BigW Consortium Gitlab

stage_entity.rb 739 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
    project_pipeline_path(
18
      stage.pipeline.project,
19
      stage.pipeline,
20 21
      anchor: stage.name)
  end
22 23

  expose :dropdown_path do |stage|
24
    stage_project_pipeline_path(
25 26 27 28 29 30 31 32 33 34 35
      stage.pipeline.project,
      stage.pipeline,
      stage: stage.name,
      format: :json)
  end

  private

  alias_method :stage, :object

  def detailed_status
36
    stage.detailed_status(request.current_user)
37
  end
38
end