From b462a133879ca2a202f18f18d8e78a3ffed05c24 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 25 Sep 2012 23:13:19 -0400 Subject: [PATCH] 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 | 4 +-- app/views/compare/_form.html.haml | 32 ++++++++++++++++++++ app/views/compare/_head.html.haml | 23 --------------- app/views/compare/index.html.haml | 7 +++++ app/views/compare/show.html.haml | 41 ++------------------------ app/views/events/_event_push.html.haml | 2 +- features/steps/shared/paths.rb | 2 +- 7 files changed, 45 insertions(+), 66 deletions(-) create mode 100644 app/views/compare/_form.html.haml delete mode 100644 app/views/compare/_head.html.haml create mode 100644 app/views/compare/index.html.haml diff --git a/app/views/commits/_head.html.haml b/app/views/commits/_head.html.haml index cdee391f493..86a65f879c9 100644 --- a/app/views/commits/_head.html.haml +++ b/app/views/commits/_head.html.haml @@ -3,8 +3,8 @@ %li{class: "#{'active' if current_page?(project_commits_path(@project)) }"} = link_to project_commits_path(@project) do Commits - %li{class: "#{'active' if current_page?(compare_project_commits_path(@project)) }"} - = link_to compare_project_commits_path(@project) do + %li{class: "#{'active' if current_controller?(:compare)}"} + = link_to project_compare_index_path(@project) do Compare %li{class: "#{branches_tab_class}"} = link_to project_repository_path(@project) do diff --git a/app/views/compare/_form.html.haml b/app/views/compare/_form.html.haml new file mode 100644 index 00000000000..07f1c818e4d --- /dev/null +++ b/app/views/compare/_form.html.haml @@ -0,0 +1,32 @@ +%div + %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 commits list, code diff. + + %br + + = form_tag project_compare_index_path(@project), method: :post do + .clearfix + = text_field_tag :from, params[:from], placeholder: "master", class: "xlarge" + = "..." + = text_field_tag :to, params[:to], placeholder: "aa8b4ef", class: "xlarge" + - if @refs_are_same + .alert + %span Refs are the same + .actions + = submit_tag "Compare", class: "btn primary wide commits-compare-btn" + +:javascript + $(function() { + var availableTags = #{@project.ref_names.to_json}; + + $("#from, #to").autocomplete({ + source: availableTags, + minLength: 1 + }); + + disableButtonIfEmptyField('#to', '.commits-compare-btn'); + }); diff --git a/app/views/compare/_head.html.haml b/app/views/compare/_head.html.haml deleted file mode 100644 index cdee391f493..00000000000 --- a/app/views/compare/_head.html.haml +++ /dev/null @@ -1,23 +0,0 @@ -%ul.nav.nav-tabs - %li= render partial: 'shared/ref_switcher', locals: {destination: 'commits'} - %li{class: "#{'active' if current_page?(project_commits_path(@project)) }"} - = link_to project_commits_path(@project) do - Commits - %li{class: "#{'active' if current_page?(compare_project_commits_path(@project)) }"} - = link_to compare_project_commits_path(@project) do - Compare - %li{class: "#{branches_tab_class}"} - = link_to project_repository_path(@project) do - Branches - %span.badge= @project.repo.branch_count - - %li{class: "#{'active' if current_page?(tags_project_repository_path(@project)) }"} - = link_to tags_project_repository_path(@project) do - Tags - %span.badge= @project.repo.tag_count - - - if current_page?(project_commits_path(@project)) && current_user.private_token - %li.right - %span.rss-icon - = link_to project_commits_path(@project, @ref, {format: :atom, private_token: current_user.private_token}), title: "Feed" do - = image_tag "rss_ui.png", title: "feed" diff --git a/app/views/compare/index.html.haml b/app/views/compare/index.html.haml new file mode 100644 index 00000000000..6c9a5fd8305 --- /dev/null +++ b/app/views/compare/index.html.haml @@ -0,0 +1,7 @@ += render "commits/head" + +%h3.page_title + Compare View +%hr + += render "form" diff --git a/app/views/compare/show.html.haml b/app/views/compare/show.html.haml index db15ba53823..528c8b44af4 100644 --- a/app/views/compare/show.html.haml +++ b/app/views/compare/show.html.haml @@ -1,29 +1,10 @@ -= render "head" += render "commits/head" %h3.page_title Compare View %hr -%div - %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 commits list, code diff. - - %br - - = form_tag compare_project_commits_path(@project), method: :get do - .clearfix - = text_field_tag :from, params[:from], placeholder: "master", class: "xlarge" - = "..." - = text_field_tag :to, params[:to], placeholder: "aa8b4ef", class: "xlarge" - - if @refs_are_same - .alert - %span Refs are the same - .actions - = submit_tag "Compare", class: "btn primary wide commits-compare-btn" += render "form" - if @commits.present? %div.ui-box @@ -33,21 +14,3 @@ - unless @diffs.empty? %h4 Diff = render "commits/diffs", diffs: @diffs - -:javascript - $(function() { - var availableTags = #{@project.ref_names.to_json}; - - $("#from").autocomplete({ - source: availableTags, - minLength: 1 - }); - - $("#to").autocomplete({ - source: availableTags, - minLength: 1 - }); - - disableButtonIfEmptyField('#to', '.commits-compare-btn'); - }); - diff --git a/app/views/events/_event_push.html.haml b/app/views/events/_event_push.html.haml index c0be9cf5230..19ac9263563 100644 --- a/app/views/events/_event_push.html.haml +++ b/app/views/events/_event_push.html.haml @@ -21,6 +21,6 @@ %li.commits-stat - if event.commits_count > 2 %span ... and #{event.commits_count - 2} more commits. - = link_to compare_project_commits_path(event.project, from: event.parent_commit.id, to: event.last_commit.id) do + = link_to project_compare_path(event.project, from: event.parent_commit.id, to: event.last_commit.id) do %strong Compare → #{event.parent_commit.id[0..7]}...#{event.last_commit.id[0..7]} .clearfix diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index a1a8efd677a..8efedfa1083 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -139,7 +139,7 @@ module SharedPaths end Given 'I visit compare refs page' do - visit compare_project_commits_path(@project) + visit project_compare_index_path(@project) end Given 'I visit project commits page' do