]> source.dussan.org Git - redmine.git/commitdiff
Adds a link to all projects in the jump drop down (#23310).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 10 Jan 2017 18:33:36 +0000 (18:33 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Tue, 10 Jan 2017 18:33:36 +0000 (18:33 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@16172 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/projects_controller.rb
app/helpers/application_helper.rb
app/views/projects/index.js.erb
lib/redmine/menu_manager.rb
public/stylesheets/application.css
test/functional/projects_controller_test.rb

index 9284b8d099e4ed246b2da0205b49c501734e2f48..99a39af3b5c4f50318210bb4a18e162fa2da813f 100644 (file)
@@ -36,6 +36,11 @@ class ProjectsController < ApplicationController
 
   # Lists visible projects
   def index
+    # try to redirect to the requested menu item
+    if params[:jump] && redirect_to_menu_item(params[:jump])
+      return
+    end
+
     scope = Project.visible.sorted
 
     respond_to do |format|
index 13075126dfe44ee77145a6674c52b66019e63cb1..b319537ee1c7512d168a14710c5bd9af9e1434b1 100644 (file)
@@ -362,9 +362,11 @@ module ApplicationHelper
       text = @project.try(:name) || l(:label_jump_to_a_project)
       trigger = content_tag('span', text, :class => 'drdn-trigger')
       q = text_field_tag('q', '', :id => 'projects-quick-search', :class => 'autocomplete', :data => {:automcomplete_url => projects_path(:format => 'js')})
+      all = link_to(l(:label_project_all), projects_path(:jump => current_menu_item), :class => (@project.nil? && controller.class.main_menu ? 'selected' : nil))
       content = content_tag('div',
             content_tag('div', q, :class => 'quick-search') + 
-            content_tag('div', render_projects_for_jump_box(projects, @project), :class => 'drdn-items selection'),
+            content_tag('div', render_projects_for_jump_box(projects, @project), :class => 'drdn-items projects selection') +
+            content_tag('div', all, :class => 'drdn-items all-projects selection'),
           :class => 'drdn-content'
         )
 
index b4731fb09343f2a1661d5086fdc4341780d2bec5..de6c3f5791291918145cd035b48a1b0bdc2beb25 100644 (file)
@@ -1,2 +1,2 @@
 <% s = @projects.any? ? render_projects_for_jump_box(@projects) : content_tag('span', l(:label_no_data)) %>
-$('#project-jump .drdn-items').html('<%= escape_javascript s %>');
+$('#project-jump .drdn-items.projects').html('<%= escape_javascript s %>');
index 9f90f681a1c916ba76d375245d4e843d3ce536e9..f1a9b1b35761659293e27a3dd110d682d368c5d1 100644 (file)
@@ -68,12 +68,21 @@ module Redmine
                                  menu_items[controller_name.to_sym][:default]
       end
 
+      # Redirects user to the menu item
+      # Returns false if user is not authorized
+      def redirect_to_menu_item(name)
+        redirect_to_project_menu_item(nil, name)
+      end
+
       # Redirects user to the menu item of the given project
       # Returns false if user is not authorized
       def redirect_to_project_menu_item(project, name)
-        item = Redmine::MenuManager.items(:project_menu).detect {|i| i.name.to_s == name.to_s}
+        menu = project.nil? ? :application_menu : :project_menu
+        item = Redmine::MenuManager.items(menu).detect {|i| i.name.to_s == name.to_s}
         if item && item.allowed?(User.current, project)
-          redirect_to({item.param => project}.merge(item.url))
+          url = item.url
+          url = {item.param => project}.merge(url) if project
+          redirect_to url
           return true
         end
         false
index 701be5541e1dd43117579c41b7218c40ab0cc63a..b95aef3be50d96ac137da685f560927b78d9f6a1 100644 (file)
@@ -177,7 +177,7 @@ a.toggle-checkboxes { margin-left: 5px; padding-left: 12px; background: url(../i
 .drdn-content .autocomplete {box-sizing: border-box; width:100% !important; height:28px;}
 .drdn-content .autocomplete:focus {border-color:#5ad;}
 .drdn-items {max-height:400px; overflow:auto;}
-.quick-search + .drdn-items {border-top:1px solid #ccc;}
+div + .drdn-items {border-top:1px solid #ccc;}
 .drdn-items>* {
   display:block;
   border:1px solid #fff;
index da2818174cd25bf08e0cf641e7eb43a15c8adf5e..db81206fb564f09cc17e9f00c1d9ab8cd467fbf0 100644 (file)
@@ -745,6 +745,16 @@ class ProjectsControllerTest < Redmine::ControllerTest
     assert_select_error /Identifier cannot be blank/
   end
 
+  def test_jump_without_project_id_should_redirect_to_active_tab
+    get :index, :jump => 'issues'
+    assert_redirected_to '/issues'
+  end
+
+  def test_jump_should_not_redirect_to_unknown_tab
+    get :index, :jump => 'foobar'
+    assert_response :success
+  end
+
   def test_jump_should_redirect_to_active_tab
     get :show, :id => 1, :jump => 'issues'
     assert_redirected_to '/projects/ecookbook/issues'