diff --git a/app/assets/stylesheets/gitlab_bootstrap/forms.scss b/app/assets/stylesheets/gitlab_bootstrap/forms.scss index 020a0bf7fd567bf067f31c1998de216241c52748..a2612166c7858f6feedb29af472bb794ead65edc 100644 --- a/app/assets/stylesheets/gitlab_bootstrap/forms.scss +++ b/app/assets/stylesheets/gitlab_bootstrap/forms.scss @@ -6,10 +6,9 @@ form { } } -input { - &.input-xpadding { - padding: 6px 10px; - } +input.input-xpadding, +.add-on.input-xpadding { + padding: 6px 10px; } .control-group { diff --git a/app/helpers/compare_helper.rb b/app/helpers/compare_helper.rb new file mode 100644 index 0000000000000000000000000000000000000000..55d0d6268adca10af99f88354cbdce1ec45dc3ae --- /dev/null +++ b/app/helpers/compare_helper.rb @@ -0,0 +1,12 @@ +module CompareHelper + def compare_to_mr_button? + params[:from].present? && params[:to].present? && + @repository.branch_names.include?(params[:from]) && + @repository.branch_names.include?(params[:to]) && + !@refs_are_same + end + + def compare_mr_path + new_project_merge_request_path(@project, merge_request: {source_branch: params[:from], target_branch: params[:to]}) + end +end diff --git a/app/views/projects/compare/_form.html.haml b/app/views/projects/compare/_form.html.haml index 503b39c0663858db7b1d2494d6b98fef7e668f26..ca1ea4073e6ea4b51fc453d1241a93cb27d20651 100644 --- a/app/views/projects/compare/_form.html.haml +++ b/app/views/projects/compare/_form.html.haml @@ -1,30 +1,21 @@ -%div - - unless params[:to] - %p.slead - Fill input field with commit id like - %code.label-branch 4eedf23 - or branch/tag name like - %code.label-branch master - and press compare button for the commits list and a code diff. - %br - Changes are shown <b>from</b> the version in the first field <b>to</b> the version in the second field. - - - = form_tag project_compare_index_path(@project), method: :post do - .clearfix - .pull-left - - if params[:to] && params[:from] - = link_to 'switch', {from: params[:to], to: params[:from]}, {class: 'commits-compare-switch has_tooltip', title: 'Switch base of comparison'} - = text_field_tag :from, params[:from], placeholder: "from", class: "input-xlarge input-xpadding" - = "..." - = text_field_tag :to, params[:to], placeholder: "to", class: "input-xlarge input-xpadding" - .pull-left - - = submit_tag "Compare", class: "btn btn-create commits-compare-btn" - - if @refs_are_same - .alert - %span Refs are the same - += form_tag project_compare_index_path(@project), method: :post do + .clearfix + .pull-left + - if params[:to] && params[:from] + = link_to 'switch', {from: params[:to], to: params[:from]}, {class: 'commits-compare-switch has_tooltip', title: 'Switch base of comparison'} + .input-prepend + %span.add-on.input-xpadding from + = text_field_tag :from, params[:from], class: "span3 input-xpadding" + = "..." + .input-prepend + %span.add-on.input-xpadding to + = text_field_tag :to, params[:to], class: "span3 input-xpadding" + .pull-left + + = submit_tag "Compare", class: "btn btn-create commits-compare-btn" + - if compare_to_mr_button? + = link_to compare_mr_path, class: 'prepend-left-10' do + %strong Make a merge request :javascript diff --git a/app/views/projects/compare/index.html.haml b/app/views/projects/compare/index.html.haml index 8f108ed0b08932898859200945c0075536b31f29..4745bfbeaaf061e5a1f896ed2864f0ac76b2be73 100644 --- a/app/views/projects/compare/index.html.haml +++ b/app/views/projects/compare/index.html.haml @@ -2,5 +2,15 @@ %h3.page-title Compare View +%p.slead + Compare branches, tags or commit ranges. + %br + Fill input field with commit id like + %code.label-branch 4eedf23 + or branch/tag name like + %code.label-branch master + and press compare button for the commits list and a code diff. + %br + Changes are shown <b>from</b> the version in the first field <b>to</b> the version in the second field. = render "form" diff --git a/app/views/projects/compare/show.html.haml b/app/views/projects/compare/show.html.haml index af9273f9315b5eee7eec8ba9dbe40891eaea3485..4be62d3691742dcfad2c00f6f616b99117d6b4fa 100644 --- a/app/views/projects/compare/show.html.haml +++ b/app/views/projects/compare/show.html.haml @@ -20,3 +20,16 @@ - unless @diffs.empty? %h4 Diff = render "projects/commits/diffs", diffs: @diffs, project: @project +- else + .light-well + %center + %h4 + There isn't anything to compare. + %p.slead + - if params[:to] == params[:from] + You'll need to use different branch names to get a valid comparison. + - else + %span.label-branch #{params[:from]} + and + %span.label-branch #{params[:to]} + are the same. diff --git a/app/views/projects/issues/_form.html.haml b/app/views/projects/issues/_form.html.haml index 957cc5a7e2d9ed49116b9bd3fab775fda935731b..6acad9134d1e67eead4fba2bf79d76fb119834d4 100644 --- a/app/views/projects/issues/_form.html.haml +++ b/app/views/projects/issues/_form.html.haml @@ -67,8 +67,8 @@ event.preventDefault(); } }) - .bind( "click", function( event ) { - $( this ).autocomplete("search", ""); + .bind("click", function(event) { + $(this).autocomplete("search", ""); }) .autocomplete({ minLength: 0,