2016-07-28 09:30:05 -04:00
|
|
|
module Gitlab
|
|
|
|
module Badge
|
2016-08-10 08:12:31 -04:00
|
|
|
module Build
|
2016-07-28 09:30:05 -04:00
|
|
|
##
|
2016-08-08 06:49:26 -04:00
|
|
|
# Class that represents a build 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
|
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
|
2016-08-11 05:16:14 -04:00
|
|
|
@status.to_s
|
2016-07-28 09:30:05 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def key_width
|
|
|
|
38
|
|
|
|
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
|