BigW Consortium Gitlab

stage_entity.rb 839 Bytes
Newer Older
1
class StageEntity < Grape::Entity
2 3
  include RequestAwareEntity

4
  expose :name
5

6 7
  expose :title do |stage|
    "#{stage.name}: #{detailed_status.label}"
8
  end
9

10 11 12 13 14
  expose :groups,
    if: -> (_, opts) { opts[:grouped] },
    with: JobGroupEntity

  expose :detailed_status, as: :status, with: StatusEntity
15

16
  expose :path do |stage|
17 18 19
    namespace_project_pipeline_path(
      stage.pipeline.project.namespace,
      stage.pipeline.project,
20
      stage.pipeline,
21 22
      anchor: stage.name)
  end
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37

  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
38
    stage.detailed_status(request.current_user)
39
  end
40
end