From bc5d508b7a170b1fed01dc18a554574c1d5367b7 Mon Sep 17 00:00:00 2001 From: Dombi Attila <83396+dombesz@users.noreply.github.com> Date: Wed, 11 Dec 2024 17:16:50 +0200 Subject: [PATCH] [#55024] Remove bugfix that is not required anymore Since we switched to turbo drive, this bug is not happening anymore, so the extra stimulus controller and the custom angular event can be removed. For more details about the bug see https://community.openproject.org/wp/55024 --- .../app/core/routing/openproject.routes.ts | 23 -------- .../dynamic/overview-header.controller.ts | 52 ------------------- .../views/overviews/overviews/show.html.erb | 8 +-- 3 files changed, 1 insertion(+), 82 deletions(-) delete mode 100644 frontend/src/stimulus/controllers/dynamic/overview-header.controller.ts diff --git a/frontend/src/app/core/routing/openproject.routes.ts b/frontend/src/app/core/routing/openproject.routes.ts index d1f3cf49cf02..ebb4709e386d 100644 --- a/frontend/src/app/core/routing/openproject.routes.ts +++ b/frontend/src/app/core/routing/openproject.routes.ts @@ -195,29 +195,6 @@ export function initializeUiRouterListeners(injector:Injector) { (transition) => redirectToMobileAlternative(transition), ); - // Fire an event when navigating to a different module. This event then can be detected in - // the non-angular parts of the application. A usecase for this can be found in the - // overview-header.controllers.ts - // See https://community.openproject.org/wp/55024 for details. - $transitions.onBefore( - {}, - (transition:Transition) => { - const fromState = transition.from(); - const toState = transition.to(); - if ( - !!fromState.name - && !!toState.name - && fromState.name?.split('.')[0] !== toState.name?.split('.')[0] - ) { - window.dispatchEvent(new CustomEvent('angular:router:module-changed', { - detail: toState.name?.split('.')[0], - })); - } - - return true; - }, - ); - // Apply classes from bodyClasses in each state definition // This was defined as onEnter, onExit functions in each state before // but since AOT doesn't allow anonymous functions, we can't re-use them now. diff --git a/frontend/src/stimulus/controllers/dynamic/overview-header.controller.ts b/frontend/src/stimulus/controllers/dynamic/overview-header.controller.ts deleted file mode 100644 index c8c912e59055..000000000000 --- a/frontend/src/stimulus/controllers/dynamic/overview-header.controller.ts +++ /dev/null @@ -1,52 +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 { Controller } from '@hotwired/stimulus'; - -export default class OverviewHeaderController extends Controller { - connect() { - window.addEventListener('angular:router:module-changed', this.toggleHeaderVisibility); - } - - disconnect() { - window.removeEventListener('angular:router:module-changed', this.toggleHeaderVisibility); - } - - toggleHeaderVisibility = (event:CustomEvent) => { - const name = event.detail as string; - const element = this.element as HTMLElement; - - if (name === 'overview') { - element.classList.remove('d-none'); - } else { - element.classList.add('d-none'); - } - }; -} diff --git a/modules/overviews/app/views/overviews/overviews/show.html.erb b/modules/overviews/app/views/overviews/overviews/show.html.erb index bd1d6114ccb7..cce3768ff982 100644 --- a/modules/overviews/app/views/overviews/overviews/show.html.erb +++ b/modules/overviews/app/views/overviews/overviews/show.html.erb @@ -3,13 +3,7 @@ <% end -%> <%= - render(Primer::OpenProject::PageHeader.new( - data: { - 'controller': 'overview-header', - 'application-target': 'dynamic', - turbo: true - } - )) do |header| + render(Primer::OpenProject::PageHeader.new) do |header| header.with_title(variant: :medium) { t("overviews.label") } header.with_breadcrumbs( [