Commit bb35ef2f6063c04be8cb0e655049fec7a60f260a

Authored by gitlabhq
1 parent f0b86c5f

fix branch/tag select

app/assets/stylesheets/projects.css.scss
@@ -377,3 +377,11 @@ body.dashboard.project-page .news-feed .project-updates a.project-update span.up @@ -377,3 +377,11 @@ body.dashboard.project-page .news-feed .project-updates a.project-update span.up
377 body.dashboard.project-page .news-feed .project-updates a.project-update span.update-author{color: #999; font-weight: normal; font-style: italic;} 377 body.dashboard.project-page .news-feed .project-updates a.project-update span.update-author{color: #999; font-weight: normal; font-style: italic;}
378 body.dashboard.project-page .news-feed .project-updates a.project-update span.update-author strong{font-weight: bold; font-style: normal;} 378 body.dashboard.project-page .news-feed .project-updates a.project-update span.update-author strong{font-weight: bold; font-style: normal;}
379 /* eo Dashboard Page */ 379 /* eo Dashboard Page */
  380 +
  381 +/* Breadcrumbs fix */
  382 +#tree-breadcrumbs {
  383 + width: 100%;
  384 + overflow: hidden;
  385 + height: 45px;
  386 +}
  387 +
app/controllers/refs_controller.rb
@@ -8,6 +8,16 @@ class RefsController < ApplicationController @@ -8,6 +8,16 @@ class RefsController < ApplicationController
8 before_filter :authorize_read_project! 8 before_filter :authorize_read_project!
9 before_filter :require_non_empty_project 9 before_filter :require_non_empty_project
10 10
  11 + def switch
  12 + new_path = if params[:destination] == "tree"
  13 + tree_project_ref_path(@project, params[:ref])
  14 + else
  15 + project_commits_path(@project, :ref => params[:ref])
  16 + end
  17 +
  18 + redirect_to new_path
  19 + end
  20 +
11 # 21 #
12 # Repository preview 22 # Repository preview
13 # 23 #
app/helpers/application_helper.rb
@@ -46,7 +46,7 @@ module ApplicationHelper @@ -46,7 +46,7 @@ module ApplicationHelper
46 "Never" 46 "Never"
47 end 47 end
48 48
49 - def grouped_options_refs 49 + def grouped_options_refs(destination = :tree)
50 options = [ 50 options = [
51 ["Branch", @repo.heads.map(&:name) ], 51 ["Branch", @repo.heads.map(&:name) ],
52 [ "Tag", @project.tags ] 52 [ "Tag", @project.tags ]
app/views/commits/index.html.haml
@@ -12,7 +12,7 @@ @@ -12,7 +12,7 @@
12 \/ 12 \/
13 %a{:href => "#"}= params[:path].split("/").join(" / ") 13 %a{:href => "#"}= params[:path].split("/").join(" / ")
14 14
15 -.right= render :partial => "projects/refs", :locals => { :destination => project_commits_path(@project) } 15 +.right= render :partial => "projects/refs", :locals => { :destination => :commits }
16 16
17 %div{:id => dom_id(@project)} 17 %div{:id => dom_id(@project)}
18 #commits_list= render "commits" 18 #commits_list= render "commits"
app/views/projects/_refs.html.haml
1 -= form_tag destination, :method => :get, :class => "project-refs-form" do 1 += form_tag switch_project_refs_path(@project), :method => :get, :class => "project-refs-form" do
2 = select_tag "ref", grouped_options_refs, :onchange => "this.form.submit();", :class => "project-refs-select" 2 = select_tag "ref", grouped_options_refs, :onchange => "this.form.submit();", :class => "project-refs-select"
  3 + = hidden_field_tag :destination, destination
3 4
4 :javascript 5 :javascript
5 $(function(){ 6 $(function(){
app/views/refs/_tree.html.haml
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 \/ 16 \/
17 = link_to truncate(part, :length => 40), tree_file_project_ref_path(@project, @ref, :path => part_path), :remote => :true 17 = link_to truncate(part, :length => 40), tree_file_project_ref_path(@project, @ref, :path => part_path), :remote => :true
18   18  
19 - .right= render :partial => "projects/refs", :locals => { :destination => tree_project_ref_path(@project, @ref) } 19 + .right= render :partial => "projects/refs", :locals => { :destination => :tree }
20 .clear 20 .clear
21 21
22 #tree-content-holder 22 #tree-content-holder
config/routes.rb
@@ -36,15 +36,19 @@ Gitlab::Application.routes.draw do @@ -36,15 +36,19 @@ Gitlab::Application.routes.draw do
36 end 36 end
37 37
38 resources :refs, :only => [], :path => "/" do 38 resources :refs, :only => [], :path => "/" do
  39 + collection do
  40 + get "switch"
  41 + end
  42 +
39 member do 43 member do
40 - get "tree" 44 + get "tree", :constraints => { :id => /[a-zA-Z.0-9_\-]+/ }
41 get "blob" 45 get "blob"
42 46
43 # tree viewer 47 # tree viewer
44 get "tree/:path" => "refs#tree", 48 get "tree/:path" => "refs#tree",
45 :as => :tree_file, 49 :as => :tree_file,
46 :constraints => { 50 :constraints => {
47 - :id => /[a-zA-Z0-9_\-]+/, 51 + :id => /[a-zA-Z.0-9_\-]+/,
48 :path => /.*/ 52 :path => /.*/
49 } 53 }
50 end 54 end