Commit f7da5065 authored by Grzegorz Bizon's avatar Grzegorz Bizon Committed by Annabel Dunstone Gray

Extract pipeline vars in merge requests controller

parent db0e700d
...@@ -483,13 +483,12 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -483,13 +483,12 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@noteable = @merge_request @noteable = @merge_request
@commits_count = @merge_request.commits.count @commits_count = @merge_request.commits.count
@pipeline = @merge_request.pipeline
@statuses = @pipeline.statuses.relevant if @pipeline
if @merge_request.locked_long_ago? if @merge_request.locked_long_ago?
@merge_request.unlock_mr @merge_request.unlock_mr
@merge_request.close @merge_request.close
end end
define_pipelines_vars
end end
# Discussion tab data is rendered on html responses of actions # Discussion tab data is rendered on html responses of actions
...@@ -543,6 +542,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -543,6 +542,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController
) )
end end
def define_pipelines_vars
@pipelines = @merge_request.all_pipelines
if @pipelines.any?
@pipeline = @pipelines.first
@statuses = @pipeline.statuses.relevant
end
end
def define_new_vars def define_new_vars
@noteable = @merge_request @noteable = @merge_request
...@@ -558,10 +566,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -558,10 +566,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@commit = @merge_request.diff_head_commit @commit = @merge_request.diff_head_commit
@base_commit = @merge_request.diff_base_commit @base_commit = @merge_request.diff_base_commit
@pipelines = @merge_request.all_pipelines
@statuses = @pipelines.first.statuses.relevant if @pipelines.any?
@note_counts = Note.where(commit_id: @commits.map(&:id)). @note_counts = Note.where(commit_id: @commits.map(&:id)).
group(:commit_id).count group(:commit_id).count
define_pipelines_vars
end end
def invalid_mr def invalid_mr
......
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
%li.pipelines-tab %li.pipelines-tab
= link_to pipelines_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: { target: '#pipelines', action: 'pipelines', toggle: 'tab' } do = link_to pipelines_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: { target: '#pipelines', action: 'pipelines', toggle: 'tab' } do
Pipelines Pipelines
%span.badge= @merge_request.all_pipelines.size %span.badge= @pipelines.size
%li.builds-tab %li.builds-tab
= link_to builds_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: { target: '#builds', action: 'builds', toggle: 'tab' } do = link_to builds_namespace_project_merge_request_path(@project.namespace, @project, @merge_request), data: { target: '#builds', action: 'builds', toggle: 'tab' } do
Builds Builds
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment