Add proper stage.json data
This commit is contained in:
parent
e0b7541b9a
commit
551f8c4b1a
3 changed files with 31 additions and 3 deletions
|
@ -104,9 +104,9 @@ class Projects::PipelinesController < Projects::ApplicationController
|
|||
@stage = pipeline.legacy_stage(params[:stage])
|
||||
return not_found unless @stage
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: { html: view_to_html_string('projects/pipelines/_stage') } }
|
||||
end
|
||||
render json: StageSerializer
|
||||
.new(project: @project, current_user: @current_user)
|
||||
.represent(@pipeline)
|
||||
end
|
||||
|
||||
def retry
|
||||
|
|
21
app/serializers/stage_details_entity.rb
Normal file
21
app/serializers/stage_details_entity.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
class StageDetailsEntity < Grape::Entity
|
||||
include RequestAwareEntity
|
||||
|
||||
expose :name
|
||||
|
||||
expose :title do |stage|
|
||||
"#{stage.name}: #{detailed_status.label}"
|
||||
end
|
||||
|
||||
expose :statuses, with: JobEntity
|
||||
|
||||
expose :detailed_status, as: :status, with: StatusEntity
|
||||
|
||||
private
|
||||
|
||||
alias_method :stage, :object
|
||||
|
||||
def detailed_status
|
||||
stage.detailed_status(request.current_user)
|
||||
end
|
||||
end
|
7
app/serializers/stage_serializer.rb
Normal file
7
app/serializers/stage_serializer.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
class StageSerializer < BaseSerializer
|
||||
include WithPagination
|
||||
|
||||
InvalidResourceError = Class.new(StandardError)
|
||||
|
||||
entity StageDetailsEntity
|
||||
end
|
Loading…
Reference in a new issue