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

Add `Boards` menu item to the global menu

Aaron Contreras324220d38202
diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb
index f0d087eedf3..74a4202a0a5 100644
--- a/config/initializers/menus.rb
+++ b/config/initializers/menus.rb
@@ -125,12 +125,14 @@ Redmine::MenuManager.map :global_menu do |menu|
# Homescreen
menu.push :home,
{ controller: '/homescreen', action: 'index' },
- icon: 'home'
+ icon: 'home',
+ first: true
# Activity
menu.push :activity,
{ controller: '/activities', action: 'index' },
- icon: 'checkmark'
+ icon: 'checkmark',
+ after: :home
menu.push :activity_filters,
{ controller: '/activities', action: 'index' },
@@ -140,7 +142,8 @@ Redmine::MenuManager.map :global_menu do |menu|
# Work packages
menu.push :work_packages,
{ controller: '/work_packages', action: 'index' },
- icon: 'view-timeline'
+ icon: 'view-timeline',
+ after: :activity
menu.push :work_packages_query_select,
{ controller: '/work_packages', action: 'index' },
diff --git a/modules/boards/app/controllers/boards/boards_controller.rb b/modules/boards/app/controllers/boards/boards_controller.rb
index 8a86a919407..d2f819043d4 100644
--- a/modules/boards/app/controllers/boards/boards_controller.rb
+++ b/modules/boards/app/controllers/boards/boards_controller.rb
@@ -20,12 +20,17 @@ module ::Boards
def overview
projects = Project.allowed_to(User.current, :show_board_views)
@board_grids = Boards::Grid.includes(:project).where(project: projects)
+ render layout: 'global'
end
current_menu_item :index do
:board_view
end
+ current_menu_item :overview do
+ :boards
+ end
+
private
def authorize_work_package_permission
diff --git a/modules/boards/lib/open_project/boards/engine.rb b/modules/boards/lib/open_project/boards/engine.rb
index 8909046d18c..96d48d28a76 100644
--- a/modules/boards/lib/open_project/boards/engine.rb
+++ b/modules/boards/lib/open_project/boards/engine.rb
@@ -53,16 +53,27 @@ module OpenProject::Boards
last: true,
caption: :'boards.label_boards'
+ should_render_global_menu_item = Proc.new do
+ OpenProject::FeatureDecisions.more_global_index_pages_active? &&
+ (User.current.logged? || !Setting.login_required?) &&
+ User.current.allowed_to_globally?(:show_board_views)
+ end
+
menu :top_menu,
- :boards, { controller: '/boards/boards', action: 'overview' },
+ :boards,
+ { controller: '/boards/boards', action: 'overview' },
context: :modules,
caption: :project_module_board_view,
icon: 'boards',
- if: Proc.new {
- OpenProject::FeatureDecisions.more_global_index_pages_active? &&
- (User.current.logged? || !Setting.login_required?) &&
- User.current.allowed_to_globally?(:show_board_views)
- }
+ if: should_render_global_menu_item
+
+ menu :global_menu,
+ :boards,
+ { controller: '/boards/boards', action: 'overview' },
+ caption: :project_module_board_view,
+ after: :team_planners,
+ icon: 'boards',
+ if: should_render_global_menu_item
end
patch_with_namespace :BasicData, :SettingSeeder
diff --git a/modules/boards/spec/features/board_enterprise_spec.rb b/modules/boards/spec/features/board_enterprise_spec.rb
index bf63571d675..08a816ba008 100644
--- a/modules/boards/spec/features/board_enterprise_spec.rb
+++ b/modules/boards/spec/features/board_enterprise_spec.rb
@@ -30,7 +30,7 @@ require 'spec_helper'
require_relative './support/board_index_page'
require_relative './support/board_page'
-RSpec.describe 'Boards enterprise spec', js: true do
+RSpec.describe 'Boards enterprise spec', :js, :with_cuprite do
shared_let(:admin) { create(:admin) }
shared_let(:project) { create(:project, enabled_module_names: %i[work_package_tracking board_view]) }
diff --git a/modules/boards/spec/features/board_overview_spec.rb b/modules/boards/spec/features/board_overview_spec.rb
index 9b4e602f4d3..60111488f78 100644
--- a/modules/boards/spec/features/board_overview_spec.rb
+++ b/modules/boards/spec/features/board_overview_spec.rb
@@ -29,7 +29,10 @@
require 'spec_helper'
require_relative './support/board_overview_page'
-RSpec.describe 'Work Package boards overview spec', with_ee: %i[board_view], with_flag: { more_global_index_pages: true } do
+RSpec.describe 'Work Package boards overview spec',
+ with_cuprite: true,
+ with_ee: %i[board_view],
+ with_flag: { more_global_index_pages: true } do
let(:user) do
create(:user,
member_in_project: project,
@@ -48,7 +51,13 @@ RSpec.describe 'Work Package boards overview spec', with_ee: %i[board_view], wit
let(:other_project_board_view) { create(:board_grid_with_query, name: 'Unseeable Board', project: other_project) }
before do
- login_as(user)
+ login_as user
+ end
+
+ it 'renders the global menu with its item selected' do
+ board_overview.visit!
+
+ board_overview.expect_global_menu_item_selected
end
context 'when no boards exist' do
diff --git a/modules/boards/spec/features/menu_items/global_menu_item_spec.rb b/modules/boards/spec/features/menu_items/global_menu_item_spec.rb
new file mode 100644
index 00000000000..a5d6f5bfd1d
--- /dev/null
+++ b/modules/boards/spec/features/menu_items/global_menu_item_spec.rb
@@ -0,0 +1,67 @@
+# frozen_string_literal: true
+
+# -- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2023 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+# ++
+#
+
+require 'spec_helper'
+
+RSpec.describe 'Global menu item for boards', :js, :with_cuprite do
+ let(:boards_label) { I18n.t('boards.label_boards') }
+
+ before do
+ login_as current_user
+ visit root_path
+ end
+
+ context 'with more global index pages active', with_flag: { more_global_index_pages: true } do
+ context 'with permissions' do
+ let(:current_user) { create(:admin) }
+
+ it "sends the user to the boards overview when clicked" do
+ within '#main-menu' do
+ click_on boards_label
+ end
+
+ expect(page).to have_current_path(boards_all_path)
+ expect(page).to have_content(boards_label)
+ expect(page).to have_content(I18n.t(:no_results_title_text))
+ end
+ end
+
+ context 'without permissions' do
+ let(:current_user) { create(:user) }
+
+ it 'is not rendered' do
+ within '#main-menu' do
+ expect(page).not_to have_content(boards_label)
+ end
+ end
+ end
+ end
+end
diff --git a/modules/boards/spec/features/menu_items/top_menu_item_spec.rb b/modules/boards/spec/features/menu_items/top_menu_item_spec.rb
index ba6370c64b8..58a4071ba40 100644
--- a/modules/boards/spec/features/menu_items/top_menu_item_spec.rb
+++ b/modules/boards/spec/features/menu_items/top_menu_item_spec.rb
@@ -28,7 +28,7 @@
require 'spec_helper'
-RSpec.describe 'Top menu item for boards', js: true, selenium: true do
+RSpec.describe 'Top menu item for boards', :js, :with_cuprite do
let(:user) { create(:admin) }
let(:menu) { find(".op-app-menu a[title='#{I18n.t('label_modules')}']") }
@@ -39,12 +39,12 @@ RSpec.describe 'Top menu item for boards', js: true, selenium: true do
end
shared_examples_for 'the boards menu item' do
- it "displays the menu item" do
- expect(page).to have_link(boards)
- end
-
it "sends the user to the boards overview when clicked" do
- click_on boards
+ menu.click
+
+ within '#more-menu' do
+ click_on boards
+ end
expect(page).to have_content(boards)
expect(page).to have_content(I18n.t(:no_results_title_text))
@@ -57,8 +57,6 @@ RSpec.describe 'Top menu item for boards', js: true, selenium: true do
before do
visit "/projects/#{project.identifier}/settings/general"
-
- menu.click
end
it_behaves_like 'the boards menu item'
@@ -67,24 +65,30 @@ RSpec.describe 'Top menu item for boards', js: true, selenium: true do
context 'on the landing page' do
before do
visit root_path
-
- menu.click
end
it_behaves_like 'the boards menu item'
- end
- context 'with missing permissions' do
- let(:user) { create(:user) }
+ context 'with missing permissions' do
+ let(:user) { create(:user) }
- before do
- visit root_path
-
- menu.click
+ it "does not display the menu item" do
+ within '#more-menu', visible: false do
+ expect(page).not_to have_link boards
+ end
+ end
end
+ end
+ end
+
+ context 'without more global index pages enabled' do
+ before do
+ visit root_path
+ end
- it "does not display the menu item" do
- expect(page).not_to have_link(boards)
+ it 'does not display the menu item' do
+ within '#more-menu', visible: false do
+ expect(page).not_to have_link boards
end
end
end
diff --git a/modules/boards/spec/features/support/board_index_page.rb b/modules/boards/spec/features/support/board_index_page.rb
index 348afa0649b..cb26f4b5377 100644
--- a/modules/boards/spec/features/support/board_index_page.rb
+++ b/modules/boards/spec/features/support/board_index_page.rb
@@ -78,6 +78,7 @@ module Pages
def open_board(board)
page.find('td.name a', text: board.name).click
+ wait_for_reload if using_cuprite?
::Pages::Board.new board
end
end
diff --git a/modules/boards/spec/features/support/board_overview_page.rb b/modules/boards/spec/features/support/board_overview_page.rb
index 1fd2153cf8f..793c115d545 100644
--- a/modules/boards/spec/features/support/board_overview_page.rb
+++ b/modules/boards/spec/features/support/board_overview_page.rb
@@ -35,6 +35,12 @@ module Pages
navigate_to_modules_menu_item("Boards")
end
+ def expect_global_menu_item_selected
+ within '#main-menu' do
+ expect(page).to have_selector('.selected', text: 'Boards')
+ end
+ end
+
def expect_no_boards_listed
within '#content-wrapper' do
expect(page).to have_content I18n.t(:no_results_title_text)
diff --git a/modules/team_planner/lib/open_project/team_planner/engine.rb b/modules/team_planner/lib/open_project/team_planner/engine.rb
index 78cc744b4b8..ed233a56903 100644
--- a/modules/team_planner/lib/open_project/team_planner/engine.rb
+++ b/modules/team_planner/lib/open_project/team_planner/engine.rb
@@ -48,6 +48,7 @@ module OpenProject::TeamPlanner
:team_planners,
{ controller: '/team_planner/team_planner', action: :overview },
caption: :'team_planner.label_team_planner_plural',
+ before: :boards,
after: :calendar_view,
icon: 'team-planner',
if: should_render_global_menu_item,
diff --git a/spec/lib/redmine/menu_manager_spec.rb b/spec/lib/redmine/menu_manager_spec.rb
index 3fd0413cd33..422e69a9ff6 100644
--- a/spec/lib/redmine/menu_manager_spec.rb
+++ b/spec/lib/redmine/menu_manager_spec.rb
@@ -52,7 +52,7 @@ RSpec.describe Redmine::MenuManager do
context 'for the global_menu' do
it 'includes the expected items' do
expect(described_class.items(:global_menu).map(&:name))
- .to include(:home, :activity, :work_packages, :calendar_view, :team_planners, :cost_reports_global)
+ .to include(:home, :activity, :work_packages, :calendar_view, :team_planners, :boards, :cost_reports_global)
end
end