From 9b5a83816ec96b4c3a896c3d7c5edf358e62622f Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Wed, 31 Aug 2016 16:30:54 +0300 Subject: [PATCH] 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 --- app/helpers/merge_requests_helper.rb | 4 ++++ .../merge_requests/show/_versions.html.haml | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb index a9e175c3f5c..d5470d5d3c8 100644 --- a/app/helpers/merge_requests_helper.rb +++ b/app/helpers/merge_requests_helper.rb @@ -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 diff --git a/app/views/projects/merge_requests/show/_versions.html.haml b/app/views/projects/merge_requests/show/_versions.html.haml index 2da70ce7137..d2a70bcc716 100644 --- a/app/views/projects/merge_requests/show/_versions.html.haml +++ b/app/views/projects/merge_requests/show/_versions.html.haml @@ -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}