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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Order module menu items in tandem with the global sidebar
Aaron Contreras6dc0c1292e8c
diff --git a/config/initializers/menus.rb b/config/initializers/menus.rbindex f1c0e16b5b8..2591df65655 100644--- a/config/initializers/menus.rb+++ b/config/initializers/menus.rb@@ -39,6 +39,12 @@ Redmine::MenuManager.map :top_menu do |menu|if: Proc.new {(User.current.logged? || !Setting.login_required?)}++ menu.push :activity,+ { controller: '/activities', action: 'index' },+ context: :modules,+ icon: 'checkmark'+menu.push :work_packages,{ controller: '/work_packages', project_id: nil, state: nil, action: 'index' },context: :modules,diff --git a/modules/boards/lib/open_project/boards/engine.rb b/modules/boards/lib/open_project/boards/engine.rbindex 612e94d8696..5db32f429b2 100644--- a/modules/boards/lib/open_project/boards/engine.rb+++ b/modules/boards/lib/open_project/boards/engine.rb@@ -64,6 +64,8 @@ module OpenProject::Boards{ controller: '/boards/boards', action: 'overview' },context: :modules,caption: :project_module_board_view,+ before: :news,+ after: :team_planners,icon: 'boards',if: should_render_global_menu_itemdiff --git a/modules/meeting/lib/open_project/meeting/engine.rb b/modules/meeting/lib/open_project/meeting/engine.rbindex 170dffcc986..704cb84b11e 100644--- a/modules/meeting/lib/open_project/meeting/engine.rb+++ b/modules/meeting/lib/open_project/meeting/engine.rb@@ -76,6 +76,7 @@ module OpenProject::Meeting:meetings, { controller: '/meetings', action: 'index', project_id: nil },context: :modules,caption: :label_meeting_plural,+ last: true,icon: 'meetings',if: should_render_global_menu_itemdiff --git a/modules/team_planner/lib/open_project/team_planner/engine.rb b/modules/team_planner/lib/open_project/team_planner/engine.rbindex 9919aa5d97a..617087b1dcd 100644--- a/modules/team_planner/lib/open_project/team_planner/engine.rb+++ b/modules/team_planner/lib/open_project/team_planner/engine.rb@@ -74,6 +74,8 @@ module OpenProject::TeamPlanner:team_planners, { controller: '/team_planner/team_planner', action: :overview },context: :modules,caption: :'team_planner.label_team_planner_plural',+ before: :boards,+ after: :calendar_view,icon: 'team-planner',if: should_render_global_menu_item,enterprise_feature: 'team_planner_view'diff --git a/spec/features/menu_items/top_menu_item_spec.rb b/spec/features/menu_items/top_menu_item_spec.rbindex 6a7f6849a8e..33a9c7cc8f5 100644--- a/spec/features/menu_items/top_menu_item_spec.rb+++ b/spec/features/menu_items/top_menu_item_spec.rb@@ -28,29 +28,26 @@require 'spec_helper'-RSpec.describe 'Top menu items', js: true, with_cuprite: true do+RSpec.describe 'Top menu items', :js, :with_cuprite dolet(:user) { create(:user) }let(:open_menu) { true }- def has_menu_items?(*labels)+ def has_menu_items?(*items)within '.op-app-header' do- labels.each do |l|- expect(page).to have_link(l)+ items.each do |item|+ expect(page).to have_link(item.label)end- (all_items - labels).each do |l|- expect(page).not_to have_link(l)+ (all_items - items).each do |item|+ expect(page).not_to have_link(item.label)endendenddef click_link_in_open_menu(title)- # if the menu is not completely expanded (e.g. if the frontend thread is too fast),- # the click might be ignored-within '.op-app-menu--dropdown[aria-expanded=true]' doexpect(page).not_to have_selector('[style~=overflow]')- page.click_link(title)+ click_link(title)endend@@ -64,48 +61,80 @@ RSpec.describe 'Top menu items', js: true, with_cuprite: true doendvisit root_path+ wait_for_reloadtop_menu.click if open_menuend- describe 'Modules' do+ describe 'Modules', with_flag: { more_global_index_pages_active: true } dolet!(:top_menu) { find("[title=#{I18n.t('label_modules')}]") }- let(:news_item) { I18n.t('label_news_plural') }- let(:project_item) { I18n.t('label_projects_menu') }- let(:reporting_item) { I18n.t('cost_reports_title') }+ shared_let(:menu_link_item) { Struct.new(:label, :path) }++ shared_let(:project_item) { menu_link_item.new(I18n.t(:label_projects_menu), projects_path) }+ shared_let(:activity_item) { menu_link_item.new(I18n.t(:label_activity), activity_index_path) }+ shared_let(:work_packages_item) { menu_link_item.new(I18n.t(:label_work_package_plural), work_packages_path) }+ shared_let(:calendar_item) { menu_link_item.new(I18n.t(:label_calendar_plural), calendars_path) }+ shared_let(:team_planners_item) { menu_link_item.new(I18n.t('team_planner.label_team_planner_plural'), team_planners_path) }+ shared_let(:boards_item) { menu_link_item.new(I18n.t(:project_module_board_view), boards_all_path) }+ shared_let(:news_item) { menu_link_item.new(I18n.t(:label_news_plural), news_index_path) }+ shared_let(:reporting_item) { menu_link_item.new(I18n.t(:cost_reports_title), '/cost_reports') }+ shared_let(:meetings_item) { menu_link_item.new(I18n.t(:label_meeting_plural), '/meetings') }++ shared_let(:all_items) do+ [+ project_item,+ activity_item,+ work_packages_item,+ calendar_item,+ team_planners_item,+ boards_item,+ news_item,+ reporting_item,+ meetings_item+ ]+ end- let!(:all_items) { [news_item, project_item, reporting_item] }+ shared_examples 'visits the global index page' do |item:|+ it "visits the #{item.label} page" do+ click_link_in_open_menu item.label+ expect(page).to have_current_path item.path+ end+ endcontext 'as an admin' dolet(:user) { create(:admin) }it 'displays all items' do- has_menu_items?(reporting_item, news_item, project_item)+ has_menu_items?(*all_items)end- it 'visits the news page' do- click_link_in_open_menu(news_item)- expect(page).to have_current_path(news_index_path)+ it 'visits all module pages', :aggregate_failures, with_ee: %i[team_planner_view] do+ all_items.each do |item|+ click_link_in_open_menu item.label+ expect(page).to have_current_path(item.path)++ top_menu.click if open_menu+ endendendcontext 'as a regular user' do- it 'displays news and projects only' do- has_menu_items? news_item, project_item+ it 'only displays projects, activity and news' do+ has_menu_items? project_item, activity_item, news_itemendendcontext 'as a user with permissions', allowed_to: true doit 'displays all options' do- has_menu_items?(reporting_item, news_item, project_item)+ has_menu_items?(*all_items)endendcontext 'as an anonymous user' dolet(:user) { create(:anonymous) }- it 'displays only news and projects' do- has_menu_items? news_item, project_item+ it 'displays only projects, activity and news' do+ has_menu_items? project_item, activity_item, news_itemendendenddiff --git a/spec/lib/redmine/menu_manager_spec.rb b/spec/lib/redmine/menu_manager_spec.rbindex 4fa354b9701..1389c95d51d 100644--- a/spec/lib/redmine/menu_manager_spec.rb+++ b/spec/lib/redmine/menu_manager_spec.rb@@ -31,7 +31,16 @@ RSpec.describe Redmine::MenuManager docontext 'for the top_menu' doit 'includes the expected items' doexpect(described_class.items(:top_menu).map(&:name))- .to include(:work_packages, :news, :help)+ .to include(:projects,+ :activity,+ :work_packages,+ :calendar_view,+ :team_planners,+ :boards,+ :news,+ :cost_reports_global,+ :meetings,+ :help)endend