Commit 51ce7161 authored by jplang's avatar jplang

Adds a link to all projects in the jump drop down (#23310).

git-svn-id: https://svn.redmine.org/redmine/trunk@16172 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 968ba5aa
......@@ -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|
......
......@@ -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'
)
......
<% 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 %>');
......@@ -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
......
......@@ -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;
......
......@@ -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'
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment