From 083e185cdaee03e66dec0ab267a2f3b5d3dab9a7 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 19 Dec 2016 13:20:17 +0100 Subject: Render stage dropdown in separate API call as HTML ``` Endpoint: /group/project/pipelines/id/stage.json?stage=name Call: stage_namespace_project_pipeline_path(pipeline.project.namespace, pipeline.project, pipeline, stage: stage.name) ``` --- app/controllers/projects/pipelines_controller.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'app/controllers/projects/pipelines_controller.rb') diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index 85188cfdd4c..0147072b0f1 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -8,6 +8,7 @@ class Projects::PipelinesController < Projects::ApplicationController def index @scope = params[:scope] @pipelines = PipelinesFinder.new(project).execute(scope: @scope).page(params[:page]).per(30) + @pipelines = @pipelines.includes(project: :namespace) @running_or_pending_count = PipelinesFinder.new(project).execute(scope: 'running').count @pipelines_count = PipelinesFinder.new(project).execute.count @@ -40,6 +41,17 @@ class Projects::PipelinesController < Projects::ApplicationController end end + def stage + @stage = pipeline.stages.find do |stage| + stage.name == params[:stage] + end + return not_found unless @stage + + respond_to do |format| + format.json { render json: { html: view_to_html_string('projects/pipelines/_stage') } } + end + end + def retry pipeline.retry_failed(current_user) -- cgit v1.2.1 From 2b0b53cddd7d57ca5dd93437fdffefd7a07af91e Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Tue, 20 Dec 2016 11:00:56 +0100 Subject: Add tests for stage API endpoint --- app/controllers/projects/pipelines_controller.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'app/controllers/projects/pipelines_controller.rb') diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb index 0147072b0f1..cc347922c6a 100644 --- a/app/controllers/projects/pipelines_controller.rb +++ b/app/controllers/projects/pipelines_controller.rb @@ -42,9 +42,7 @@ class Projects::PipelinesController < Projects::ApplicationController end def stage - @stage = pipeline.stages.find do |stage| - stage.name == params[:stage] - end + @stage = pipeline.stage(params[:stage]) return not_found unless @stage respond_to do |format| -- cgit v1.2.1