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: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
Dmitriy Zaporozhets 2016-08-31 16:30:54 +03:00
parent 1e042ac251
commit 9b5a83816e
2 changed files with 26 additions and 0 deletions

View file

@ -100,4 +100,8 @@ module MergeRequestsHelper
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?
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

View file

@ -22,10 +22,32 @@
#{number_with_delimiter(merge_request_diff.commits.count)} #{'commit'.pluralize(merge_request_diff.commits.count)},
= 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?
%span.prepend-left-default
= icon('info-circle')
This version is not the latest one. Comments are disabled
.pull-right
%span.monospace
#{@merge_request_diff.base_commit.short_id}..#{@merge_request_diff.head_commit.short_id}