From c1e6ca1413fc8cacecdcc79d330c0dd4fbe774a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Geuken?= Date: Tue, 18 Dec 2018 11:22:26 +0100 Subject: [PATCH 1/3] Align appearance of build status icons * Add tooltip to build status icons on monitor and binary page * Wrap common code in a helper method --- src/api/app/helpers/webui/webui_helper.rb | 7 +++++++ .../app/views/webui2/webui/package/_buildstatus.html.haml | 5 +---- src/api/app/views/webui2/webui/package/binaries.html.haml | 2 +- .../app/views/webui2/webui/project/_buildstatus.html.haml | 5 +---- src/api/app/views/webui2/webui/project/monitor.html.haml | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/api/app/helpers/webui/webui_helper.rb b/src/api/app/helpers/webui/webui_helper.rb index 621e471c767..abfda3bae36 100644 --- a/src/api/app/helpers/webui/webui_helper.rb +++ b/src/api/app/helpers/webui/webui_helper.rb @@ -132,6 +132,13 @@ def repo_status_icon(status, details = nil) sprite_tag icon, title: description end + def webui2_repository_status_icon(status:, details: nil, html_class: '') + icon = webui2_repo_status_icon(status) + description = webui2_repo_status_description(status, details) + content_tag(:i, '', class: "#{html_class} #{webui2_repo_status_icon(status)}", + data: { content: description, placement: 'top', toggle: 'popover' }) + end + def webui2_repo_status_description(status, details) description_preface = '' if /^outdated_/.match?(status) diff --git a/src/api/app/views/webui2/webui/package/_buildstatus.html.haml b/src/api/app/views/webui2/webui/package/_buildstatus.html.haml index 24c93f6dce5..1361e0e074b 100644 --- a/src/api/app/views/webui2/webui/package/_buildstatus.html.haml +++ b/src/api/app/views/webui2/webui/package/_buildstatus.html.haml @@ -25,10 +25,7 @@ - if !(repository && repository.architectures.pluck(:name).include?(result.architecture)) %i.fas.fa-clock.text-warning{ title: 'This result is outdated' } - else - :ruby - icon = webui2_repo_status_icon(result.state) - description = webui2_repo_status_description(result.state, result.details) - %i{ class: icon, data: { content: description, placement: 'top', toggle: 'popover' } } + = webui2_repository_status_icon(status: result.state, details: result.details) %span.ml-1 = result.architecture .col-6.col-sm-5.buildstatus.text-nowrap diff --git a/src/api/app/views/webui2/webui/package/binaries.html.haml b/src/api/app/views/webui2/webui/package/binaries.html.haml index 6e213afa461..3241d742f63 100644 --- a/src/api/app/views/webui2/webui/package/binaries.html.haml +++ b/src/api/app/views/webui2/webui/package/binaries.html.haml @@ -15,7 +15,7 @@ - @buildresults.each do |result| %h5.bg-light.p-2.mb-0 - %i{ class: "#{webui2_repo_status_icon(result[:repocode])} fa-xs" } + = webui2_repository_status_icon(status: result[:repocode].to_s, html_class: 'fa-xs') = result[:arch] - if result[:binaries].empty? %p.pl-2 diff --git a/src/api/app/views/webui2/webui/project/_buildstatus.html.haml b/src/api/app/views/webui2/webui/project/_buildstatus.html.haml index a2580414460..3ffb1f8472b 100644 --- a/src/api/app/views/webui2/webui/project/_buildstatus.html.haml +++ b/src/api/app/views/webui2/webui/project/_buildstatus.html.haml @@ -24,10 +24,7 @@ - build_results.sort_by(&:architecture).each do |build_result| .row.py-1 .col-4.col-sm-3.offset-2.offset-sm-4.text-nowrap{ title: "#{repository} summary" } - :ruby - icon = webui2_repo_status_icon(build_result.state) - description = webui2_repo_status_description(build_result.state, build_result.details) - %i{ class: icon, data: { content: description, placement: 'top', toggle: 'popover' } } + = webui2_repository_status_icon(status: build_result.state, details: build_result.details) %span.ml-1 = link_to(build_result.architecture, { action: :monitor, "#{valid_xml_id('repo_' + repository)}": 1, diff --git a/src/api/app/views/webui2/webui/project/monitor.html.haml b/src/api/app/views/webui2/webui/project/monitor.html.haml index 7c46e0697c4..53445ff775e 100644 --- a/src/api/app/views/webui2/webui/project/monitor.html.haml +++ b/src/api/app/views/webui2/webui/project/monitor.html.haml @@ -24,7 +24,7 @@ - @repohash.sort.each do |repo, archlist| - archlist.sort.each do |arch| %th.text-center - %i.fa-xs.mr-1{ class: webui2_repo_status_icon(@repostatushash[repo][arch]) } + = webui2_repository_status_icon(status: @repostatushash[repo][arch], html_class: 'fa-xs mr-1') = arch %tbody - @packagenames.each do |packname| From e35661a59d19c16198bd34c45bdf99b3c2184363 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Geuken?= Date: Tue, 18 Dec 2018 11:28:33 +0100 Subject: [PATCH 2/3] Refactor repository state: outdated * Move coloring of repository state icon to CSS * Refactor handling of 'outdated_' flag --- .../stylesheets/webui2/build-results.scss | 8 ++++++ src/api/app/helpers/webui/webui_helper.rb | 26 ++++++------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/api/app/assets/stylesheets/webui2/build-results.scss b/src/api/app/assets/stylesheets/webui2/build-results.scss index 5f94c56cc8c..ba39b6dc02a 100644 --- a/src/api/app/assets/stylesheets/webui2/build-results.scss +++ b/src/api/app/assets/stylesheets/webui2/build-results.scss @@ -45,3 +45,11 @@ .build-state-scheduled-warning, .build-state-unknown { color: $yellow; } + +.repository-state-default { + @extend .text-black-50; +} + +.repository-state-outdated { + @extend .text-gray-400; +} diff --git a/src/api/app/helpers/webui/webui_helper.rb b/src/api/app/helpers/webui/webui_helper.rb index abfda3bae36..d26df9634ad 100644 --- a/src/api/app/helpers/webui/webui_helper.rb +++ b/src/api/app/helpers/webui/webui_helper.rb @@ -133,29 +133,19 @@ def repo_status_icon(status, details = nil) end def webui2_repository_status_icon(status:, details: nil, html_class: '') - icon = webui2_repo_status_icon(status) - description = webui2_repo_status_description(status, details) - content_tag(:i, '', class: "#{html_class} #{webui2_repo_status_icon(status)}", - data: { content: description, placement: 'top', toggle: 'popover' }) - end - - def webui2_repo_status_description(status, details) - description_preface = '' - if /^outdated_/.match?(status) - status.gsub!(%r{^outdated_}, '') - description_preface = 'State needs recalculations, former state was: ' - end + outdated = status.sub!(/^outdated_/, '') + description = outdated ? 'State needs recalculations, former state was: ' : '' + description << REPO_STATUS_DESCRIPTIONS[status] || 'Unknown state of repository' + description << " (#{details})" if details - description = REPO_STATUS_DESCRIPTIONS[status] || 'Unknown state of repository' - description = description_preface + description - description += " (#{details})" if details - description + repo_state_class = outdated ? 'outdated' : 'default' + content_tag(:i, '', class: "repository-state-#{repo_state_class} #{html_class} #{webui2_repo_status_icon(status)}", + data: { content: description, placement: 'top', toggle: 'popover' }) end def webui2_repo_status_icon(status) icon = WEBUI2_REPO_STATUS_ICONS[status] || 'eye' - color = /^outdated_/.match?(status) ? 'text-gray-400' : 'text-black-50' - "fas fa-#{icon} #{color}" + "fas fa-#{icon}" end # TODO: bento_only From 418bfd9a831c5f8435c0b6c532225d7fdde3cb19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Geuken?= Date: Tue, 18 Dec 2018 12:27:07 +0100 Subject: [PATCH 3/3] Wrap REPO_STATUS constants in a method and add a default --- src/api/app/helpers/webui/webui_helper.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/api/app/helpers/webui/webui_helper.rb b/src/api/app/helpers/webui/webui_helper.rb index d26df9634ad..0d9faef3b49 100644 --- a/src/api/app/helpers/webui/webui_helper.rb +++ b/src/api/app/helpers/webui/webui_helper.rb @@ -111,6 +111,14 @@ def format_projectname(prjname, login) 'scheduling' => 'The repository state is being calculated right now' }.freeze + def repo_status_description(status) + REPO_STATUS_DESCRIPTIONS[status] || 'Unknown state of repository' + end + + def webui2_repo_status_icon(status) + WEBUI2_REPO_STATUS_ICONS[status] || 'eye' + end + def check_first(first) first.nil? ? true : nil end @@ -118,7 +126,6 @@ def check_first(first) # TODO: bento_only def repo_status_icon(status, details = nil) icon = REPO_STATUS_ICONS[status] || 'eye' - outdated = nil if /^outdated_/.match?(status) status.gsub!(%r{^outdated_}, '') @@ -135,19 +142,14 @@ def repo_status_icon(status, details = nil) def webui2_repository_status_icon(status:, details: nil, html_class: '') outdated = status.sub!(/^outdated_/, '') description = outdated ? 'State needs recalculations, former state was: ' : '' - description << REPO_STATUS_DESCRIPTIONS[status] || 'Unknown state of repository' + description << repo_status_description(status) description << " (#{details})" if details repo_state_class = outdated ? 'outdated' : 'default' - content_tag(:i, '', class: "repository-state-#{repo_state_class} #{html_class} #{webui2_repo_status_icon(status)}", + content_tag(:i, '', class: "repository-state-#{repo_state_class} #{html_class} fas fa-#{webui2_repo_status_icon(status)}", data: { content: description, placement: 'top', toggle: 'popover' }) end - def webui2_repo_status_icon(status) - icon = WEBUI2_REPO_STATUS_ICONS[status] || 'eye' - "fas fa-#{icon}" - end - # TODO: bento_only def tab(id, text, opts) opts[:package] = @package.to_s if @package