Commit f774949d3f7676f925c7fc858d462ec2400e43a2

Authored by Dmitriy Zaporozhets
1 parent edb3368c

Compare page improved

* Show new merge request button from compare page
* Show message if user selected same branches
* Show message if compared branches are the same
* Prepend inputs with from/to labels
app/assets/stylesheets/gitlab_bootstrap/forms.scss
@@ -6,10 +6,9 @@ form { @@ -6,10 +6,9 @@ form {
6 } 6 }
7 } 7 }
8 8
9 -input {  
10 - &.input-xpadding {  
11 - padding: 6px 10px;  
12 - } 9 +input.input-xpadding,
  10 +.add-on.input-xpadding {
  11 + padding: 6px 10px;
13 } 12 }
14 13
15 .control-group { 14 .control-group {
app/helpers/compare_helper.rb 0 → 100644
@@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
  1 +module CompareHelper
  2 + def compare_to_mr_button?
  3 + params[:from].present? && params[:to].present? &&
  4 + @repository.branch_names.include?(params[:from]) &&
  5 + @repository.branch_names.include?(params[:to]) &&
  6 + !@refs_are_same
  7 + end
  8 +
  9 + def compare_mr_path
  10 + new_project_merge_request_path(@project, merge_request: {source_branch: params[:from], target_branch: params[:to]})
  11 + end
  12 +end
app/views/projects/compare/_form.html.haml
1 -%div  
2 - - unless params[:to]  
3 - %p.slead  
4 - Fill input field with commit id like  
5 - %code.label-branch 4eedf23  
6 - or branch/tag name like  
7 - %code.label-branch master  
8 - and press compare button for the commits list and a code diff.  
9 - %br  
10 - Changes are shown <b>from</b> the version in the first field <b>to</b> the version in the second field.  
11 -  
12 -  
13 - = form_tag project_compare_index_path(@project), method: :post do  
14 - .clearfix  
15 - .pull-left  
16 - - if params[:to] && params[:from]  
17 - = link_to 'switch', {from: params[:to], to: params[:from]}, {class: 'commits-compare-switch has_tooltip', title: 'Switch base of comparison'}  
18 - = text_field_tag :from, params[:from], placeholder: "from", class: "input-xlarge input-xpadding"  
19 - = "..."  
20 - = text_field_tag :to, params[:to], placeholder: "to", class: "input-xlarge input-xpadding"  
21 - .pull-left  
22 - &nbsp;  
23 - = submit_tag "Compare", class: "btn btn-create commits-compare-btn"  
24 - - if @refs_are_same  
25 - .alert  
26 - %span Refs are the same  
27 - 1 += form_tag project_compare_index_path(@project), method: :post do
  2 + .clearfix
  3 + .pull-left
  4 + - if params[:to] && params[:from]
  5 + = link_to 'switch', {from: params[:to], to: params[:from]}, {class: 'commits-compare-switch has_tooltip', title: 'Switch base of comparison'}
  6 + .input-prepend
  7 + %span.add-on.input-xpadding from
  8 + = text_field_tag :from, params[:from], class: "span3 input-xpadding"
  9 + = "..."
  10 + .input-prepend
  11 + %span.add-on.input-xpadding to
  12 + = text_field_tag :to, params[:to], class: "span3 input-xpadding"
  13 + .pull-left
  14 + &nbsp;
  15 + = submit_tag "Compare", class: "btn btn-create commits-compare-btn"
  16 + - if compare_to_mr_button?
  17 + = link_to compare_mr_path, class: 'prepend-left-10' do
  18 + %strong Make a merge request
28 19
29 20
30 :javascript 21 :javascript
app/views/projects/compare/index.html.haml
@@ -2,5 +2,15 @@ @@ -2,5 +2,15 @@
2 2
3 %h3.page-title 3 %h3.page-title
4 Compare View 4 Compare View
  5 +%p.slead
  6 + Compare branches, tags or commit ranges.
  7 + %br
  8 + Fill input field with commit id like
  9 + %code.label-branch 4eedf23
  10 + or branch/tag name like
  11 + %code.label-branch master
  12 + and press compare button for the commits list and a code diff.
  13 + %br
  14 + Changes are shown <b>from</b> the version in the first field <b>to</b> the version in the second field.
5 15
6 = render "form" 16 = render "form"
app/views/projects/compare/show.html.haml
@@ -20,3 +20,16 @@ @@ -20,3 +20,16 @@
20 - unless @diffs.empty? 20 - unless @diffs.empty?
21 %h4 Diff 21 %h4 Diff
22 = render "projects/commits/diffs", diffs: @diffs, project: @project 22 = render "projects/commits/diffs", diffs: @diffs, project: @project
  23 +- else
  24 + .light-well
  25 + %center
  26 + %h4
  27 + There isn't anything to compare.
  28 + %p.slead
  29 + - if params[:to] == params[:from]
  30 + You'll need to use different branch names to get a valid comparison.
  31 + - else
  32 + %span.label-branch #{params[:from]}
  33 + and
  34 + %span.label-branch #{params[:to]}
  35 + are the same.
app/views/projects/issues/_form.html.haml
@@ -67,8 +67,8 @@ @@ -67,8 +67,8 @@
67 event.preventDefault(); 67 event.preventDefault();
68 } 68 }
69 }) 69 })
70 - .bind( "click", function( event ) {  
71 - $( this ).autocomplete("search", ""); 70 + .bind("click", function(event) {
  71 + $(this).autocomplete("search", "");
72 }) 72 })
73 .autocomplete({ 73 .autocomplete({
74 minLength: 0, 74 minLength: 0,