Commit 9b5a8381 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Add link to compare merge request versions

It adds a dropdown to the right of merge request version dropdown and
allow you to choose older version for compare. Once clicked it will take
user to compare page with older and newer versions sha pre-filled
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 1e042ac2
...@@ -100,4 +100,8 @@ module MergeRequestsHelper ...@@ -100,4 +100,8 @@ module MergeRequestsHelper
def merge_request_button_visibility(merge_request, closed) def merge_request_button_visibility(merge_request, closed)
return 'hidden' if merge_request.closed? == closed || (merge_request.merged? == closed && !merge_request.closed?) || merge_request.closed_without_fork? return 'hidden' if merge_request.closed? == closed || (merge_request.merged? == closed && !merge_request.closed?) || merge_request.closed_without_fork?
end end
def compare_versions_path(project, version, base_version)
namespace_project_compare_path(project.namespace, project, base_version.head_commit_sha, version.head_commit_sha)
end
end end
...@@ -22,10 +22,32 @@ ...@@ -22,10 +22,32 @@
#{number_with_delimiter(merge_request_diff.commits.count)} #{'commit'.pluralize(merge_request_diff.commits.count)}, #{number_with_delimiter(merge_request_diff.commits.count)} #{'commit'.pluralize(merge_request_diff.commits.count)},
= time_ago_with_tooltip(merge_request_diff.created_at) = time_ago_with_tooltip(merge_request_diff.created_at)
%span.prepend-left-default
Compared with:
%span.dropdown.inline
%a.btn-link.dropdown-toggle{ data: {toggle: :dropdown} }
%strong.monospace base
%span.caret
%ul.dropdown-menu.dropdown-menu-selectable
- merge_request_diffs.each do |merge_request_diff|
- next if merge_request_diff.id >= @merge_request_diff.id
%li
= link_to compare_versions_path(@project, @merge_request_diff, merge_request_diff), class: ('is-active' if merge_request_diff == @base_version), target: '_blank' do
%strong.monospace
#{merge_request_diff.head_commit.short_id}
%br
%small
= time_ago_with_tooltip(merge_request_diff.created_at)
%li
= link_to '#', class: 'is-active' do
%strong.monospace
base
- unless @merge_request_diff.latest? - unless @merge_request_diff.latest?
%span.prepend-left-default %span.prepend-left-default
= icon('info-circle') = icon('info-circle')
This version is not the latest one. Comments are disabled This version is not the latest one. Comments are disabled
.pull-right .pull-right
%span.monospace %span.monospace
#{@merge_request_diff.base_commit.short_id}..#{@merge_request_diff.head_commit.short_id} #{@merge_request_diff.base_commit.short_id}..#{@merge_request_diff.head_commit.short_id}
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