Add proper stage.json data

This commit is contained in:
Kamil Trzciński 2018-04-23 15:58:59 +02:00
parent e0b7541b9a
commit 551f8c4b1a
3 changed files with 31 additions and 3 deletions

View file

@ -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

View 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

View file

@ -0,0 +1,7 @@
class StageSerializer < BaseSerializer
include WithPagination
InvalidResourceError = Class.new(StandardError)
entity StageDetailsEntity
end