diff --git a/app/assets/stylesheets/projects.css.scss b/app/assets/stylesheets/projects.css.scss index fb668c63..85831b96 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 cbe87514..0da429b8 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 530709ea..47067083 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 e5ef3df5..14317b4c 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 99a91fea..af15fbdf 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 52e58209..5dd55ee4 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   - .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 b474f26e..f82d4c14 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