Skip to content

Commit

Permalink
Merge pull request #6654 from bgeuken/sync_build_results
Browse files Browse the repository at this point in the history
Sync repository state icons
  • Loading branch information
bgeuken committed Dec 19, 2018
2 parents da503da + 418bfd9 commit cf8b4ef
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 27 deletions.
8 changes: 8 additions & 0 deletions src/api/app/assets/stylesheets/webui2/build-results.scss
Expand Up @@ -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;
}
33 changes: 16 additions & 17 deletions src/api/app/helpers/webui/webui_helper.rb
Expand Up @@ -111,14 +111,21 @@ 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

# 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_}, '')
Expand All @@ -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
Expand Down
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/views/webui2/webui/package/binaries.html.haml
Expand Up @@ -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
Expand Down
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/views/webui2/webui/project/monitor.html.haml
Expand Up @@ -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|
Expand Down

0 comments on commit cf8b4ef

Please sign in to comment.