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
|
|
|
|
2016-12-27 13:37:17 +00:00
|
|
|
expose :detailed_status,
|
|
|
|
as: :status,
|
2016-12-27 11:48:01 +00:00
|
|
|
with: StatusEntity
|
|
|
|
|
2016-12-09 20:56:12 +00:00
|
|
|
expose :path do |stage|
|
2016-11-10 14:32:23 +00:00
|
|
|
namespace_project_pipeline_path(
|
|
|
|
stage.pipeline.project.namespace,
|
|
|
|
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|
|
|
|
|
stage_namespace_project_pipeline_path(
|
|
|
|
stage.pipeline.project.namespace,
|
|
|
|
stage.pipeline.project,
|
|
|
|
stage.pipeline,
|
|
|
|
stage: stage.name,
|
|
|
|
format: :json)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
alias_method :stage, :object
|
|
|
|
|
|
|
|
def detailed_status
|
|
|
|
stage.detailed_status(request.user)
|
|
|
|
end
|
2016-11-10 14:32:23 +00:00
|
|
|
end
|