Skip to content

Commit

Permalink
Set four groups of package build status
Browse files Browse the repository at this point in the history
Set one color for each group and use those colors on status icons.

- Successful final status (green)
- Unsuccessful final status (red)
- In progress status (yellow)
- Refused (disabled/excluded) status (light grey)

Also add missing icon for 'deleting' status.
  • Loading branch information
saraycp committed Nov 16, 2022
1 parent 891b9a8 commit 038c1ac
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/api/.rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ Metrics/ClassLength:
- 'app/models/bs_request_action_maintenance_incident.rb'
- 'app/models/bs_request_action_maintenance_release.rb'
- 'app/models/bs_request_permission_check.rb'
- 'app/models/buildresult.rb'
- 'app/models/channel.rb'
- 'app/models/event/base.rb'
- 'app/models/event/request.rb'
Expand Down
15 changes: 8 additions & 7 deletions src/api/app/helpers/webui/buildresult_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ module Webui::BuildresultHelper
broken: 'fa-xmark text-danger',
blocked: 'fa-shield text-warning',
scheduled: 'fa-hourglass-half text-warning',
dispatching: 'fa-plane-departure',
building: 'fa-gear',
signing: 'fa-signature',
finished: 'fa-check',
disabled: 'fa-xmark text-warning',
excluded: 'fa-xmark text-warning',
dispatching: 'fa-plane-departure text-warning',
building: 'fa-gear text-warning',
signing: 'fa-signature text-warning',
finished: 'fa-check text-warning',
disabled: 'fa-xmark text-gray-500',
excluded: 'fa-xmark text-gray-500',
locked: 'fa-lock text-warning',
unknown: 'fa-question'
deleting: 'fa-eraser text-warning',
unknown: 'fa-question text-warning'
}.with_indifferent_access.freeze

def repository_expanded?(collapsed_repositories, repository_name, key = 'project')
Expand Down
22 changes: 22 additions & 0 deletions src/api/app/models/buildresult.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class Buildresult
attr_accessor :status

AVAIL_STATUS_VALUES = {
succeeded: 0,
failed: 1,
Expand Down Expand Up @@ -39,6 +41,10 @@ class Buildresult
unknown: 'The scheduler has not yet evaluated this package. Should be a short intermediate state for new packages.'
}.with_indifferent_access.freeze

def initialize(status)
@status = status
end

def self.find_hashed(opts = {})
begin
xml = Backend::Api::BuildResults::Status.result_swiss_knife(opts.delete(:project), opts)
Expand Down Expand Up @@ -100,4 +106,20 @@ def self.code2index(code)

raise ArgumentError, "code '#{code}' unknown #{AVAIL_STATUS_VALUES.inspect}"
end

def successful_final_status?
status.in?(['succeeded'])
end

def unsuccessful_final_status?
status.in?(['failed', 'unresolvable', 'broken'])
end

def in_progress_status?
status.in?(['blocked', 'dispatching', 'scheduled', 'building', 'finished', 'signing', 'locked', 'deleting', 'unknown'])
end

def refused_status?
status.in?(['disabled', 'excluded'])
end
end

0 comments on commit 038c1ac

Please sign in to comment.