Commit b462a133879ca2a202f18f18d8e78a3ffed05c24

Authored by Robert Speicher
1 parent 6cb626ef

Compare views and cleanup

- Remove compare/_head and just use commits/_head since they're identical
- Add index view; extract the form into a partial
app/views/commits/_head.html.haml
@@ -3,8 +3,8 @@ @@ -3,8 +3,8 @@
3 %li{class: "#{'active' if current_page?(project_commits_path(@project)) }"} 3 %li{class: "#{'active' if current_page?(project_commits_path(@project)) }"}
4 = link_to project_commits_path(@project) do 4 = link_to project_commits_path(@project) do
5 Commits 5 Commits
6 - %li{class: "#{'active' if current_page?(compare_project_commits_path(@project)) }"}  
7 - = link_to compare_project_commits_path(@project) do 6 + %li{class: "#{'active' if current_controller?(:compare)}"}
  7 + = link_to project_compare_index_path(@project) do
8 Compare 8 Compare
9 %li{class: "#{branches_tab_class}"} 9 %li{class: "#{branches_tab_class}"}
10 = link_to project_repository_path(@project) do 10 = link_to project_repository_path(@project) do
app/views/compare/_form.html.haml 0 → 100644
@@ -0,0 +1,32 @@ @@ -0,0 +1,32 @@
  1 +%div
  2 + %p.slead
  3 + Fill input field with commit id like
  4 + %code.label_branch 4eedf23
  5 + or branch/tag name like
  6 + %code.label_branch master
  7 + and press compare button for commits list, code diff.
  8 +
  9 + %br
  10 +
  11 + = form_tag project_compare_index_path(@project), method: :post do
  12 + .clearfix
  13 + = text_field_tag :from, params[:from], placeholder: "master", class: "xlarge"
  14 + = "..."
  15 + = text_field_tag :to, params[:to], placeholder: "aa8b4ef", class: "xlarge"
  16 + - if @refs_are_same
  17 + .alert
  18 + %span Refs are the same
  19 + .actions
  20 + = submit_tag "Compare", class: "btn primary wide commits-compare-btn"
  21 +
  22 +:javascript
  23 + $(function() {
  24 + var availableTags = #{@project.ref_names.to_json};
  25 +
  26 + $("#from, #to").autocomplete({
  27 + source: availableTags,
  28 + minLength: 1
  29 + });
  30 +
  31 + disableButtonIfEmptyField('#to', '.commits-compare-btn');
  32 + });
app/views/compare/_head.html.haml
@@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
1 -%ul.nav.nav-tabs  
2 - %li= render partial: 'shared/ref_switcher', locals: {destination: 'commits'}  
3 - %li{class: "#{'active' if current_page?(project_commits_path(@project)) }"}  
4 - = link_to project_commits_path(@project) do  
5 - Commits  
6 - %li{class: "#{'active' if current_page?(compare_project_commits_path(@project)) }"}  
7 - = link_to compare_project_commits_path(@project) do  
8 - Compare  
9 - %li{class: "#{branches_tab_class}"}  
10 - = link_to project_repository_path(@project) do  
11 - Branches  
12 - %span.badge= @project.repo.branch_count  
13 -  
14 - %li{class: "#{'active' if current_page?(tags_project_repository_path(@project)) }"}  
15 - = link_to tags_project_repository_path(@project) do  
16 - Tags  
17 - %span.badge= @project.repo.tag_count  
18 -  
19 - - if current_page?(project_commits_path(@project)) && current_user.private_token  
20 - %li.right  
21 - %span.rss-icon  
22 - = link_to project_commits_path(@project, @ref, {format: :atom, private_token: current_user.private_token}), title: "Feed" do  
23 - = image_tag "rss_ui.png", title: "feed"  
app/views/compare/index.html.haml 0 → 100644
@@ -0,0 +1,7 @@ @@ -0,0 +1,7 @@
  1 += render "commits/head"
  2 +
  3 +%h3.page_title
  4 + Compare View
  5 +%hr
  6 +
  7 += render "form"
app/views/compare/show.html.haml
1 -= render "head" 1 += render "commits/head"
2 2
3 %h3.page_title 3 %h3.page_title
4 Compare View 4 Compare View
5 %hr 5 %hr
6 6
7 -%div  
8 - %p.slead  
9 - Fill input field with commit id like  
10 - %code.label_branch 4eedf23  
11 - or branch/tag name like  
12 - %code.label_branch master  
13 - and press compare button for commits list, code diff.  
14 -  
15 - %br  
16 -  
17 - = form_tag compare_project_commits_path(@project), method: :get do  
18 - .clearfix  
19 - = text_field_tag :from, params[:from], placeholder: "master", class: "xlarge"  
20 - = "..."  
21 - = text_field_tag :to, params[:to], placeholder: "aa8b4ef", class: "xlarge"  
22 - - if @refs_are_same  
23 - .alert  
24 - %span Refs are the same  
25 - .actions  
26 - = submit_tag "Compare", class: "btn primary wide commits-compare-btn" 7 += render "form"
27 8
28 - if @commits.present? 9 - if @commits.present?
29 %div.ui-box 10 %div.ui-box
@@ -33,21 +14,3 @@ @@ -33,21 +14,3 @@
33 - unless @diffs.empty? 14 - unless @diffs.empty?
34 %h4 Diff 15 %h4 Diff
35 = render "commits/diffs", diffs: @diffs 16 = render "commits/diffs", diffs: @diffs
36 -  
37 -:javascript  
38 - $(function() {  
39 - var availableTags = #{@project.ref_names.to_json};  
40 -  
41 - $("#from").autocomplete({  
42 - source: availableTags,  
43 - minLength: 1  
44 - });  
45 -  
46 - $("#to").autocomplete({  
47 - source: availableTags,  
48 - minLength: 1  
49 - });  
50 -  
51 - disableButtonIfEmptyField('#to', '.commits-compare-btn');  
52 - });  
53 -  
app/views/events/_event_push.html.haml
@@ -21,6 +21,6 @@ @@ -21,6 +21,6 @@
21 %li.commits-stat 21 %li.commits-stat
22 - if event.commits_count > 2 22 - if event.commits_count > 2
23 %span ... and #{event.commits_count - 2} more commits. 23 %span ... and #{event.commits_count - 2} more commits.
24 - = link_to compare_project_commits_path(event.project, from: event.parent_commit.id, to: event.last_commit.id) do 24 + = link_to project_compare_path(event.project, from: event.parent_commit.id, to: event.last_commit.id) do
25 %strong Compare → #{event.parent_commit.id[0..7]}...#{event.last_commit.id[0..7]} 25 %strong Compare → #{event.parent_commit.id[0..7]}...#{event.last_commit.id[0..7]}
26 .clearfix 26 .clearfix
features/steps/shared/paths.rb
@@ -139,7 +139,7 @@ module SharedPaths @@ -139,7 +139,7 @@ module SharedPaths
139 end 139 end
140 140
141 Given 'I visit compare refs page' do 141 Given 'I visit compare refs page' do
142 - visit compare_project_commits_path(@project) 142 + visit project_compare_index_path(@project)
143 end 143 end
144 144
145 Given 'I visit project commits page' do 145 Given 'I visit project commits page' do