From f774949d3f7676f925c7fc858d462ec2400e43a2 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> Date: Thu, 12 Sep 2013 20:15:10 +0300 Subject: [PATCH] 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 --- .../stylesheets/gitlab_bootstrap/forms.scss | 7 ++- app/helpers/compare_helper.rb | 12 +++++ app/views/projects/compare/_form.html.haml | 45 ++++++++----------- app/views/projects/compare/index.html.haml | 10 +++++ app/views/projects/compare/show.html.haml | 13 ++++++ app/views/projects/issues/_form.html.haml | 4 +- 6 files changed, 58 insertions(+), 33 deletions(-) create mode 100644 app/helpers/compare_helper.rb diff --git a/app/assets/stylesheets/gitlab_bootstrap/forms.scss b/app/assets/stylesheets/gitlab_bootstrap/forms.scss index 020a0bf7fd5..a2612166c78 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 00000000000..55d0d6268ad --- /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 503b39c0663..ca1ea4073e6 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 8f108ed0b08..4745bfbeaaf 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 af9273f9315..4be62d36917 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 957cc5a7e2d..6acad9134d1 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, -- GitLab