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
Move toggleButton for menu into the sidebar
Henriette Dargebb66d0d5b484
diff --git a/app/components/_index.sass b/app/components/_index.sassindex c8a5624de14..a4f4cfbe6b6 100644--- a/app/components/_index.sass+++ b/app/components/_index.sass@@ -6,6 +6,7 @@@import "open_project/common/attribute_help_text_component"@import "open_project/common/attribute_label_component"@import "open_project/common/submenu_component"+@import "open_project/common/main_menu_toggler_component"@import "projects/row_component"@import "projects/phases/hover_card_component"@import "shares/invite_user_form_component"diff --git a/app/components/open_project/common/main_menu_toggler_component.rb b/app/components/open_project/common/main_menu_toggler_component.rbnew file mode 100644index 00000000000..12ac73be3c9--- /dev/null+++ b/app/components/open_project/common/main_menu_toggler_component.rb@@ -0,0 +1,76 @@+# frozen_string_literal: true++# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) 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 OpenProject+ module Common+ class MainMenuTogglerComponent < ApplicationComponent+ def initialize(opened:)+ super++ @opened = opened+ end++ def icon+ @opened ? "sidebar-expand" : :"sidebar-collapse"+ end++ def id+ "menu-toggler--#{@opened ? 'opener' : 'closer'}"+ end++ def aria_label+ @opened ? I18n.t("js.label_hide_project_menu") : I18n.t("js.label_expand_project_menu")+ end++ def scheme+ :invisible+ end++ def size+ @opened ? :medium : :small+ end++ def data+ {+ action: "click->menus--main-toggler#toggleNavigation"+ }+ end++ def call+ render(Primer::Beta::IconButton.new(icon:,+ id:,+ aria: { label: aria_label },+ scheme:,+ size:,+ data:))+ end+ end+ end+enddiff --git a/app/components/open_project/common/main_menu_toggler_component.sass b/app/components/open_project/common/main_menu_toggler_component.sassnew file mode 100644index 00000000000..fc320414522--- /dev/null+++ b/app/components/open_project/common/main_menu_toggler_component.sass@@ -0,0 +1,48 @@+//-- copyright+// OpenProject is an open source project management software.+// Copyright (C) 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.+//++++#menu-toggler--closer+ position: absolute+ top: 14px+ left: 11px++#menu-toggler--opener+ margin-right: 5px++ .Button-visual+ color: var(--main-menu-font-color)++#wrapper+ .hidden-navigation+ // TODO: Add angular breadcrumb selector once it exists+ .PageHeader-contextBar+ margin-left: 30px++ &:not(.hidden-navigation)+ #menu-toggler--closer+ display: nonediff --git a/app/views/layouts/base.html.erb b/app/views/layouts/base.html.erbindex 522b1f3242e..001ea4ba3b2 100644--- a/app/views/layouts/base.html.erb+++ b/app/views/layouts/base.html.erb@@ -74,7 +74,6 @@ See COPYRIGHT and LICENSE files for more details.<h1 class="hidden-for-sighted"><%= t(:label_top_menu) %></h1>- <opce-main-menu-toggle></opce-main-menu-toggle><a href="" class="hidden-for-sighted skip-navigation-link"id="skip-navigation--content"aria-label="<%= I18n.t('js.work_packages.jump_marks.label_content') %>">@@ -92,7 +91,9 @@ See COPYRIGHT and LICENSE files for more details.</header><% end %><div id="main"- class="<%= initial_classes %>">+ class="<%= initial_classes %>"+ data-controller="menus--main-toggler"+ data-application-target="dynamic"><% if (side_displayed && show_decoration) %><divid="main-menu"@@ -102,7 +103,15 @@ See COPYRIGHT and LICENSE files for more details.<h1 class="hidden-for-sighted"><%= t(:label_main_menu) %></h1><opce-main-menu-resizer></opce-main-menu-resizer><div id="menu-sidebar">- <%= render_projects_top_menu_node %>+ <%= render(Primer::OpenProject::FlexLayout.new(align_items: :center, mt: 2)) do |flex|+ flex.with_column(flex: :auto, overflow: :hidden) do+ render_projects_top_menu_node+ end+ flex.with_column do+ render(OpenProject::Common::MainMenuTogglerComponent.new(opened: true))+ end+ end %>+<%= render(Primer::BaseComponent.new(tag: :hr,classes: "main-menu--projects-divider",role: :presentation,@@ -144,6 +153,7 @@ See COPYRIGHT and LICENSE files for more details.<% end %><div id="content-body">+ <%= render(OpenProject::Common::MainMenuTogglerComponent.new(opened: false)) %><%= content_for :content_body %><% unless local_assigns[:no_layout_yield] %><%= yield %>diff --git a/config/locales/js-en.yml b/config/locales/js-en.ymlindex d60b42ffb33..84b1e790861 100644--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@ -373,6 +373,7 @@ en:label_added_time_by: 'Added by <a href="%{authorLink}">%{author}</a> at %{age}'label_ago: "days ago"label_all: "all"+ label_all_projects: "All projects"label_all_uppercase: "All"label_all_work_packages: "all work packages"label_and: "and"@@ -482,7 +483,6 @@ en:label_repository_plural: "Repositories"label_save_as: "Save as"label_search_columns: "Search a column"- label_select_project: "Select a project"label_select_watcher: "Select a watcher..."label_selected_filter_list: "Selected filters"label_show_attributes: "Show all attributes"diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.tsindex 580ecc9344e..adc59154e19 100644--- a/frontend/src/app/app.module.ts+++ b/frontend/src/app/app.module.ts@@ -68,7 +68,6 @@ import {RevitAddInSettingsButtonService,} from 'core-app/features/bim/revit_add_in/revit-add-in-settings-button.service';import { OpenprojectEnterpriseModule } from 'core-app/features/enterprise/openproject-enterprise.module';-import { MainMenuToggleComponent } from 'core-app/core/main-menu/main-menu-toggle.component';import { ConfirmDialogService } from 'core-app/shared/components/modals/confirm-dialog/confirm-dialog.service';import { ConfirmDialogModalComponent } from 'core-app/shared/components/modals/confirm-dialog/confirm-dialog.modal';import { DynamicContentModalComponent } from 'core-app/shared/components/modals/modal-wrapper/dynamic-content.modal';@@ -354,7 +353,6 @@ export function initializeServices(injector:Injector) {// Main menuMainMenuResizerComponent,- MainMenuToggleComponent,// Project selectorOpHeaderProjectSelectComponent,@@ -437,7 +435,6 @@ export class OpenProjectModule implements DoBootstrap {registerCustomElement('opce-header-project-select', OpHeaderProjectSelectComponent, { injector });registerCustomElement('opce-no-results', NoResultsComponent, { injector });registerCustomElement('opce-non-working-days-list', OpNonWorkingDaysListComponent, { injector });- registerCustomElement('opce-main-menu-toggle', MainMenuToggleComponent, { injector });registerCustomElement('opce-main-menu-resizer', MainMenuResizerComponent, { injector });registerCustomElement('opce-global-search-title', GlobalSearchTitleComponent, { injector });registerCustomElement('opce-persistent-toggle', PersistentToggleComponent, { injector });diff --git a/frontend/src/app/core/main-menu/main-menu-toggle.component.html b/frontend/src/app/core/main-menu/main-menu-toggle.component.htmldeleted file mode 100644index bd9c72ba8d2..00000000000--- a/frontend/src/app/core/main-menu/main-menu-toggle.component.html+++ /dev/null@@ -1,11 +0,0 @@-<button- class="op-app-menu--item-action"- id="main-menu-toggle"- aria-haspopup="true"- type="button"- [attr.title]="toggleTitle"- (click)="toggle($event)"->- <op-icon class="icon-hamburger" aria-hidden="true"></op-icon>- <op-icon class="icon-close" aria-hidden="true"></op-icon>-</button>diff --git a/frontend/src/app/core/main-menu/main-menu-toggle.component.ts b/frontend/src/app/core/main-menu/main-menu-toggle.component.tsdeleted file mode 100644index ad12425f592..00000000000--- a/frontend/src/app/core/main-menu/main-menu-toggle.component.ts+++ /dev/null@@ -1,78 +0,0 @@-//-- copyright-// OpenProject is an open source project management software.-// Copyright (C) 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.-//++--import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Injector, OnInit } from '@angular/core';-import { distinctUntilChanged } from 'rxjs/operators';-import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';-import { InjectField } from 'core-app/shared/helpers/angular/inject-field.decorator';-import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';-import { MainMenuToggleService } from './main-menu-toggle.service';-import { TopMenuService } from 'core-app/core/top-menu/top-menu.service';--@Component({- selector: 'opce-main-menu-toggle',- changeDetection: ChangeDetectionStrategy.OnPush,- // eslint-disable-next-line @angular-eslint/no-host-metadata-property- host: {- class: 'op-app-menu op-main-menu-toggle',- },- templateUrl: './main-menu-toggle.component.html',-})-export class MainMenuToggleComponent extends UntilDestroyedMixin implements OnInit {- toggleTitle = '';-- @InjectField() currentProject:CurrentProjectService;-- constructor(- readonly topMenu:TopMenuService,- readonly toggleService:MainMenuToggleService,- readonly cdRef:ChangeDetectorRef,- readonly injector:Injector,- ) {- super();- }-- ngOnInit():void {- this.toggleService.initializeMenu();-- this.toggleService.titleData$- .pipe(- distinctUntilChanged(),- this.untilDestroyed(),- )- .subscribe((setToggleTitle) => {- this.toggleTitle = setToggleTitle;- this.cdRef.detectChanges();- });- }-- toggle(event:Event):void {- this.toggleService.toggleNavigation(event);- this.topMenu.close();- }-}diff --git a/frontend/src/app/core/main-menu/main-menu-toggle.service.ts b/frontend/src/app/core/main-menu/main-menu-toggle.service.tsindex 3c2904e769d..ee0ca792e87 100644--- a/frontend/src/app/core/main-menu/main-menu-toggle.service.ts+++ b/frontend/src/app/core/main-menu/main-menu-toggle.service.ts@@ -55,11 +55,6 @@ export class MainMenuToggleService {private mainMenu = jQuery('#main-menu')[0]; // main menu, containing sidebar and resizer- // Title needs to be sync in main-menu-toggle.component.ts and main-menu-resizer.component.ts- private titleData = new BehaviorSubject<string>('');-- public titleData$ = this.titleData.asObservable();-// Notes all changes of the menu size (currently needed in wp-resizer.component.ts)private changeData = new BehaviorSubject<any>({});@@ -166,7 +161,6 @@ export class MainMenuToggleService {// Check if menu is open or closed and apply CSS class if neededthis.toggleClassHidden();this.snapBack();- this.setToggleTitle();// Save the width if it's openif (this.elementWidth > 0) {@@ -190,15 +184,6 @@ export class MainMenuToggleService {}}- private setToggleTitle():void {- if (this.showNavigation) {- this.toggleTitle = this.I18n.t('js.label_hide_project_menu');- } else {- this.toggleTitle = this.I18n.t('js.label_expand_project_menu');- }- this.titleData.next(this.toggleTitle);- }-private toggleClassHidden():void {const isHidden = this.elementWidth < this.elementMinWidth;const hideElements = jQuery('.can-hide-navigation');diff --git a/frontend/src/app/shared/components/header-project-select/header-project-select.component.sass b/frontend/src/app/shared/components/header-project-select/header-project-select.component.sassindex 03183c041cd..8e2505f044c 100644--- a/frontend/src/app/shared/components/header-project-select/header-project-select.component.sass+++ b/frontend/src/app/shared/components/header-project-select/header-project-select.component.sass@@ -1,5 +1,4 @@.op-project-select- margin-top: 0.75remflex: 1overflow: hiddendiff --git a/frontend/src/app/shared/components/header-project-select/header-project-select.component.ts b/frontend/src/app/shared/components/header-project-select/header-project-select.component.tsindex 822b0c77eb4..bd10b513016 100644--- a/frontend/src/app/shared/components/header-project-select/header-project-select.component.ts+++ b/frontend/src/app/shared/components/header-project-select/header-project-select.component.ts@@ -129,7 +129,7 @@ export class OpHeaderProjectSelectComponent extends UntilDestroyedMixin implemensingular: this.I18n.t('js.label_project'),plural: this.I18n.t('js.label_project_plural'),list: this.I18n.t('js.label_project_list'),- select: this.I18n.t('js.label_select_project'),+ select: this.I18n.t('js.label_all_projects'),},search_placeholder: this.I18n.t('js.include_projects.search_placeholder'),no_results: this.I18n.t('js.include_projects.no_results'),diff --git a/frontend/src/app/shared/components/resizer/resizer/main-menu-resizer.component.ts b/frontend/src/app/shared/components/resizer/resizer/main-menu-resizer.component.tsindex 398bc6cf625..bf99934b4a7 100644--- a/frontend/src/app/shared/components/resizer/resizer/main-menu-resizer.component.ts+++ b/frontend/src/app/shared/components/resizer/resizer/main-menu-resizer.component.ts@@ -27,13 +27,10 @@//++import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, OnInit } from '@angular/core';-import { distinctUntilChanged } from 'rxjs/operators';-import { ResizeDelta } from 'core-app/shared/components/resizer/resizer.component';import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';import { MainMenuToggleService } from 'core-app/core/main-menu/main-menu-toggle.service';-@Component({selector: 'opce-main-menu-resizer',changeDetection: ChangeDetectionStrategy.OnPush,@@ -78,16 +75,6 @@ export class MainMenuResizerComponent extends UntilDestroyedMixin implements OnI}ngOnInit() {- this.toggleService.titleData$- .pipe(- distinctUntilChanged(),- this.untilDestroyed(),- )- .subscribe((setToggleTitle) => {- this.toggleTitle = setToggleTitle;- this.cdRef.detectChanges();- });-this.resizeEvent = 'main-menu-resize';}diff --git a/frontend/src/global_styles/layout/_base.sass b/frontend/src/global_styles/layout/_base.sassindex c6465b61d7b..1f4e0e20933 100644--- a/frontend/src/global_styles/layout/_base.sass+++ b/frontend/src/global_styles/layout/_base.sass@@ -83,7 +83,7 @@// Because of those requirements, the #content element cannot take care of the paddings.// Instead the children elements have to do that themselves depending on which elements are present-$top-space: 10px+$top-space: 18px$right-space: 16px$bottom-space: 10px$left-space: 16pxdiff --git a/frontend/src/global_styles/layout/_main_menu_mobile.sass b/frontend/src/global_styles/layout/_main_menu_mobile.sassindex aa3e684b008..61929a3de71 100644--- a/frontend/src/global_styles/layout/_main_menu_mobile.sass+++ b/frontend/src/global_styles/layout/_main_menu_mobile.sass@@ -34,21 +34,9 @@box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.15)min-width: 75vw- #main-menu-toggle- .icon-hamburger- display: none- .icon-close- display: block-.hidden-navigation.main-menudisplay: none- #main-menu-toggle- .icon-hamburger- display: block- .icon-close- display: none-.main-item-wrapper awidth: 100%diff --git a/frontend/src/stimulus/controllers/dynamic/menus/main-toggler.controller.ts b/frontend/src/stimulus/controllers/dynamic/menus/main-toggler.controller.tsnew file mode 100644index 00000000000..aa23e675041--- /dev/null+++ b/frontend/src/stimulus/controllers/dynamic/menus/main-toggler.controller.ts@@ -0,0 +1,19 @@+import { Controller } from '@hotwired/stimulus';+import { MainMenuToggleService } from 'core-app/core/main-menu/main-menu-toggle.service';++export default class MainTogglerController extends Controller {+ mainMenuService:MainMenuToggleService;++ initialize() {+ void window.OpenProject.getPluginContext()+ .then((pluginContext) => pluginContext.injector.get(MainMenuToggleService))+ .then((service) => {+ this.mainMenuService = service;+ this.mainMenuService.initializeMenu();+ });+ }++ toggleNavigation(e:Event) {+ this.mainMenuService.toggleNavigation(e);+ }+}diff --git a/lib/redmine/menu_manager/top_menu/projects_menu.rb b/lib/redmine/menu_manager/top_menu/projects_menu.rbindex 6673fb4cdbc..2f140585de4 100644--- a/lib/redmine/menu_manager/top_menu/projects_menu.rb+++ b/lib/redmine/menu_manager/top_menu/projects_menu.rb@@ -29,7 +29,7 @@module Redmine::MenuManager::TopMenu::ProjectsMenudef render_projects_top_menu_nodereturn "" if User.current.anonymous? and Setting.login_required?- return "" if User.current.anonymous? and User.current.number_of_known_projects.zero?+ return "" if User.current.anonymous? and User.current.number_of_known_projects.zero? #TODOrender_projects_dropdownenddiff --git a/spec/features/work_packages/cancel_editing_spec.rb b/spec/features/work_packages/cancel_editing_spec.rbindex f185d886afe..06945c6fb8f 100644--- a/spec/features/work_packages/cancel_editing_spec.rb+++ b/spec/features/work_packages/cancel_editing_spec.rb@@ -72,7 +72,7 @@ RSpec.describe "Cancel editing work package", :js, :selenium dofind(".op-logo--link").clickend- expect(page).to have_css("#projects-menu", text: "Select a project")+ expect(page).to have_css("#projects-menu", text: "All projects")endit "does not show an alert when moving to other pages" do