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
This commit is contained in:
Robert Speicher 2012-09-25 23:13:19 -04:00
parent 6cb626ef51
commit b462a13387
7 changed files with 45 additions and 66 deletions

View file

@ -3,8 +3,8 @@
%li{class: "#{'active' if current_page?(project_commits_path(@project)) }"} %li{class: "#{'active' if current_page?(project_commits_path(@project)) }"}
= link_to project_commits_path(@project) do = link_to project_commits_path(@project) do
Commits Commits
%li{class: "#{'active' if current_page?(compare_project_commits_path(@project)) }"} %li{class: "#{'active' if current_controller?(:compare)}"}
= link_to compare_project_commits_path(@project) do = link_to project_compare_index_path(@project) do
Compare Compare
%li{class: "#{branches_tab_class}"} %li{class: "#{branches_tab_class}"}
= link_to project_repository_path(@project) do = link_to project_repository_path(@project) do

View file

@ -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');
});

View file

@ -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"

View file

@ -0,0 +1,7 @@
= render "commits/head"
%h3.page_title
Compare View
%hr
= render "form"

View file

@ -1,29 +1,10 @@
= render "head" = render "commits/head"
%h3.page_title %h3.page_title
Compare View Compare View
%hr %hr
%div = render "form"
%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"
- if @commits.present? - if @commits.present?
%div.ui-box %div.ui-box
@ -33,21 +14,3 @@
- unless @diffs.empty? - unless @diffs.empty?
%h4 Diff %h4 Diff
= render "commits/diffs", diffs: @diffs = 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');
});

View file

@ -21,6 +21,6 @@
%li.commits-stat %li.commits-stat
- if event.commits_count > 2 - if event.commits_count > 2
%span ... and #{event.commits_count - 2} more commits. %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]} %strong Compare → #{event.parent_commit.id[0..7]}...#{event.last_commit.id[0..7]}
.clearfix .clearfix

View file

@ -139,7 +139,7 @@ module SharedPaths
end end
Given 'I visit compare refs page' do Given 'I visit compare refs page' do
visit compare_project_commits_path(@project) visit project_compare_index_path(@project)
end end
Given 'I visit project commits page' do Given 'I visit project commits page' do