2016-09-13 17:45:13 +05:30
|
|
|
module Gitlab
|
|
|
|
module Badge
|
2017-09-10 17:25:29 +05:30
|
|
|
module Pipeline
|
2016-09-13 17:45:13 +05:30
|
|
|
##
|
2017-09-10 17:25:29 +05:30
|
|
|
# Class that represents a pipeline badge template.
|
2016-09-13 17:45:13 +05:30
|
|
|
#
|
|
|
|
# Template object will be passed to badge.svg.erb template.
|
|
|
|
#
|
|
|
|
class Template < Badge::Template
|
2017-09-10 17:25:29 +05:30
|
|
|
STATUS_RENAME = { 'success' => 'passed' }.freeze
|
2016-09-13 17:45:13 +05:30
|
|
|
STATUS_COLOR = {
|
|
|
|
success: '#4c1',
|
|
|
|
failed: '#e05d44',
|
|
|
|
running: '#dfb317',
|
|
|
|
pending: '#dfb317',
|
|
|
|
canceled: '#9f9f9f',
|
|
|
|
skipped: '#9f9f9f',
|
|
|
|
unknown: '#9f9f9f'
|
2017-08-17 22:00:37 +05:30
|
|
|
}.freeze
|
2016-09-13 17:45:13 +05:30
|
|
|
|
|
|
|
def initialize(badge)
|
|
|
|
@entity = badge.entity
|
|
|
|
@status = badge.status
|
|
|
|
end
|
|
|
|
|
|
|
|
def key_text
|
|
|
|
@entity.to_s
|
|
|
|
end
|
|
|
|
|
|
|
|
def value_text
|
2017-09-10 17:25:29 +05:30
|
|
|
STATUS_RENAME[@status.to_s] || @status.to_s
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def key_width
|
2017-09-10 17:25:29 +05:30
|
|
|
62
|
2016-09-13 17:45:13 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def value_width
|
|
|
|
54
|
|
|
|
end
|
|
|
|
|
|
|
|
def value_color
|
|
|
|
STATUS_COLOR[@status.to_sym] || STATUS_COLOR[:unknown]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|