2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
module Ci
|
2018-10-15 14:42:47 +05:30
|
|
|
class BuildPresenter < CommitStatusPresenter
|
2017-08-17 22:00:37 +05:30
|
|
|
def erased_by_user?
|
|
|
|
# Build can be erased through API, therefore it does not have
|
|
|
|
# `erased_by` user assigned in that case.
|
|
|
|
erased? && erased_by
|
|
|
|
end
|
|
|
|
|
|
|
|
def erased_by_name
|
|
|
|
erased_by.name if erased_by_user?
|
|
|
|
end
|
|
|
|
|
|
|
|
def status_title
|
|
|
|
if auto_canceled?
|
|
|
|
"Job is redundant and is auto-canceled by Pipeline ##{auto_canceled_by_id}"
|
2018-05-09 12:01:36 +05:30
|
|
|
else
|
|
|
|
tooltip_for_badge
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
def trigger_variables
|
|
|
|
return [] unless trigger_request
|
|
|
|
|
|
|
|
@trigger_variables ||=
|
|
|
|
if pipeline.variables.any?
|
|
|
|
pipeline.variables.map(&:to_runner_variable)
|
|
|
|
else
|
|
|
|
trigger_request.user_variables
|
|
|
|
end
|
|
|
|
end
|
2018-05-09 12:01:36 +05:30
|
|
|
|
|
|
|
def tooltip_message
|
|
|
|
"#{subject.name} - #{detailed_status.status_tooltip}"
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def tooltip_for_badge
|
|
|
|
detailed_status.badge_tooltip.capitalize
|
|
|
|
end
|
|
|
|
|
|
|
|
def detailed_status
|
|
|
|
@detailed_status ||= subject.detailed_status(user)
|
|
|
|
end
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|