Commit f774949d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

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
parent edb3368c
...@@ -6,10 +6,9 @@ form { ...@@ -6,10 +6,9 @@ form {
} }
} }
input { input.input-xpadding,
&.input-xpadding { .add-on.input-xpadding {
padding: 6px 10px; padding: 6px 10px;
}
} }
.control-group { .control-group {
......
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
%div = form_tag project_compare_index_path(@project), method: :post do
- 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 .clearfix
.pull-left .pull-left
- if params[:to] && params[:from] - 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'} = 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" .input-prepend
%span.add-on.input-xpadding from
= text_field_tag :from, params[:from], class: "span3 input-xpadding"
= "..." = "..."
= text_field_tag :to, params[:to], placeholder: "to", class: "input-xlarge input-xpadding" .input-prepend
%span.add-on.input-xpadding to
= text_field_tag :to, params[:to], class: "span3 input-xpadding"
.pull-left .pull-left
&nbsp; &nbsp;
= submit_tag "Compare", class: "btn btn-create commits-compare-btn" = submit_tag "Compare", class: "btn btn-create commits-compare-btn"
- if @refs_are_same - if compare_to_mr_button?
.alert = link_to compare_mr_path, class: 'prepend-left-10' do
%span Refs are the same %strong Make a merge request
:javascript :javascript
......
...@@ -2,5 +2,15 @@ ...@@ -2,5 +2,15 @@
%h3.page-title %h3.page-title
Compare View 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" = render "form"
...@@ -20,3 +20,16 @@ ...@@ -20,3 +20,16 @@
- unless @diffs.empty? - unless @diffs.empty?
%h4 Diff %h4 Diff
= render "projects/commits/diffs", diffs: @diffs, project: @project = 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.
...@@ -67,8 +67,8 @@ ...@@ -67,8 +67,8 @@
event.preventDefault(); event.preventDefault();
} }
}) })
.bind( "click", function( event ) { .bind("click", function(event) {
$( this ).autocomplete("search", ""); $(this).autocomplete("search", "");
}) })
.autocomplete({ .autocomplete({
minLength: 0, minLength: 0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment