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
Replace angular sidemenu with rails based Submenu component for TeamPlanner module
Henriette Darge357ca0f396cb
diff --git a/app/components/open_project/common/submenu_component.html.erb b/app/components/open_project/common/submenu_component.html.erbindex 35e4f8e2a95..6f42ad54916 100644--- a/app/components/open_project/common/submenu_component.html.erb+++ b/app/components/open_project/common/submenu_component.html.erb@@ -31,7 +31,7 @@<% top_level_sidebar_menu_items.first.children.each do |menu_item| %><li class="op-sidemenu--item" data-filter--filter-list-target="searchItem"><% selected = menu_item.selected ? 'selected' : '' %>- <a class="op-sidemenu--item-action <%= selected %>" href="<%= menu_item.href %>">+ <a class="op-sidemenu--item-action <%= selected %>" href="<%= menu_item.href %>" data-test-selector="op-sidemenu--item-action"><span class="op-sidemenu--item-title"><%= menu_item.title %></span></a></li>@@ -60,7 +60,7 @@<% menu_item.children.each do |child_item| %><li class="op-sidemenu--item" data-filter--filter-list-target="searchItem"><% selected = child_item.selected ? 'selected' : '' %>- <a class="op-sidemenu--item-action <%= selected %>" href="<%= child_item.href %>">+ <a class="op-sidemenu--item-action <%= selected %>" href="<%= child_item.href %>" data-test-selector="op-sidemenu--item-action"><span class="op-sidemenu--item-title"><%= child_item.title %></span></a></li>@@ -75,9 +75,10 @@<%= render Primer::Beta::Button.new(scheme: :primary,tag: :a,href: @create_btn_options[:href],+ test_selector: "#{@create_btn_options[:module_key]}--create-button",classes: "op-sidebar--footer-action") do |button|button.with_leading_visual_icon(icon: "plus")- @create_btn_options[:text]+ I18n.t("label_#{@create_btn_options[:module_key]}")end %></div><% end %>diff --git a/frontend/src/app/core/setup/global-dynamic-components.const.ts b/frontend/src/app/core/setup/global-dynamic-components.const.tsindex a4ad7980083..571d539333e 100644--- a/frontend/src/app/core/setup/global-dynamic-components.const.ts+++ b/frontend/src/app/core/setup/global-dynamic-components.const.ts@@ -143,10 +143,6 @@ import {opInAppNotificationBellSelector,} from 'core-app/features/in-app-notifications/bell/in-app-notification-bell.component';import { IanMenuComponent, ianMenuSelector } from 'core-app/features/in-app-notifications/center/menu/menu.component';-import {- opTeamPlannerSidemenuSelector,- TeamPlannerSidemenuComponent,-} from 'core-app/features/team-planner/team-planner/sidemenu/team-planner-sidemenu.component';import {OpModalOverlayComponent,opModalOverlaySelector,@@ -213,7 +209,6 @@ export const globalDynamicComponents:OptionalBootstrapDefinition[] = [{ selector: headerProjectSelectSelector, cls: OpHeaderProjectSelectComponent },{ selector: wpOverviewGraphSelector, cls: WorkPackageOverviewGraphComponent },{ selector: opViewSelectSelector, cls: ViewSelectComponent },- { selector: opTeamPlannerSidemenuSelector, cls: TeamPlannerSidemenuComponent },{ selector: triggerActionsEntryComponentSelector, cls: TriggerActionsEntryComponent, embeddable: true },{ selector: editableQueryPropsSelector, cls: EditableQueryPropsComponent },{ selector: backupSelector, cls: BackupComponent },diff --git a/frontend/src/app/features/team-planner/team-planner/sidemenu/team-planner-sidemenu.component.html b/frontend/src/app/features/team-planner/team-planner/sidemenu/team-planner-sidemenu.component.htmldeleted file mode 100644index 6d49c6203a3..00000000000--- a/frontend/src/app/features/team-planner/team-planner/sidemenu/team-planner-sidemenu.component.html+++ /dev/null@@ -1,22 +0,0 @@-<op-view-select- [projectId]="projectId"- [menuItems]="menuItems"- baseRoute="team_planner.page.show"- viewType="TeamPlanner"- class="op-sidebar--body"->-</op-view-select>--<div class="op-sidebar--footer">- <button- *ngIf="(canAddTeamPlanner$ | async)"- class="button -primary -expand"- [uiSref]="createButton.uiSref"- [uiParams]="createButton.uiParams"- [title]="createButton.title"- data-test-selector="team-planner--create-button"- >- <span class="spot-icon spot-icon_add"></span>- <span [textContent]="createButton.text"></span>- </button>-</div>diff --git a/frontend/src/app/features/team-planner/team-planner/sidemenu/team-planner-sidemenu.component.ts b/frontend/src/app/features/team-planner/team-planner/sidemenu/team-planner-sidemenu.component.tsdeleted file mode 100644index a434c52cb8c..00000000000--- a/frontend/src/app/features/team-planner/team-planner/sidemenu/team-planner-sidemenu.component.ts+++ /dev/null@@ -1,61 +0,0 @@-import {- ChangeDetectionStrategy,- Component,- ElementRef,- HostBinding,- Input,-} from '@angular/core';-import { populateInputsFromDataset } from 'core-app/shared/components/dataset-inputs';-import { CurrentUserService } from 'core-app/core/current-user/current-user.service';-import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';-import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';-import { I18nService } from 'core-app/core/i18n/i18n.service';-import { BannersService } from 'core-app/core/enterprise/banners.service';-import { map } from 'rxjs/operators';--export const opTeamPlannerSidemenuSelector = 'op-team-planner-sidemenu';--@Component({- selector: opTeamPlannerSidemenuSelector,- templateUrl: './team-planner-sidemenu.component.html',- changeDetection: ChangeDetectionStrategy.OnPush,-})-export class TeamPlannerSidemenuComponent extends UntilDestroyedMixin {- @HostBinding('class.op-sidebar') className = true;-- @Input() menuItems:string[] = [];-- @Input() projectId:string|undefined;-- canAddTeamPlanner$ = this- .currentUserService- .hasCapabilities$(- 'team_planners/create',- this.currentProjectService.id || null,- )- .pipe(- map((val) => val && !this.bannersService.eeShowBanners),- );-- createButton = {- text: this.I18n.t('js.team_planner.create_label'),- title: this.I18n.t('js.team_planner.create_title'),- uiSref: 'team_planner.page.show',- uiParams: {- query_id: null,- query_props: '',- },- };-- constructor(- readonly elementRef:ElementRef,- readonly currentUserService:CurrentUserService,- readonly currentProjectService:CurrentProjectService,- readonly bannersService:BannersService,- readonly I18n:I18nService,- ) {- super();-- populateInputsFromDataset(this);- }-}diff --git a/frontend/src/app/features/team-planner/team-planner/team-planner.module.ts b/frontend/src/app/features/team-planner/team-planner/team-planner.module.tsindex 3d8f8316ee2..3d3d2c1e744 100644--- a/frontend/src/app/features/team-planner/team-planner/team-planner.module.ts+++ b/frontend/src/app/features/team-planner/team-planner/team-planner.module.ts@@ -14,7 +14,6 @@ import { TeamPlannerPageComponent } from 'core-app/features/team-planner/team-plimport { OpSharedModule } from 'core-app/shared/shared.module';import { AddExistingPaneComponent } from './add-work-packages/add-existing-pane.component';import { OpenprojectContentLoaderModule } from 'core-app/shared/components/op-content-loader/openproject-content-loader.module';-import { TeamPlannerSidemenuComponent } from 'core-app/features/team-planner/team-planner/sidemenu/team-planner-sidemenu.component';import { TeamPlannerViewSelectMenuDirective } from 'core-app/features/team-planner/team-planner/view-select/view-select-menu.directive';@NgModule({@@ -23,7 +22,6 @@ import { TeamPlannerViewSelectMenuDirective } from 'core-app/features/team-plannTeamPlannerPageComponent,AddAssigneeComponent,AddExistingPaneComponent,- TeamPlannerSidemenuComponent,TeamPlannerViewSelectMenuDirective,],imports: [diff --git a/frontend/src/app/features/team-planner/team-planner/team-planner.routes.ts b/frontend/src/app/features/team-planner/team-planner/team-planner.routes.tsindex 2674e488e6f..8efb9246cb7 100644--- a/frontend/src/app/features/team-planner/team-planner/team-planner.routes.ts+++ b/frontend/src/app/features/team-planner/team-planner/team-planner.routes.ts@@ -33,6 +33,13 @@ import { WorkPackagesBaseComponent } from 'core-app/features/work-packages/routiimport { TeamPlannerPageComponent } from 'core-app/features/team-planner/team-planner/page/team-planner-page.component';import { TeamPlannerComponent } from 'core-app/features/team-planner/team-planner/planner/team-planner.component';+export const sidemenuId = 'team_planner_sidemenu';+export const sideMenuOptions = {+ sidemenuId,+ hardReloadOnBaseRoute: true,+ defaultQuery: 'new',+};+export const TEAM_PLANNER_ROUTES:Ng2StateDeclaration[] = [{name: 'team_planner',@@ -56,12 +63,14 @@ export const TEAM_PLANNER_ROUTES:Ng2StateDeclaration[] = [redirectTo: 'team_planner.page.show',data: {bodyClasses: 'router--team-planner',+ sideMenuOptions,},},{name: 'team_planner.page.show',data: {baseRoute: 'team_planner.page.show',+ sideMenuOptions,},views: {'content-left': { component: TeamPlannerComponent },diff --git a/lookbook/previews/open_project/common/submenu_component_preview.rb b/lookbook/previews/open_project/common/submenu_component_preview.rbindex b8d4bce36f2..b64d39f2c7b 100644--- a/lookbook/previews/open_project/common/submenu_component_preview.rb+++ b/lookbook/previews/open_project/common/submenu_component_preview.rb@@ -21,7 +21,7 @@ module OpenProjectdef with_create_buttonrender_with_template(template: "open_project/common/submenu_preview/playground",locals: { sidebar_menu_items: menu_items, searchable: true,- create_btn_options: { href: "/#", text: "User" } })+ create_btn_options: { href: "/#", module_key: "user" } })endprivatediff --git a/modules/calendar/app/controllers/calendar/menus_controller.rb b/modules/calendar/app/controllers/calendar/menus_controller.rbindex b32d394b53d..41da3240b9b 100644--- a/modules/calendar/app/controllers/calendar/menus_controller.rb+++ b/modules/calendar/app/controllers/calendar/menus_controller.rb@@ -33,7 +33,7 @@ module ::Calendardef show@submenu_menu_items = ::Calendar::Menu.new(project: @project, params:).menu_items@create_btn_options = if User.current.allowed_in_project?(:manage_calendars, @project)- { href: new_project_calendars_path(@project), text: I18n.t("label_calendar") }+ { href: new_project_calendars_path(@project), module_key: "calendar" }endrender layout: nildiff --git a/modules/team_planner/app/controllers/team_planner/menus_controller.rb b/modules/team_planner/app/controllers/team_planner/menus_controller.rbnew file mode 100644index 00000000000..e782768bac5--- /dev/null+++ b/modules/team_planner/app/controllers/team_planner/menus_controller.rb@@ -0,0 +1,43 @@+# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2010-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.+# +++module ::TeamPlanner+ class MenusController < ApplicationController+ before_action :find_project_by_project_id,+ :authorize++ def show+ @submenu_menu_items = ::TeamPlanner::Menu.new(project: @project, params:).menu_items+ if User.current.allowed_in_project?(:manage_team_planner, @project) &&+ EnterpriseToken.allows_to?(:team_planner_view)+ @create_btn_options = { href: new_project_team_planners_path(@project), module_key: "team_planner" }+ end++ render layout: nil+ end+ end+enddiff --git a/modules/team_planner/app/menus/team_planner/menu.rb b/modules/team_planner/app/menus/team_planner/menu.rbnew file mode 100644index 00000000000..7041404b287--- /dev/null+++ b/modules/team_planner/app/menus/team_planner/menu.rb@@ -0,0 +1,56 @@+# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2010-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.+# +++module TeamPlanner+ class Menu < Submenu+ attr_reader :view_type, :project++ def initialize(project: nil, params: nil)+ @view_type = "team_planner"+ @project = project+ @params = params++ super(view_type:, project:, params:)+ end++ def default_queries+ []+ end++ def selected?(query_params)+ query_params[:id].to_s == params[:id]+ end++ def query_params(id)+ { id: }+ end++ def query_path(query_params)+ project_team_planner_path(project, query_params)+ end+ end+enddiff --git a/modules/team_planner/app/views/team_planner/menus/_menu.html.erb b/modules/team_planner/app/views/team_planner/menus/_menu.html.erbnew file mode 100644index 00000000000..7ceb63595fb--- /dev/null+++ b/modules/team_planner/app/views/team_planner/menus/_menu.html.erb@@ -0,0 +1,5 @@+ <%= turbo_frame_tag "team_planner_sidemenu",+ src: menu_project_team_planners_path(@project, **params.permit(:id)),+ target: '_top',+ data: { turbo: false },+ loading: :lazy %>diff --git a/modules/team_planner/app/views/team_planner/menus/show.html.erb b/modules/team_planner/app/views/team_planner/menus/show.html.erbnew file mode 100644index 00000000000..7c6fb6985ae--- /dev/null+++ b/modules/team_planner/app/views/team_planner/menus/show.html.erb@@ -0,0 +1,5 @@+<%= turbo_frame_tag "team_planner_sidemenu" do %>+ <%= render OpenProject::Common::SubmenuComponent.new(sidebar_menu_items: @submenu_menu_items,+ searchable: true,+ create_btn_options: @create_btn_options) %>+<% end %>diff --git a/modules/team_planner/app/views/team_planner/team_planner/_menu.html.erb b/modules/team_planner/app/views/team_planner/team_planner/_menu.html.erbdeleted file mode 100644index fed603f4a41..00000000000--- a/modules/team_planner/app/views/team_planner/team_planner/_menu.html.erb+++ /dev/null@@ -1,7 +0,0 @@- <%=- angular_component_tag 'op-team-planner-sidemenu',- inputs: {- projectId: (@project ? @project.id.to_s : ''),- menuItems: [parent_name, name],- }- %>diff --git a/modules/team_planner/config/routes.rb b/modules/team_planner/config/routes.rbindex 2f694e15410..501607c86cc 100644--- a/modules/team_planner/config/routes.rb+++ b/modules/team_planner/config/routes.rb@@ -15,6 +15,7 @@ Rails.application.routes.draw doonly: %i[index destroy],as: :team_planners docollection do+ get "menu" => "team_planner/menus#show"get "/upsale", to: "team_planner/team_planner#upsale", as: :upsaleget "/new", to: "team_planner/team_planner#show", as: :newenddiff --git a/modules/team_planner/lib/open_project/team_planner/engine.rb b/modules/team_planner/lib/open_project/team_planner/engine.rbindex 2a853694ae2..422c42bafe8 100644--- a/modules/team_planner/lib/open_project/team_planner/engine.rb+++ b/modules/team_planner/lib/open_project/team_planner/engine.rb@@ -38,7 +38,8 @@ module OpenProject::TeamPlannersettings: {} doproject_module :team_planner_view, dependencies: :work_package_tracking, enterprise_feature: true dopermission :view_team_planner,- { "team_planner/team_planner": %i[index show upsale overview] },+ { "team_planner/team_planner": %i[index show upsale overview],+ "team_planner/menus": %i[show] },permissible_on: :project,dependencies: %i[view_work_packages],contract_actions: { team_planner: %i[read] }@@ -80,7 +81,7 @@ module OpenProject::TeamPlanner:team_planner_menu,{ controller: "/team_planner/team_planner", action: :index },parent: :team_planner_view,- partial: "team_planner/team_planner/menu",+ partial: "team_planner/menus/menu",last: true,caption: :"team_planner.label_team_planner_plural"diff --git a/modules/team_planner/spec/features/query_handling_spec.rb b/modules/team_planner/spec/features/query_handling_spec.rbindex 7388ee6f9f8..005c10402b8 100644--- a/modules/team_planner/spec/features/query_handling_spec.rb+++ b/modules/team_planner/spec/features/query_handling_spec.rb@@ -75,7 +75,7 @@ RSpec.describe "Team planner query handling", :js, with_ee: %i[team_planner_viewlet(:team_planner) { Pages::TeamPlanner.new project }let(:work_package_page) { Pages::WorkPackagesTable.new project }let(:query_title) { Components::WorkPackages::QueryTitle.new }- let(:query_menu) { Components::WorkPackages::QueryMenu.new }+ let(:query_menu) { Components::Submenu.new }let(:filters) { team_planner.filters }current_user { user }@@ -114,8 +114,8 @@ RSpec.describe "Team planner query handling", :js, with_ee: %i[team_planner_viewit "shows only team planner queries" do# Go to team planner where no query is shown, only the create option- query_menu.expect_no_menu_entry- expect(page).to have_test_selector("team-planner--create-button")+ query_menu.expect_no_items+ expect(page).to have_test_selector("team_planner--create-button")# Change filterfilters.open@@ -128,11 +128,11 @@ RSpec.describe "Team planner query handling", :js, with_ee: %i[team_planner_viewteam_planner.expect_and_dismiss_toaster(message: I18n.t("js.notice_successful_create"))# The saved query appears in the side menu...- query_menu.expect_menu_entry "I am your Query"+ query_menu.expect_item "I am your Query"# .. but not in the work packages modulework_package_page.visit!- query_menu.expect_menu_entry_not_visible "I am your Query"+ query_menu.expect_no_item "I am your Query"endit_behaves_like "module specific query view management" dodiff --git a/modules/team_planner/spec/features/team_planner_index_spec.rb b/modules/team_planner/spec/features/team_planner_index_spec.rbindex 067fbb09ec3..f06f50a88c4 100644--- a/modules/team_planner/spec/features/team_planner_index_spec.rb+++ b/modules/team_planner/spec/features/team_planner_index_spec.rb@@ -63,7 +63,7 @@ RSpec.describe "Team planner index", :js, :with_cuprite, with_ee: %i[team_planneendit "can create an action through the sidebar" do- find_test_selector("team-planner--create-button").click+ find_test_selector("team_planner--create-button").clickteam_planner.expect_no_toasterteam_planner.expect_titlediff --git a/modules/team_planner/spec/features/team_planner_menu_spec.rb b/modules/team_planner/spec/features/team_planner_menu_spec.rbindex 0732a737821..e7b61a15cab 100644--- a/modules/team_planner/spec/features/team_planner_menu_spec.rb+++ b/modules/team_planner/spec/features/team_planner_menu_spec.rb@@ -77,7 +77,7 @@ RSpec.describe "Team planner Menu Item", :js, :with_cuprite doclick_link "Team planners"end- expect(page).not_to have_test_selector("team-planner--create-button")+ expect(page).not_to have_test_selector("team_planner--create-button")endend@@ -89,7 +89,7 @@ RSpec.describe "Team planner Menu Item", :js, :with_cuprite doclick_link "Team planners"end- expect(page).not_to have_test_selector("team-planner--create-button")+ expect(page).not_to have_test_selector("team_planner--create-button")endendend@@ -105,7 +105,7 @@ RSpec.describe "Team planner Menu Item", :js, :with_cuprite doclick_link "Team planners"end- expect(page).not_to have_test_selector("team-planner--create-button")+ expect(page).not_to have_test_selector("team_planner--create-button")endend@@ -117,7 +117,7 @@ RSpec.describe "Team planner Menu Item", :js, :with_cuprite doclick_link "Team planners"end- expect(page).to have_test_selector("team-planner--create-button")+ expect(page).to have_test_selector("team_planner--create-button")endendenddiff --git a/spec/support/components/common/submenu.rb b/spec/support/components/common/submenu.rbindex 77c59af075d..f876bdf700f 100644--- a/spec/support/components/common/submenu.rb+++ b/spec/support/components/common/submenu.rb@@ -37,12 +37,13 @@ module Componentsselected_specifier = selected ? ".selected" : ":not(.selected)"expect(page).to have_css(".op-sidemenu--item-action#{selected_specifier}", text: name, visible:)+ # expect(page).to have_css("[data-test-selector='op-sidemenu--item-action']#{selected_specifier}", text: name, visible:)endenddef expect_no_item(name)within "#main-menu" do- expect(page).to have_no_css(".op-sidemenu--item-action", text: name)+ expect(page).not_to have_test_selector("op-sidemenu--item-action", text: name)endend@@ -52,6 +53,12 @@ module Componentsendend+ def expect_no_items+ within "#main-menu" do+ expect(page).not_to have_test_selector("op-sidemenu--item-action")+ end+ end+def search_for_item(name)within "#main-menu" dopage.find_test_selector("op-sidebar--search-input").set(name)diff --git a/spec/support/components/work_packages/query_menu.rb b/spec/support/components/work_packages/query_menu.rbindex 10f541c862b..a370d6bb68b 100644--- a/spec/support/components/work_packages/query_menu.rb+++ b/spec/support/components/work_packages/query_menu.rb@@ -69,10 +69,6 @@ module Componentsdef expect_menu_entry_not_visible(name)expect(page).to have_no_selector(autocompleter_item_selector, text: name)end-- def expect_no_menu_entry- expect(page).to have_no_selector(autocompleter_item_selector)- endendendend