mirror of
https://github.com/meineerde/redmine.git
synced 2026-03-28 11:41:08 +00:00
Use the main menu for project related actions that support cross-project display.
git-svn-id: http://svn.redmine.org/redmine/trunk@15983 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
33d78d605d
commit
124a459d55
@ -19,6 +19,8 @@ class AccountController < ApplicationController
|
|||||||
helper :custom_fields
|
helper :custom_fields
|
||||||
include CustomFieldsHelper
|
include CustomFieldsHelper
|
||||||
|
|
||||||
|
self.main_menu = false
|
||||||
|
|
||||||
# prevents login action to be filtered by check_if_login_required application scope filter
|
# prevents login action to be filtered by check_if_login_required application scope filter
|
||||||
skip_before_action :check_if_login_required, :check_password_change
|
skip_before_action :check_if_login_required, :check_password_change
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
class AdminController < ApplicationController
|
class AdminController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
self.main_menu = false
|
||||||
menu_item :projects, :only => :projects
|
menu_item :projects, :only => :projects
|
||||||
menu_item :plugins, :only => :plugins
|
menu_item :plugins, :only => :plugins
|
||||||
menu_item :info, :only => :info
|
menu_item :info, :only => :info
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
class AuthSourcesController < ApplicationController
|
class AuthSourcesController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
self.main_menu = false
|
||||||
menu_item :ldap_authentication
|
menu_item :ldap_authentication
|
||||||
|
|
||||||
before_action :require_admin
|
before_action :require_admin
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
class CustomFieldEnumerationsController < ApplicationController
|
class CustomFieldEnumerationsController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
self.main_menu = false
|
||||||
|
|
||||||
before_action :require_admin
|
before_action :require_admin
|
||||||
before_action :find_custom_field
|
before_action :find_custom_field
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
class CustomFieldsController < ApplicationController
|
class CustomFieldsController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
self.main_menu = false
|
||||||
|
|
||||||
before_action :require_admin
|
before_action :require_admin
|
||||||
before_action :build_new_custom_field, :only => [:new, :create]
|
before_action :build_new_custom_field, :only => [:new, :create]
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class EmailAddressesController < ApplicationController
|
class EmailAddressesController < ApplicationController
|
||||||
|
self.main_menu = false
|
||||||
before_action :find_user, :require_admin_or_current_user
|
before_action :find_user, :require_admin_or_current_user
|
||||||
before_action :find_email_address, :only => [:update, :destroy]
|
before_action :find_email_address, :only => [:update, :destroy]
|
||||||
require_sudo_mode :create, :update, :destroy
|
require_sudo_mode :create, :update, :destroy
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
class EnumerationsController < ApplicationController
|
class EnumerationsController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
self.main_menu = false
|
||||||
|
|
||||||
before_action :require_admin, :except => :index
|
before_action :require_admin, :except => :index
|
||||||
before_action :require_admin_or_api_request, :only => :index
|
before_action :require_admin_or_api_request, :only => :index
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
class GroupsController < ApplicationController
|
class GroupsController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
self.main_menu = false
|
||||||
|
|
||||||
before_action :require_admin
|
before_action :require_admin
|
||||||
before_action :find_group, :except => [:index, :new, :create]
|
before_action :find_group, :except => [:index, :new, :create]
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
class IssueStatusesController < ApplicationController
|
class IssueStatusesController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
self.main_menu = false
|
||||||
|
|
||||||
before_action :require_admin, :except => :index
|
before_action :require_admin, :except => :index
|
||||||
before_action :require_admin_or_api_request, :only => :index
|
before_action :require_admin_or_api_request, :only => :index
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class MyController < ApplicationController
|
class MyController < ApplicationController
|
||||||
|
self.main_menu = false
|
||||||
before_action :require_login
|
before_action :require_login
|
||||||
# let user change user's password when user has to
|
# let user change user's password when user has to
|
||||||
skip_before_action :check_password_change, :only => :password
|
skip_before_action :check_password_change, :only => :password
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
class PrincipalMembershipsController < ApplicationController
|
class PrincipalMembershipsController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
self.main_menu = false
|
||||||
|
|
||||||
before_action :require_admin
|
before_action :require_admin
|
||||||
before_action :find_principal, :only => [:new, :create]
|
before_action :find_principal, :only => [:new, :create]
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
class ProjectsController < ApplicationController
|
class ProjectsController < ApplicationController
|
||||||
menu_item :overview
|
menu_item :overview
|
||||||
menu_item :settings, :only => :settings
|
menu_item :settings, :only => :settings
|
||||||
|
menu_item :projects, :only => [:index, :new, :create]
|
||||||
|
|
||||||
before_action :find_project, :except => [ :index, :list, :new, :create, :copy ]
|
before_action :find_project, :except => [ :index, :list, :new, :create, :copy ]
|
||||||
before_action :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy]
|
before_action :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy]
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
class RolesController < ApplicationController
|
class RolesController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
self.main_menu = false
|
||||||
|
|
||||||
before_action :require_admin, :except => [:index, :show]
|
before_action :require_admin, :except => [:index, :show]
|
||||||
before_action :require_admin_or_api_request, :only => [:index, :show]
|
before_action :require_admin_or_api_request, :only => [:index, :show]
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
class SettingsController < ApplicationController
|
class SettingsController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
self.main_menu = false
|
||||||
menu_item :plugins, :only => :plugin
|
menu_item :plugins, :only => :plugin
|
||||||
|
|
||||||
helper :queries
|
helper :queries
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
class TrackersController < ApplicationController
|
class TrackersController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
self.main_menu = false
|
||||||
|
|
||||||
before_action :require_admin, :except => :index
|
before_action :require_admin, :except => :index
|
||||||
before_action :require_admin_or_api_request, :only => :index
|
before_action :require_admin_or_api_request, :only => :index
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
class UsersController < ApplicationController
|
class UsersController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
self.main_menu = false
|
||||||
|
|
||||||
before_action :require_admin, :except => :show
|
before_action :require_admin, :except => :show
|
||||||
before_action :find_user, :only => [:show, :edit, :update, :destroy]
|
before_action :find_user, :only => [:show, :edit, :update, :destroy]
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
|
||||||
class WelcomeController < ApplicationController
|
class WelcomeController < ApplicationController
|
||||||
|
self.main_menu = false
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@news = News.latest User.current
|
@news = News.latest User.current
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
class WorkflowsController < ApplicationController
|
class WorkflowsController < ApplicationController
|
||||||
layout 'admin'
|
layout 'admin'
|
||||||
|
self.main_menu = false
|
||||||
|
|
||||||
before_action :require_admin
|
before_action :require_admin
|
||||||
|
|
||||||
|
|||||||
@ -48,18 +48,11 @@ module ProjectsHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def render_project_action_links
|
def render_project_action_links
|
||||||
links = []
|
links = "".html_safe
|
||||||
if User.current.allowed_to?(:add_project, nil, :global => true)
|
if User.current.allowed_to?(:add_project, nil, :global => true)
|
||||||
links << link_to(l(:label_project_new), new_project_path, :class => 'icon icon-add')
|
links << link_to(l(:label_project_new), new_project_path, :class => 'icon icon-add')
|
||||||
end
|
end
|
||||||
if User.current.allowed_to?(:view_issues, nil, :global => true)
|
links
|
||||||
links << link_to(l(:label_issue_view_all), issues_path)
|
|
||||||
end
|
|
||||||
if User.current.allowed_to?(:view_time_entries, nil, :global => true)
|
|
||||||
links << link_to(l(:label_overall_spent_time), time_entries_path)
|
|
||||||
end
|
|
||||||
links << link_to(l(:label_overall_activity), activity_path)
|
|
||||||
links.join(" | ").html_safe
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Renders the projects index
|
# Renders the projects index
|
||||||
|
|||||||
@ -203,7 +203,21 @@ Redmine::MenuManager.map :account_menu do |menu|
|
|||||||
end
|
end
|
||||||
|
|
||||||
Redmine::MenuManager.map :application_menu do |menu|
|
Redmine::MenuManager.map :application_menu do |menu|
|
||||||
# Empty
|
menu.push :projects, {:controller => 'projects', :action => 'index'},
|
||||||
|
:permission => nil,
|
||||||
|
:caption => :label_project_plural
|
||||||
|
menu.push :activity, {:controller => 'activities', :action => 'index'}
|
||||||
|
menu.push :issues, {:controller => 'issues', :action => 'index'},
|
||||||
|
:if => Proc.new {User.current.allowed_to?(:view_issues, nil, :global => true)},
|
||||||
|
:caption => :label_issue_plural
|
||||||
|
menu.push :time_entries, {:controller => 'timelog', :action => 'index'},
|
||||||
|
:if => Proc.new {User.current.allowed_to?(:view_time_entries, nil, :global => true)},
|
||||||
|
:caption => :label_spent_time
|
||||||
|
menu.push :gantt, { :controller => 'gantts', :action => 'show' }, :caption => :label_gantt
|
||||||
|
menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :caption => :label_calendar
|
||||||
|
|
||||||
|
menu.push :news, {:controller => 'news', :action => 'index'},
|
||||||
|
:caption => :label_news_plural
|
||||||
end
|
end
|
||||||
|
|
||||||
Redmine::MenuManager.map :admin_menu do |menu|
|
Redmine::MenuManager.map :admin_menu do |menu|
|
||||||
|
|||||||
@ -22,6 +22,9 @@ module Redmine
|
|||||||
|
|
||||||
module MenuController
|
module MenuController
|
||||||
def self.included(base)
|
def self.included(base)
|
||||||
|
base.class_attribute :main_menu
|
||||||
|
base.main_menu = true
|
||||||
|
|
||||||
base.extend(ClassMethods)
|
base.extend(ClassMethods)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -51,6 +54,14 @@ module Redmine
|
|||||||
self.class.menu_items
|
self.class.menu_items
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def current_menu(project)
|
||||||
|
if project && !project.new_record?
|
||||||
|
:project_menu
|
||||||
|
elsif self.class.main_menu
|
||||||
|
:application_menu
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Returns the menu item name according to the current action
|
# Returns the menu item name according to the current action
|
||||||
def current_menu_item
|
def current_menu_item
|
||||||
@current_menu_item ||= menu_items[controller_name.to_sym][:actions][action_name.to_sym] ||
|
@current_menu_item ||= menu_items[controller_name.to_sym][:actions][action_name.to_sym] ||
|
||||||
@ -77,12 +88,14 @@ module Redmine
|
|||||||
|
|
||||||
# Renders the application main menu
|
# Renders the application main menu
|
||||||
def render_main_menu(project)
|
def render_main_menu(project)
|
||||||
render_menu((project && !project.new_record?) ? :project_menu : :application_menu, project)
|
if menu_name = controller.current_menu(project)
|
||||||
|
render_menu(menu_name, project)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def display_main_menu?(project)
|
def display_main_menu?(project)
|
||||||
menu_name = project && !project.new_record? ? :project_menu : :application_menu
|
menu_name = controller.current_menu(project)
|
||||||
Redmine::MenuManager.items(menu_name).children.present?
|
menu_name.present? && Redmine::MenuManager.items(menu_name).children.present?
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_menu(menu, project=nil)
|
def render_menu(menu, project=nil)
|
||||||
|
|||||||
@ -2594,7 +2594,7 @@ class IssuesControllerTest < Redmine::ControllerTest
|
|||||||
:subject => ''}
|
:subject => ''}
|
||||||
assert_response :success
|
assert_response :success
|
||||||
# no project menu
|
# no project menu
|
||||||
assert_select '#main-menu', 0
|
assert_select '#main-menu a.overview', 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_post_create_should_send_a_notification
|
def test_post_create_should_send_a_notification
|
||||||
|
|||||||
@ -63,4 +63,17 @@ class MenuManagerTest < Redmine::IntegrationTest
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_main_menu_should_select_projects_tab_on_project_list
|
||||||
|
get '/projects'
|
||||||
|
assert_select '#main-menu' do
|
||||||
|
assert_select 'a.projects'
|
||||||
|
assert_select 'a.projects.selected'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_main_menu_should_not_show_up_on_account
|
||||||
|
get '/login'
|
||||||
|
assert_select '#main-menu', 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user