debian-mirror-gitlab/app/serializers/stage_entity.rb

39 lines
739 B
Ruby
Raw Normal View History

2017-08-17 22:00:37 +05:30
class StageEntity < Grape::Entity
include RequestAwareEntity
expose :name
expose :title do |stage|
"#{stage.name}: #{detailed_status.label}"
end
expose :groups,
if: -> (_, opts) { opts[:grouped] },
with: JobGroupEntity
expose :detailed_status, as: :status, with: StatusEntity
expose :path do |stage|
2017-09-10 17:25:29 +05:30
project_pipeline_path(
2017-08-17 22:00:37 +05:30
stage.pipeline.project,
stage.pipeline,
anchor: stage.name)
end
expose :dropdown_path do |stage|
2017-09-10 17:25:29 +05:30
stage_project_pipeline_path(
2017-08-17 22:00:37 +05:30
stage.pipeline.project,
stage.pipeline,
stage: stage.name,
format: :json)
end
private
alias_method :stage, :object
def detailed_status
stage.detailed_status(request.current_user)
end
end