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
Add `Team Planners` item to the global menu
Aaron Contreras38009fede563
diff --git a/modules/reporting/lib/open_project/reporting/engine.rb b/modules/reporting/lib/open_project/reporting/engine.rbindex 37a6cc4c058..fd2f5f409aa 100644--- a/modules/reporting/lib/open_project/reporting/engine.rb+++ b/modules/reporting/lib/open_project/reporting/engine.rb@@ -79,6 +79,7 @@ module OpenProject::Reportingmenu :global_menu,:cost_reports_global,{ controller: '/cost_reports', action: 'index', project_id: nil },+ last: true,caption: :cost_reports_title,icon: 'cost-reports',if: should_renderdiff --git a/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb b/modules/team_planner/app/controllers/team_planner/team_planner_controller.rbindex d1a9c330d77..7069358a8b7 100644--- a/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb+++ b/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb@@ -1,6 +1,7 @@module ::TeamPlannerclass TeamPlannerController < BaseControllerinclude EnterpriseTrialHelper+ include Layoutbefore_action :find_optional_projectbefore_action :authorize, except: %i[overview upsale]before_action :authorize_global, only: %i[overview]@@ -15,6 +16,7 @@ module ::TeamPlannerdef overview@views = visible_plans+ render layout: 'global'enddef show@@ -43,6 +45,10 @@ module ::TeamPlanner:team_planner_viewend+ current_menu_item :overview do+ :team_planners+ end+privatedef find_plan_viewdiff --git a/modules/team_planner/lib/open_project/team_planner/engine.rb b/modules/team_planner/lib/open_project/team_planner/engine.rbindex dca9d551464..78cc744b4b8 100644--- a/modules/team_planner/lib/open_project/team_planner/engine.rb+++ b/modules/team_planner/lib/open_project/team_planner/engine.rb@@ -38,6 +38,21 @@ module OpenProject::TeamPlannercontract_actions: { team_planner: %i[create update destroy] }end+ 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?(:view_team_planner)+ end++ menu :global_menu,+ :team_planners,+ { controller: '/team_planner/team_planner', action: :overview },+ caption: :'team_planner.label_team_planner_plural',+ after: :calendar_view,+ icon: 'team-planner',+ if: should_render_global_menu_item,+ enterprise_feature: 'team_planner_view'+menu :project_menu,:team_planner_view,{ controller: '/team_planner/team_planner', action: :index },@@ -59,11 +74,7 @@ module OpenProject::TeamPlannercontext: :modules,caption: :'team_planner.label_team_planner_plural',icon: 'team-planner',- if: Proc.new {- OpenProject::FeatureDecisions.more_global_index_pages_active? &&- (User.current.logged? || !Setting.login_required?) &&- User.current.allowed_to_globally?(:view_team_planner)- },+ if: should_render_global_menu_item,enterprise_feature: 'team_planner_view'enddiff --git a/modules/team_planner/spec/features/team_planner_index_spec.rb b/modules/team_planner/spec/features/team_planner_index_spec.rbindex 35dd86154a1..31b958fd062 100644--- a/modules/team_planner/spec/features/team_planner_index_spec.rb+++ b/modules/team_planner/spec/features/team_planner_index_spec.rb@@ -27,9 +27,9 @@#++require 'spec_helper'-require_relative './shared_context'+require_relative 'shared_context'-RSpec.describe 'Team planner index', js: true, with_ee: %i[team_planner_view] do+RSpec.describe 'Team planner index', :js, :with_cuprite, with_ee: %i[team_planner_view] doinclude_context 'with team planner full access'let(:current_user) { user }diff --git a/modules/team_planner/spec/features/team_planner_menu_spec.rb b/modules/team_planner/spec/features/team_planner_menu_spec.rbindex 8977072da21..ed5afbb89c6 100644--- a/modules/team_planner/spec/features/team_planner_menu_spec.rb+++ b/modules/team_planner/spec/features/team_planner_menu_spec.rb@@ -28,67 +28,99 @@require 'spec_helper'-RSpec.describe 'Team planner sidemenu', js: true do+RSpec.describe 'Team planner Menu Item', :js, :with_cuprite doshared_let(:project) docreate(:project, enabled_module_names: %w[work_package_tracking team_planner_view])end+ shared_let(:user_without_rights) do+ create(:user,+ member_in_project: project,+ member_with_permissions: %w[+ view_work_packages edit_work_packages add_work_packages+ view_team_planner+ ])+ end+ shared_let(:user_with_rights) do+ create(:user,+ member_in_project: project,+ member_with_permissions: %w[+ view_work_packages edit_work_packages add_work_packages+ view_team_planner manage_team_planner+ ])+ end- context 'with a user that does not have create rights' do- shared_let(:user_without_rights) do- create(:user,- member_in_project: project,- member_with_permissions: %w[- view_work_packages edit_work_packages add_work_packages- view_team_planner- ])- end-- current_user { user_without_rights }+ context 'within the global menu', with_flag: { more_global_index_pages_active: true } do+ before do+ login_as user_without_rights- it 'hides the create team planner option if you do not have rights' do- visit project_path(project)+ visit root_pathwithin '#main-menu' doclick_link 'Team planners'end+ end- expect(page).not_to have_selector('[data-qa-selector="team-planner--create-button"]')+ context 'when EE enabled', with_ee: %i[team_planner_view] do+ it 'navigates to the global index page' do+ expect(page).to have_current_path(team_planners_path)+ endendend- context 'with a user that has create rights' do- shared_let(:user_with_rights) do- create(:user,- member_in_project: project,- member_with_permissions: %w[- view_work_packages edit_work_packages add_work_packages- view_team_planner manage_team_planner- ])- end+ context 'within the project side menu' do+ context 'as a user that does not have create rights' do+ current_user { user_without_rights }- current_user { user_with_rights }+ context 'when EE disabled' do+ it 'does not show the create team planner option' do+ visit project_path(project)- context 'when EE disabled' do- it 'does not show the create team planner option' do- visit project_path(project)+ within '#main-menu' do+ click_link 'Team planners'+ end- within '#main-menu' do- click_link 'Team planners'+ expect(page).not_to have_selector('[data-qa-selector="team-planner--create-button"]')end+ end++ context 'when EE enabled', with_ee: %i[team_planner_view] do+ it 'does not show the create team planner option' do+ visit project_path(project)- expect(page).not_to have_selector('[data-qa-selector="team-planner--create-button"]')+ within '#main-menu' do+ click_link 'Team planners'+ end++ expect(page).not_to have_selector('[data-qa-selector="team-planner--create-button"]')+ endendend- context 'when EE enabled', with_ee: %i[team_planner_view] do- it 'shows the create team planner option' do- visit project_path(project)+ context 'as a user that has create rights' do+ current_user { user_with_rights }++ context 'when EE disabled' do+ it 'does not show the create team planner option' do+ visit project_path(project)++ within '#main-menu' do+ click_link 'Team planners'+ end- within '#main-menu' do- click_link 'Team planners'+ expect(page).not_to have_selector('[data-qa-selector="team-planner--create-button"]')end+ end++ context 'when EE enabled', with_ee: %i[team_planner_view] do+ it 'shows the create team planner option' do+ visit project_path(project)- expect(page).to have_selector('[data-qa-selector="team-planner--create-button"]')+ within '#main-menu' do+ click_link 'Team planners'+ end++ expect(page).to have_selector('[data-qa-selector="team-planner--create-button"]')+ endendendenddiff --git a/modules/team_planner/spec/features/team_planner_overview_spec.rb b/modules/team_planner/spec/features/team_planner_overview_spec.rbnew file mode 100644index 00000000000..dba8054a28a--- /dev/null+++ b/modules/team_planner/spec/features/team_planner_overview_spec.rb@@ -0,0 +1,109 @@+# 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'+require_relative 'shared_context'++RSpec.describe 'Team planner overview',+ :js,+ :with_cuprite,+ with_ee: %i[team_planner_view],+ with_flag: { more_global_index_pages_active: true } do+ include_context 'with team planner full access'++ let(:current_user) { user }+ let(:query) { create(:query, user:, project:, public: true) }+ let(:team_plan) { create(:view_team_planner, query:) }++ before do+ login_as current_user+ team_plan+ visit team_planners_path+ end++ it 'renders a global menu with its item selected' do+ within '#main-menu' do+ expect(page).to have_selector '.selected', text: 'Team planners'+ end+ end++ it 'shows no create button' do+ expect(page).not_to have_selector '.button', text: 'Team planner'+ end++ context 'with no view' do+ let(:team_plan) { nil }++ it 'shows an overview action' do+ expect(page).to have_text 'There is currently nothing to display.'+ end+ end++ context 'with an existing view' do+ it 'shows that view' do+ expect(page).to have_selector 'td', text: query.name+ end++ context 'with another user with limited access' do+ let(:current_user) do+ create(:user,+ firstname: 'Bernd',+ member_in_project: project,+ member_with_permissions: %w[view_work_packages view_team_planner])+ end++ it 'does not show the management buttons' do+ expect(page).to have_selector 'td', text: query.name++ # Does not show the delete+ expect(page).not_to have_selector "[data-qa-selector='team-planner-remove-#{query.id}']"++ # Does not show the create button+ expect(page).not_to have_selector '.button', text: 'Team planner'+ end++ context 'when the view is non-public' do+ let(:query) { create(:query, user:, project:, public: false) }++ it 'does not show a non-public view' do+ expect(page).to have_text 'There is currently nothing to display.'+ expect(page).not_to have_selector 'td', text: query.name++ # Does not show the delete+ expect(page).not_to have_selector "[data-qa-selector='team-planner-remove-#{query.id}']"++ # Does not show the create button+ expect(page).not_to have_selector '.button', text: 'Team planner'+ end+ end+ end+ end+enddiff --git a/modules/team_planner/spec/features/team_planner_upsale_spec.rb b/modules/team_planner/spec/features/team_planner_upsale_spec.rbindex 8d38e56ac48..ffe48f8d141 100644--- a/modules/team_planner/spec/features/team_planner_upsale_spec.rb+++ b/modules/team_planner/spec/features/team_planner_upsale_spec.rb@@ -29,7 +29,7 @@require 'spec_helper'require_relative './shared_context'-RSpec.describe 'Team planner index', js: true do+RSpec.describe 'Team planner index', :js, :with_cuprite doinclude_context 'with team planner full access'let(:current_user) { user }@@ -39,6 +39,10 @@ RSpec.describe 'Team planner index', js: true doendit 'redirects routes to upsale' do+ visit team_planners_path++ expect(page).to have_text 'Upgrade now'+visit project_team_planners_path(project)expect(page).to have_text 'Upgrade now'diff --git a/spec/lib/redmine/menu_manager_spec.rb b/spec/lib/redmine/menu_manager_spec.rbindex 32b1d0cd787..3fd0413cd33 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 docontext 'for the global_menu' doit 'includes the expected items' doexpect(described_class.items(:global_menu).map(&:name))- .to include(:home, :activity, :work_packages, :calendar_view, :cost_reports_global)+ .to include(:home, :activity, :work_packages, :calendar_view, :team_planners, :cost_reports_global)endend