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 url params service to use instead of router-based
Oliver Günther5d49462fb09a
diff --git a/frontend/src/app/core/url-params/url-params.service.ts b/frontend/src/app/core/url-params/url-params.service.tsnew file mode 100644index 00000000000..ba8061abd9e--- /dev/null+++ b/frontend/src/app/core/url-params/url-params.service.ts@@ -0,0 +1,44 @@+// -- copyright+// OpenProject is an open source project management software.+// Copyright (C) 2012-2024 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 { Injectable } from '@angular/core';++@Injectable({ providedIn: 'root' })+export class UrlParamsService {+ public get(key:string):string|null {+ return this.searchParams.get(key);+ }++ public has(key:string):boolean {+ return this.searchParams.has(key);+ }++ private get searchParams():URLSearchParams {+ return new URLSearchParams(window.location.search);+ }+}diff --git a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.ts b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.tsindex b0756f33e5c..f38b1b55350 100644--- a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.ts+++ b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.ts@@ -30,7 +30,6 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, OnInimport { I18nService } from 'core-app/core/i18n/i18n.service';import { filter, map } from 'rxjs/operators';import { StateService } from '@uirouter/angular';-import { UIRouterGlobals } from '@uirouter/core';import { IanCenterService } from 'core-app/features/in-app-notifications/center/state/ian-center.service';import {INotification,@@ -40,6 +39,7 @@ import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';import { IanBellService } from 'core-app/features/in-app-notifications/bell/state/ian-bell.service';import { imagePath } from 'core-app/shared/helpers/images/path-helper';+import { UrlParamsService } from 'core-app/core/url-params/url-params.service';@Component({templateUrl: './in-app-notification-center.component.html',@@ -99,7 +99,7 @@ export class InAppNotificationCenterComponent implements OnInit {},];- selectedFilter = this.reasonMenuItems.find((item) => item.key === this.uiRouterGlobals.params.name)?.title;+ selectedFilter = this.reasonMenuItems.find((item) => item.key === this.urlParams.get('name'))?.title;image = {no_notification: imagePath('notification-center/empty-state-no-notification.svg'),@@ -137,7 +137,7 @@ export class InAppNotificationCenterComponent implements OnInit {readonly I18n:I18nService,readonly storeService:IanCenterService,readonly bellService:IanBellService,- readonly uiRouterGlobals:UIRouterGlobals,+ readonly urlParams:UrlParamsService,readonly state:StateService,readonly apiV3:ApiV3Service,readonly pathService:PathHelperService,@@ -147,8 +147,8 @@ export class InAppNotificationCenterComponent implements OnInit {ngOnInit():void {this.storeService.setFacet('unread');this.storeService.setFilters({- filter: this.uiRouterGlobals.params.filter, // eslint-disable-line @typescript-eslint/no-unsafe-assignment- name: this.uiRouterGlobals.params.name, // eslint-disable-line @typescript-eslint/no-unsafe-assignment+ filter: this.urlParams.get('filter'),+ name: this.urlParams.get('name'),});}@@ -156,6 +156,6 @@ export class InAppNotificationCenterComponent implements OnInit {if (!hasNotifications) {return this.text.no_notification;}- return (this.uiRouterGlobals.params.filter === 'project' ? this.text.no_notification_with_current_filter_project : this.text.no_notification_with_current_filter);+ return (this.urlParams.get('filter') ? this.text.no_notification_with_current_filter_project : this.text.no_notification_with_current_filter);}}diff --git a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.tsindex a593a595b97..7eea38d17f5 100644--- a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts+++ b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts@@ -74,8 +74,8 @@ import { ApiV3ListFilter, ApiV3ListParameters } from 'core-app/core/apiv3/paths/import { FrameElement } from '@hotwired/turbo';export interface INotificationPageQueryParameters {- filter?:string;- name?:string;+ filter?:string|null;+ name?:string|null;}@Injectable({ providedIn: 'root' })diff --git a/frontend/src/global_styles/openproject/_index.sass b/frontend/src/global_styles/openproject/_index.sassindex 5f8f22afa63..85db8b17cf3 100644--- a/frontend/src/global_styles/openproject/_index.sass+++ b/frontend/src/global_styles/openproject/_index.sass@@ -2,6 +2,7 @@@import announcements@import functions@import homescreen+@import notifications@import generic@import basediff --git a/frontend/src/global_styles/openproject/_notifications.sass b/frontend/src/global_styles/openproject/_notifications.sassnew file mode 100644index 00000000000..5e2917c9094--- /dev/null+++ b/frontend/src/global_styles/openproject/_notifications.sass@@ -0,0 +1,31 @@+//-- copyright+// OpenProject is an open source project management software.+// Copyright (C) 2012-2024 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.+//++++.controller-notifications+ #content+ height: 100%