OSDN Git Service

Compare views and cleanup
authorRobert Speicher <rspeicher@gmail.com>
Wed, 26 Sep 2012 03:13:19 +0000 (23:13 -0400)
committerRobert Speicher <rspeicher@gmail.com>
Wed, 26 Sep 2012 20:32:24 +0000 (16:32 -0400)
- 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
app/views/compare/_form.html.haml [new file with mode: 0644]
app/views/compare/_head.html.haml [deleted file]
app/views/compare/index.html.haml [new file with mode: 0644]
app/views/compare/show.html.haml
app/views/events/_event_push.html.haml
features/steps/shared/paths.rb

index cdee391..86a65f8 100644 (file)
@@ -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 (file)
index 0000000..07f1c81
--- /dev/null
@@ -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 (file)
index cdee391..0000000
+++ /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 (file)
index 0000000..6c9a5fd
--- /dev/null
@@ -0,0 +1,7 @@
+= render "commits/head"
+
+%h3.page_title
+  Compare View
+%hr
+
+= render "form"
index db15ba5..528c8b4 100644 (file)
@@ -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
   - 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');
-  });
-
index c0be9cf..19ac926 100644 (file)
@@ -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 &rarr; #{event.parent_commit.id[0..7]}...#{event.last_commit.id[0..7]}
   .clearfix
index a1a8efd..8efedfa 100644 (file)
@@ -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