stage_entity.rb 750 Bytes
Newer Older
1
class StageEntity < Grape::Entity
Kamil Trzciński's avatar
Kamil Trzciński committed
2 3
  include RequestAwareEntity

4
  expose :name
5

6 7
  expose :title do |stage|
    "#{stage.name}: #{detailed_status.label}"
8
  end
Kamil Trzciński's avatar
Kamil Trzciński committed
9

10 11 12
  expose :detailed_status, as: :status,
    with: StatusEntity

13
  expose :path do |stage|
Kamil Trzciński's avatar
Kamil Trzciński committed
14 15 16
    namespace_project_pipeline_path(
      stage.pipeline.project.namespace,
      stage.pipeline.project,
17
      stage.pipeline,
Kamil Trzciński's avatar
Kamil Trzciński committed
18 19
      anchor: stage.name)
  end
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

  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
Kamil Trzciński's avatar
Kamil Trzciński committed
37
end