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 621e471c767..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_}, '') @@ -132,23 +139,15 @@ def repo_status_icon(status, details = nil) sprite_tag icon, title: description 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 - - description = REPO_STATUS_DESCRIPTIONS[status] || 'Unknown state of repository' - description = description_preface + description - description += " (#{details})" if details - description - end + 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_description(status) + description << " (#{details})" if details - 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}" + repo_state_class = outdated ? 'outdated' : 'default' + 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 # TODO: bento_only 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 2a15d957d38..ef464ad7dc3 100644 --- a/src/api/app/views/webui2/webui/package/_buildstatus.html.haml +++ b/src/api/app/views/webui2/webui/package/_buildstatus.html.haml @@ -24,10 +24,7 @@ - if !result.is_repository_in_db %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|