2016-12-21 13:51:53 +00:00
|
|
|
class StageEntity < Grape::Entity
|
2016-11-10 14:32:23 +00:00
|
|
|
include RequestAwareEntity
|
|
|
|
|
2016-12-09 20:56:12 +00:00
|
|
|
expose :name
|
2016-12-21 14:47:03 +00:00
|
|
|
|
2016-12-27 11:48:01 +00:00
|
|
|
expose :title do |stage|
|
|
|
|
"#{stage.name}: #{detailed_status.label}"
|
2016-12-15 14:59:18 +00:00
|
|
|
end
|
2016-11-10 14:32:23 +00:00
|
|
|
|
2017-05-06 16:45:46 +00:00
|
|
|
expose :groups,
|
|
|
|
if: -> (_, opts) { opts[:grouped] },
|
|
|
|
with: JobGroupEntity
|
|
|
|
|
|
|
|
expose :detailed_status, as: :status, with: StatusEntity
|
2016-12-27 11:48:01 +00:00
|
|
|
|
2016-12-09 20:56:12 +00:00
|
|
|
expose :path do |stage|
|
2017-06-29 17:06:35 +00:00
|
|
|
project_pipeline_path(
|
2016-11-10 14:32:23 +00:00
|
|
|
stage.pipeline.project,
|
2016-12-27 11:48:01 +00:00
|
|
|
stage.pipeline,
|
2016-11-10 14:32:23 +00:00
|
|
|
anchor: stage.name)
|
|
|
|
end
|
2016-12-27 11:48:01 +00:00
|
|
|
|
|
|
|
expose :dropdown_path do |stage|
|
2017-06-29 17:06:35 +00:00
|
|
|
stage_project_pipeline_path(
|
2016-12-27 11:48:01 +00:00
|
|
|
stage.pipeline.project,
|
|
|
|
stage.pipeline,
|
|
|
|
stage: stage.name,
|
|
|
|
format: :json)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
alias_method :stage, :object
|
|
|
|
|
|
|
|
def detailed_status
|
2017-05-09 04:15:34 +00:00
|
|
|
stage.detailed_status(request.current_user)
|
2016-12-27 11:48:01 +00:00
|
|
|
end
|
2016-11-10 14:32:23 +00:00
|
|
|
end
|