@@ -19,6 +19,8 class AccountController < ApplicationController | |||
|
19 | 19 | helper :custom_fields |
|
20 | 20 | include CustomFieldsHelper |
|
21 | 21 | |
|
22 | self.main_menu = false | |
|
23 | ||
|
22 | 24 | # prevents login action to be filtered by check_if_login_required application scope filter |
|
23 | 25 | skip_before_action :check_if_login_required, :check_password_change |
|
24 | 26 |
@@ -17,6 +17,7 | |||
|
17 | 17 | |
|
18 | 18 | class AdminController < ApplicationController |
|
19 | 19 | layout 'admin' |
|
20 | self.main_menu = false | |
|
20 | 21 | menu_item :projects, :only => :projects |
|
21 | 22 | menu_item :plugins, :only => :plugins |
|
22 | 23 | menu_item :info, :only => :info |
@@ -17,6 +17,7 | |||
|
17 | 17 | |
|
18 | 18 | class AuthSourcesController < ApplicationController |
|
19 | 19 | layout 'admin' |
|
20 | self.main_menu = false | |
|
20 | 21 | menu_item :ldap_authentication |
|
21 | 22 | |
|
22 | 23 | before_action :require_admin |
@@ -17,6 +17,7 | |||
|
17 | 17 | |
|
18 | 18 | class CustomFieldEnumerationsController < ApplicationController |
|
19 | 19 | layout 'admin' |
|
20 | self.main_menu = false | |
|
20 | 21 | |
|
21 | 22 | before_action :require_admin |
|
22 | 23 | before_action :find_custom_field |
@@ -17,6 +17,7 | |||
|
17 | 17 | |
|
18 | 18 | class CustomFieldsController < ApplicationController |
|
19 | 19 | layout 'admin' |
|
20 | self.main_menu = false | |
|
20 | 21 | |
|
21 | 22 | before_action :require_admin |
|
22 | 23 | before_action :build_new_custom_field, :only => [:new, :create] |
@@ -16,6 +16,7 | |||
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class EmailAddressesController < ApplicationController |
|
19 | self.main_menu = false | |
|
19 | 20 | before_action :find_user, :require_admin_or_current_user |
|
20 | 21 | before_action :find_email_address, :only => [:update, :destroy] |
|
21 | 22 | require_sudo_mode :create, :update, :destroy |
@@ -17,6 +17,7 | |||
|
17 | 17 | |
|
18 | 18 | class EnumerationsController < ApplicationController |
|
19 | 19 | layout 'admin' |
|
20 | self.main_menu = false | |
|
20 | 21 | |
|
21 | 22 | before_action :require_admin, :except => :index |
|
22 | 23 | before_action :require_admin_or_api_request, :only => :index |
@@ -17,6 +17,7 | |||
|
17 | 17 | |
|
18 | 18 | class GroupsController < ApplicationController |
|
19 | 19 | layout 'admin' |
|
20 | self.main_menu = false | |
|
20 | 21 | |
|
21 | 22 | before_action :require_admin |
|
22 | 23 | before_action :find_group, :except => [:index, :new, :create] |
@@ -17,6 +17,7 | |||
|
17 | 17 | |
|
18 | 18 | class IssueStatusesController < ApplicationController |
|
19 | 19 | layout 'admin' |
|
20 | self.main_menu = false | |
|
20 | 21 | |
|
21 | 22 | before_action :require_admin, :except => :index |
|
22 | 23 | before_action :require_admin_or_api_request, :only => :index |
@@ -16,6 +16,7 | |||
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class MyController < ApplicationController |
|
19 | self.main_menu = false | |
|
19 | 20 | before_action :require_login |
|
20 | 21 | # let user change user's password when user has to |
|
21 | 22 | skip_before_action :check_password_change, :only => :password |
@@ -17,6 +17,7 | |||
|
17 | 17 | |
|
18 | 18 | class PrincipalMembershipsController < ApplicationController |
|
19 | 19 | layout 'admin' |
|
20 | self.main_menu = false | |
|
20 | 21 | |
|
21 | 22 | before_action :require_admin |
|
22 | 23 | before_action :find_principal, :only => [:new, :create] |
@@ -18,6 +18,7 | |||
|
18 | 18 | class ProjectsController < ApplicationController |
|
19 | 19 | menu_item :overview |
|
20 | 20 | menu_item :settings, :only => :settings |
|
21 | menu_item :projects, :only => [:index, :new, :create] | |
|
21 | 22 | |
|
22 | 23 | before_action :find_project, :except => [ :index, :list, :new, :create, :copy ] |
|
23 | 24 | before_action :authorize, :except => [ :index, :list, :new, :create, :copy, :archive, :unarchive, :destroy] |
@@ -17,6 +17,7 | |||
|
17 | 17 | |
|
18 | 18 | class RolesController < ApplicationController |
|
19 | 19 | layout 'admin' |
|
20 | self.main_menu = false | |
|
20 | 21 | |
|
21 | 22 | before_action :require_admin, :except => [:index, :show] |
|
22 | 23 | before_action :require_admin_or_api_request, :only => [:index, :show] |
@@ -17,6 +17,7 | |||
|
17 | 17 | |
|
18 | 18 | class SettingsController < ApplicationController |
|
19 | 19 | layout 'admin' |
|
20 | self.main_menu = false | |
|
20 | 21 | menu_item :plugins, :only => :plugin |
|
21 | 22 | |
|
22 | 23 | helper :queries |
@@ -17,6 +17,7 | |||
|
17 | 17 | |
|
18 | 18 | class TrackersController < ApplicationController |
|
19 | 19 | layout 'admin' |
|
20 | self.main_menu = false | |
|
20 | 21 | |
|
21 | 22 | before_action :require_admin, :except => :index |
|
22 | 23 | before_action :require_admin_or_api_request, :only => :index |
@@ -17,6 +17,7 | |||
|
17 | 17 | |
|
18 | 18 | class UsersController < ApplicationController |
|
19 | 19 | layout 'admin' |
|
20 | self.main_menu = false | |
|
20 | 21 | |
|
21 | 22 | before_action :require_admin, :except => :show |
|
22 | 23 | before_action :find_user, :only => [:show, :edit, :update, :destroy] |
@@ -16,6 +16,7 | |||
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class WelcomeController < ApplicationController |
|
19 | self.main_menu = false | |
|
19 | 20 | |
|
20 | 21 | def index |
|
21 | 22 | @news = News.latest User.current |
@@ -17,6 +17,7 | |||
|
17 | 17 | |
|
18 | 18 | class WorkflowsController < ApplicationController |
|
19 | 19 | layout 'admin' |
|
20 | self.main_menu = false | |
|
20 | 21 | |
|
21 | 22 | before_action :require_admin |
|
22 | 23 |
@@ -48,18 +48,11 module ProjectsHelper | |||
|
48 | 48 | end |
|
49 | 49 | |
|
50 | 50 | def render_project_action_links |
|
51 |
links = |
|
|
51 | links = "".html_safe | |
|
52 | 52 | if User.current.allowed_to?(:add_project, nil, :global => true) |
|
53 | 53 | links << link_to(l(:label_project_new), new_project_path, :class => 'icon icon-add') |
|
54 | 54 | end |
|
55 | if User.current.allowed_to?(:view_issues, nil, :global => true) | |
|
56 | links << link_to(l(:label_issue_view_all), issues_path) | |
|
57 | end | |
|
58 | if User.current.allowed_to?(:view_time_entries, nil, :global => true) | |
|
59 | links << link_to(l(:label_overall_spent_time), time_entries_path) | |
|
60 | end | |
|
61 | links << link_to(l(:label_overall_activity), activity_path) | |
|
62 | links.join(" | ").html_safe | |
|
55 | links | |
|
63 | 56 | end |
|
64 | 57 | |
|
65 | 58 | # Renders the projects index |
@@ -203,7 +203,21 Redmine::MenuManager.map :account_menu do |menu| | |||
|
203 | 203 | end |
|
204 | 204 | |
|
205 | 205 | Redmine::MenuManager.map :application_menu do |menu| |
|
206 | # Empty | |
|
206 | menu.push :projects, {:controller => 'projects', :action => 'index'}, | |
|
207 | :permission => nil, | |
|
208 | :caption => :label_project_plural | |
|
209 | menu.push :activity, {:controller => 'activities', :action => 'index'} | |
|
210 | menu.push :issues, {:controller => 'issues', :action => 'index'}, | |
|
211 | :if => Proc.new {User.current.allowed_to?(:view_issues, nil, :global => true)}, | |
|
212 | :caption => :label_issue_plural | |
|
213 | menu.push :time_entries, {:controller => 'timelog', :action => 'index'}, | |
|
214 | :if => Proc.new {User.current.allowed_to?(:view_time_entries, nil, :global => true)}, | |
|
215 | :caption => :label_spent_time | |
|
216 | menu.push :gantt, { :controller => 'gantts', :action => 'show' }, :caption => :label_gantt | |
|
217 | menu.push :calendar, { :controller => 'calendars', :action => 'show' }, :caption => :label_calendar | |
|
218 | ||
|
219 | menu.push :news, {:controller => 'news', :action => 'index'}, | |
|
220 | :caption => :label_news_plural | |
|
207 | 221 | end |
|
208 | 222 | |
|
209 | 223 | Redmine::MenuManager.map :admin_menu do |menu| |
@@ -22,6 +22,9 module Redmine | |||
|
22 | 22 | |
|
23 | 23 | module MenuController |
|
24 | 24 | def self.included(base) |
|
25 | base.class_attribute :main_menu | |
|
26 | base.main_menu = true | |
|
27 | ||
|
25 | 28 | base.extend(ClassMethods) |
|
26 | 29 | end |
|
27 | 30 | |
@@ -51,6 +54,14 module Redmine | |||
|
51 | 54 | self.class.menu_items |
|
52 | 55 | end |
|
53 | 56 | |
|
57 | def current_menu(project) | |
|
58 | if project && !project.new_record? | |
|
59 | :project_menu | |
|
60 | elsif self.class.main_menu | |
|
61 | :application_menu | |
|
62 | end | |
|
63 | end | |
|
64 | ||
|
54 | 65 | # Returns the menu item name according to the current action |
|
55 | 66 | def current_menu_item |
|
56 | 67 | @current_menu_item ||= menu_items[controller_name.to_sym][:actions][action_name.to_sym] || |
@@ -77,12 +88,14 module Redmine | |||
|
77 | 88 | |
|
78 | 89 | # Renders the application main menu |
|
79 | 90 | def render_main_menu(project) |
|
80 | render_menu((project && !project.new_record?) ? :project_menu : :application_menu, project) | |
|
91 | if menu_name = controller.current_menu(project) | |
|
92 | render_menu(menu_name, project) | |
|
93 | end | |
|
81 | 94 | end |
|
82 | 95 | |
|
83 | 96 | def display_main_menu?(project) |
|
84 | menu_name = project && !project.new_record? ? :project_menu : :application_menu | |
|
85 | Redmine::MenuManager.items(menu_name).children.present? | |
|
97 | menu_name = controller.current_menu(project) | |
|
98 | menu_name.present? && Redmine::MenuManager.items(menu_name).children.present? | |
|
86 | 99 | end |
|
87 | 100 | |
|
88 | 101 | def render_menu(menu, project=nil) |
@@ -2594,7 +2594,7 class IssuesControllerTest < Redmine::ControllerTest | |||
|
2594 | 2594 | :subject => ''} |
|
2595 | 2595 | assert_response :success |
|
2596 | 2596 | # no project menu |
|
2597 | assert_select '#main-menu', 0 | |
|
2597 | assert_select '#main-menu a.overview', 0 | |
|
2598 | 2598 | end |
|
2599 | 2599 | |
|
2600 | 2600 | def test_post_create_should_send_a_notification |
@@ -63,4 +63,17 class MenuManagerTest < Redmine::IntegrationTest | |||
|
63 | 63 | end |
|
64 | 64 | end |
|
65 | 65 | end |
|
66 | ||
|
67 | def test_main_menu_should_select_projects_tab_on_project_list | |
|
68 | get '/projects' | |
|
69 | assert_select '#main-menu' do | |
|
70 | assert_select 'a.projects' | |
|
71 | assert_select 'a.projects.selected' | |
|
72 | end | |
|
73 | end | |
|
74 | ||
|
75 | def test_main_menu_should_not_show_up_on_account | |
|
76 | get '/login' | |
|
77 | assert_select '#main-menu', 0 | |
|
78 | end | |
|
66 | 79 | end |
General Comments 0
You need to be logged in to leave comments.
Login now