Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[33680]Add "projects" to the global Modules menu (#8478)

Behrokh Satarnejad9db6aeffe5e8
diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb
index 05eaf0aaaae..59ffc72793d 100644
--- a/config/initializers/menus.rb
+++ b/config/initializers/menus.rb
@@ -32,7 +32,13 @@ require 'redmine/menu_manager'
Redmine::MenuManager.map :top_menu do |menu|
# projects menu will be added by
# Redmine::MenuManager::TopMenuHelper#render_projects_top_menu_node
-
+ menu.push :projects,
+ { controller: '/projects', project_id: nil, action: 'index' },
+ context: :modules,
+ caption: I18n.t('label_projects_menu'),
+ if: Proc.new {
+ (User.current.logged? || !Setting.login_required?)
+ }
menu.push :work_packages,
{ controller: '/work_packages', project_id: nil, state: nil, action: 'index' },
context: :modules,
@@ -41,7 +47,6 @@ Redmine::MenuManager.map :top_menu do |menu|
(User.current.logged? || !Setting.login_required?) &&
User.current.allowed_to?(:view_work_packages, nil, global: true)
}
-
menu.push :news,
{ controller: '/news', project_id: nil, action: 'index' },
context: :modules,
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 69eb0d4e12e..ff95690ece0 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1677,6 +1677,7 @@ en:
label_time_entry_plural: "Spent time"
label_time_sheet_menu: "Time sheet"
label_time_tracking: "Time tracking"
+ label_projects_menu: "Projects"
label_today: "today"
label_top_menu: "Top Menu"
label_topic_plural: "Topics"
diff --git a/spec/features/menu_items/top_menu_item_spec.rb b/spec/features/menu_items/top_menu_item_spec.rb
index e2b92c98d8f..5f33503d241 100644
--- a/spec/features/menu_items/top_menu_item_spec.rb
+++ b/spec/features/menu_items/top_menu_item_spec.rb
@@ -71,15 +71,16 @@ feature 'Top menu items', js: true, selenium: true do
!let(:top_menu) { find(:css, "[title=#{I18n.t('label_modules')}]") }
let(:news_item) { I18n.t('label_news_plural') }
+ let(:project_item) { I18n.t('label_projects_menu') }
let(:time_entries_item) { I18n.t('label_time_sheet_menu') }
let(:reporting_item) { I18n.t('cost_reports_title') }
- let(:all_items) { [news_item, time_entries_item] }
+ let(:all_items) { [news_item, time_entries_item, project_item] }
context 'as an admin' do
let(:user) { FactoryBot.create :admin }
it 'displays all items' do
- has_menu_items?(reporting_item, news_item)
+ has_menu_items?(reporting_item, news_item, project_item)
end
it 'visits the news page' do
@@ -89,29 +90,21 @@ feature 'Top menu items', js: true, selenium: true do
end
context 'as a regular user' do
- it 'displays news only' do
- has_menu_items? news_item
+ it 'displays news and projects only' do
+ has_menu_items? news_item, project_item
end
end
context 'as a user with permissions', allowed_to: true do
it 'displays all options' do
- has_menu_items?(reporting_item, news_item)
- end
- end
-
- context 'as a user without permissions', allowed_to: false do
- let(:open_menu) { false }
- it 'displays no options and hides the module menu' do
- has_menu_items?
- expect(page).not_to have_link('Modules')
+ has_menu_items?(reporting_item, news_item, project_item)
end
end
context 'as an anonymous user' do
let(:user) { FactoryBot.create :anonymous }
- it 'displays only news' do
- has_menu_items? news_item
+ it 'displays only news and projects' do
+ has_menu_items? news_item, project_item
end
end
end