summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgitlabhq <m@gitlabhq.com>2011-11-16 12:19:18 -0500
committergitlabhq <m@gitlabhq.com>2011-11-16 12:19:18 -0500
commitbb35ef2f6063c04be8cb0e655049fec7a60f260a (patch)
tree73dffd1138e2ee7643b69183b1a619676d717dcd
parentf0b86c5f1e3f59ceafc684478c7b67bb1e6886f4 (diff)
downloadgitlab-ce-bb35ef2f6063c04be8cb0e655049fec7a60f260a.tar.gz
fix branch/tag select
-rw-r--r--app/assets/stylesheets/projects.css.scss8
-rw-r--r--app/controllers/refs_controller.rb10
-rw-r--r--app/helpers/application_helper.rb2
-rw-r--r--app/views/commits/index.html.haml2
-rw-r--r--app/views/projects/_refs.html.haml3
-rw-r--r--app/views/refs/_tree.html.haml2
-rw-r--r--config/routes.rb8
7 files changed, 29 insertions, 6 deletions
diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss
index fb668c631ef..85831b96bdb 100644
--- a/app/assets/stylesheets/projects.css.scss
+++ b/app/assets/stylesheets/projects.css.scss
@@ -377,3 +377,11 @@ body.dashboard.project-page .news-feed .project-updates a.project-update span.up
body.dashboard.project-page .news-feed .project-updates a.project-update span.update-author{color: #999; font-weight: normal; font-style: italic;}
body.dashboard.project-page .news-feed .project-updates a.project-update span.update-author strong{font-weight: bold; font-style: normal;}
/* eo Dashboard Page */
+
+/* Breadcrumbs fix */
+#tree-breadcrumbs {
+ width: 100%;
+ overflow: hidden;
+ height: 45px;
+}
+
diff --git a/app/controllers/refs_controller.rb b/app/controllers/refs_controller.rb
index cbe87514a2d..0da429b8bde 100644
--- a/app/controllers/refs_controller.rb
+++ b/app/controllers/refs_controller.rb
@@ -8,6 +8,16 @@ class RefsController < ApplicationController
before_filter :authorize_read_project!
before_filter :require_non_empty_project
+ def switch
+ new_path = if params[:destination] == "tree"
+ tree_project_ref_path(@project, params[:ref])
+ else
+ project_commits_path(@project, :ref => params[:ref])
+ end
+
+ redirect_to new_path
+ end
+
#
# Repository preview
#
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 530709ea180..4706708304c 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -46,7 +46,7 @@ module ApplicationHelper
"Never"
end
- def grouped_options_refs
+ def grouped_options_refs(destination = :tree)
options = [
["Branch", @repo.heads.map(&:name) ],
[ "Tag", @project.tags ]
diff --git a/app/views/commits/index.html.haml b/app/views/commits/index.html.haml
index e5ef3df5f83..14317b4cb28 100644
--- a/app/views/commits/index.html.haml
+++ b/app/views/commits/index.html.haml
@@ -12,7 +12,7 @@
\/
%a{:href => "#"}= params[:path].split("/").join(" / ")
-.right= render :partial => "projects/refs", :locals => { :destination => project_commits_path(@project) }
+.right= render :partial => "projects/refs", :locals => { :destination => :commits }
%div{:id => dom_id(@project)}
#commits_list= render "commits"
diff --git a/app/views/projects/_refs.html.haml b/app/views/projects/_refs.html.haml
index 99a91fea9c1..af15fbdfb3d 100644
--- a/app/views/projects/_refs.html.haml
+++ b/app/views/projects/_refs.html.haml
@@ -1,5 +1,6 @@
-= form_tag destination, :method => :get, :class => "project-refs-form" do
+= form_tag switch_project_refs_path(@project), :method => :get, :class => "project-refs-form" do
= select_tag "ref", grouped_options_refs, :onchange => "this.form.submit();", :class => "project-refs-select"
+ = hidden_field_tag :destination, destination
:javascript
$(function(){
diff --git a/app/views/refs/_tree.html.haml b/app/views/refs/_tree.html.haml
index 52e58209c9f..5dd55ee4b66 100644
--- a/app/views/refs/_tree.html.haml
+++ b/app/views/refs/_tree.html.haml
@@ -16,7 +16,7 @@
\/
= link_to truncate(part, :length => 40), tree_file_project_ref_path(@project, @ref, :path => part_path), :remote => :true
&nbsp;
- .right= render :partial => "projects/refs", :locals => { :destination => tree_project_ref_path(@project, @ref) }
+ .right= render :partial => "projects/refs", :locals => { :destination => :tree }
.clear
#tree-content-holder
diff --git a/config/routes.rb b/config/routes.rb
index b474f26edc2..f82d4c14ebf 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -36,15 +36,19 @@ Gitlab::Application.routes.draw do
end
resources :refs, :only => [], :path => "/" do
+ collection do
+ get "switch"
+ end
+
member do
- get "tree"
+ get "tree", :constraints => { :id => /[a-zA-Z.0-9_\-]+/ }
get "blob"
# tree viewer
get "tree/:path" => "refs#tree",
:as => :tree_file,
:constraints => {
- :id => /[a-zA-Z0-9_\-]+/,
+ :id => /[a-zA-Z.0-9_\-]+/,
:path => /.*/
}
end