2016-07-28 09:30:05 -04:00
|
|
|
module Gitlab
|
|
|
|
module Badge
|
2017-07-19 07:08:47 -04:00
|
|
|
module Pipeline
|
2016-07-28 09:30:05 -04:00
|
|
|
##
|
2017-07-19 07:08:47 -04:00
|
|
|
# Class that represents a pipeline badge template.
|
2016-07-28 09:30:05 -04:00
|
|
|
#
|
|
|
|
# Template object will be passed to badge.svg.erb template.
|
|
|
|
#
|
2016-08-11 09:01:14 -04:00
|
|
|
class Template < Badge::Template
|
2017-07-19 07:31:47 -04:00
|
|
|
STATUS_RENAME = { 'success' => 'passed' }.freeze
|
2016-07-28 09:30:05 -04:00
|
|
|
STATUS_COLOR = {
|
|
|
|
success: '#4c1',
|
|
|
|
failed: '#e05d44',
|
|
|
|
running: '#dfb317',
|
|
|
|
pending: '#dfb317',
|
|
|
|
canceled: '#9f9f9f',
|
|
|
|
skipped: '#9f9f9f',
|
|
|
|
unknown: '#9f9f9f'
|
2017-02-21 18:32:18 -05:00
|
|
|
}.freeze
|
2016-07-28 09:30:05 -04:00
|
|
|
|
2016-08-11 05:16:14 -04:00
|
|
|
def initialize(badge)
|
|
|
|
@entity = badge.entity
|
|
|
|
@status = badge.status
|
2016-07-28 09:30:05 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def key_text
|
2016-08-11 05:16:14 -04:00
|
|
|
@entity.to_s
|
2016-07-28 09:30:05 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def value_text
|
2017-07-19 07:31:47 -04:00
|
|
|
STATUS_RENAME[@status.to_s] || @status.to_s
|
2016-07-28 09:30:05 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def key_width
|
2017-07-19 07:08:47 -04:00
|
|
|
62
|
2016-07-28 09:30:05 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def value_width
|
|
|
|
54
|
|
|
|
end
|
|
|
|
|
|
|
|
def value_color
|
2016-08-11 05:16:14 -04:00
|
|
|
STATUS_COLOR[@status.to_sym] || STATUS_COLOR[:unknown]
|
2016-07-28 09:30:05 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|