summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-12-19 13:20:17 +0100
committerKamil Trzcinski <ayufan@ayufan.eu>2016-12-19 13:20:17 +0100
commit083e185cdaee03e66dec0ab267a2f3b5d3dab9a7 (patch)
tree274d5b4a918d5bc9b3bbecebf28d3e59c1ddd497
parente1e677a653a1c6658ad7f3c9f4fbae7f120c8a8f (diff)
downloadgitlab-ce-083e185cdaee03e66dec0ab267a2f3b5d3dab9a7.tar.gz
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) ```
-rw-r--r--app/controllers/projects/pipelines_controller.rb12
-rw-r--r--app/views/projects/pipelines/_stage.html.haml13
-rw-r--r--config/routes/project.rb1
3 files changed, 26 insertions, 0 deletions
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)
diff --git a/app/views/projects/pipelines/_stage.html.haml b/app/views/projects/pipelines/_stage.html.haml
new file mode 100644
index 00000000000..44533b77eba
--- /dev/null
+++ b/app/views/projects/pipelines/_stage.html.haml
@@ -0,0 +1,13 @@
+- detailed_status = @stage.detailed_status(current_user)
+- klass = "has-tooltip ci-status-icon ci-status-icon-#{detailed_status}"
+- hasMultipleBuilds = @stage.statuses.count > 1
+- icon_status = "#{detailed_status.icon}_borderless"
+- icon_status_klass = "ci-status-icon ci-status-icon-#{detailed_status}"
+- tooltip = "#{@stage.name}: #{detailed_status.label || 'not found'}"
+
+.dropdown.inline.build-content
+ %button.has-tooltip.builds-dropdown{ type: 'button', data: { toggle: 'dropdown', title: tooltip} }
+ %span{ class: klass }
+ %span.mini-pipeline-graph-icon-container
+ %span{ class: icon_status_klass }= custom_icon(icon_status)
+ = icon('caret-down', class: 'dropdown-caret')
diff --git a/config/routes/project.rb b/config/routes/project.rb
index 0754f0ec3b0..909794922ce 100644
--- a/config/routes/project.rb
+++ b/config/routes/project.rb
@@ -127,6 +127,7 @@ constraints(ProjectUrlConstrainer.new) do
end
member do
+ get :stage
post :cancel
post :retry
get :builds