Skip to content

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

Create separate route and page for IAN center

Oliver Günther8fb312cfb844
diff --git a/config/routes.rb b/config/routes.rb
index a85a235c31b..37b08c74374 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -575,6 +575,10 @@ OpenProject::Application.routes.draw do
root to: 'account#login'
+ scope :notifications do
+ get '/', to: 'angular#empty_layout'
+ end
+
# Development route for styleguide
if Rails.env.development?
get '/styleguide' => redirect('/assets/styleguide.html')
diff --git a/frontend/src/app/core/path-helper/path-helper.service.ts b/frontend/src/app/core/path-helper/path-helper.service.ts
index 4cae55e4ec1..fbf6d188a63 100644
--- a/frontend/src/app/core/path-helper/path-helper.service.ts
+++ b/frontend/src/app/core/path-helper/path-helper.service.ts
@@ -157,6 +157,10 @@ export class PathHelperService {
return `${this.staticBase}/my/page`;
}
+ public myNotificationsSettingsPath() {
+ return `${this.staticBase}/my/notifications`;
+ }
+
public newsPath(newsId:string) {
return `${this.staticBase}/news/${newsId}`;
}
diff --git a/frontend/src/app/core/routing/openproject.routes.ts b/frontend/src/app/core/routing/openproject.routes.ts
index d94d3b88a7a..cbd2a19285c 100644
--- a/frontend/src/app/core/routing/openproject.routes.ts
+++ b/frontend/src/app/core/routing/openproject.routes.ts
@@ -37,6 +37,7 @@ import { Ng2StateDeclaration, StatesModule } from '@uirouter/angular';
import { appBaseSelector, ApplicationBaseComponent } from 'core-app/core/routing/base/application-base.component';
import { BackRoutingService } from 'core-app/features/work-packages/components/back-routing/back-routing.service';
import { MY_ACCOUNT_LAZY_ROUTES } from 'core-app/features/user-preferences/user-preferences.lazy-routes';
+import { IAN_LAZY_ROUTES } from "core-app/features/in-app-notifications/in-app-notifications.lazy-routes";
export const OPENPROJECT_ROUTES:Ng2StateDeclaration[] = [
{
@@ -114,6 +115,7 @@ export const OPENPROJECT_ROUTES:Ng2StateDeclaration[] = [
loadChildren: () => import('../../features/projects/openproject-projects.module').then((m) => m.OpenprojectProjectsModule),
},
...MY_ACCOUNT_LAZY_ROUTES,
+ ...IAN_LAZY_ROUTES,
];
/**
diff --git a/frontend/src/app/features/in-app-notifications/bell/in-app-notification-bell.component.html b/frontend/src/app/features/in-app-notifications/bell/in-app-notification-bell.component.html
index 1cc227eb5cf..e01ff12a86e 100644
--- a/frontend/src/app/features/in-app-notifications/bell/in-app-notification-bell.component.html
+++ b/frontend/src/app/features/in-app-notifications/bell/in-app-notification-bell.component.html
@@ -1,7 +1,6 @@
-<button
- type="button"
+<a
class="op-ian-bell op-app-menu--item-action"
- (click)="openCenter($event)"
+ uiSref="notifications"
>
<op-icon icon-classes="icon-bell">
</op-icon>
@@ -13,4 +12,4 @@
[textContent]="unreadCount > 99 ? '' : unreadCount">
</span>
</ng-container>
-</button>
\ No newline at end of file
+</a>
\ No newline at end of file
diff --git a/frontend/src/app/features/in-app-notifications/bell/in-app-notification-bell.component.ts b/frontend/src/app/features/in-app-notifications/bell/in-app-notification-bell.component.ts
index fd5789d2f06..aece1ea9206 100644
--- a/frontend/src/app/features/in-app-notifications/bell/in-app-notification-bell.component.ts
+++ b/frontend/src/app/features/in-app-notifications/bell/in-app-notification-bell.component.ts
@@ -33,9 +33,4 @@ export class InAppNotificationBellComponent {
readonly activeWindow:ActiveWindowService,
readonly modalService:OpModalService) {
}
-
- openCenter(event:MouseEvent) {
- this.modalService.show(InAppNotificationCenterComponent, 'global');
- event.preventDefault();
- }
}
diff --git a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.html b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.html
index 6b8cbab0a61..5c5487f9694 100644
--- a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.html
+++ b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.html
@@ -1,80 +1,35 @@
-<div
- class="op-modal op-modal_fullscreen"
->
- <op-modal-header (close)="closeMe($event)">{{text.title}}</op-modal-header>
-
- <div class="op-modal--body op-ian-center">
- <div class="toolbar-container">
- <div class="toolbar">
- <div class="title-container">
- </div>
-
- <ul class="toolbar-items">
-
- <li class="toolbar-item form--field-inline-buttons-container">
- <ng-container *ngFor="let facet of facets">
- <button
- type="button"
- class="button form--field-inline-button"
- [class.-active]="facet === (activeFacet$ | async)"
- (click)="activateFacet(facet)"
- >
- <span
- class="button--text"
- [textContent]="text.facets[facet]"
- >
- </span>
- </button>
- </ng-container>
- </li>
- <li class="toolbar-item">
- <button
- type="button"
- class="button"
- (click)="markAllRead()"
- >
- <op-icon icon-classes="button--icon icon-yes">
- </op-icon>
- <span
- class="button--text"
- [textContent]="text.mark_all_read"
- >
- </span>
- </button>
- </li>
- </ul>
- </div>
- </div>
+<div class="op-ian-center">
+ <op-ian-center-toolbar class="op-ian-center--toolbar"></op-ian-center-toolbar>
+ <div class="op-ian-center--content">
<ng-container *ngIf="(hasNotifications$ | async) as notifications; else noResults">
<cdk-virtual-scroll-viewport
- itemSize="50"
- class="op-ian-center--viewport"
+ itemSize="50"
+ class="op-ian-center--viewport"
>
<op-in-app-notification-entry
- *cdkVirtualFor="let item of notifications$ | async; templateCacheSize: 0"
- class="op-ian-center--entry"
- [notification]="item"
- (resourceLinkClicked)="closeMe()"
+ *cdkVirtualFor="let item of notifications$ | async; templateCacheSize: 0"
+ class="op-ian-center--entry"
+ [notification]="item"
></op-in-app-notification-entry>
</cdk-virtual-scroll-viewport>
</ng-container>
-
<ng-template #noResults>
<div class="generic-table--no-results-container">
<span
- class="generic-table--no-results-title"
+ class="generic-table--no-results-title"
>
<op-icon icon-classes="icon-info1"></op-icon>
{{ noResultText$ | async }}
</span>
</div>
</ng-template>
-
+ </div>
+ <div class="op-ian-center--footer">
<p
- class="op-ian-center--max-warning"
- *ngIf="hasMoreThanPageSize$ | async"
- [textContent]="totalCountWarning()">
+ class="op-ian-center--max-warning"
+ *ngIf="hasMoreThanPageSize$ | async"
+ [textContent]="totalCountWarning()">
</p>
</div>
</div>
diff --git a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.sass b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.sass
index e1a43e7336b..f557504d009 100644
--- a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.sass
+++ b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.sass
@@ -1,17 +1,20 @@
.op-ian-center
- //grid-template-columns: 1fr 3fr
- //grid-template-areas: "filters entries"
+ display: grid
+ grid-template-rows: auto 100%
+ grid-template-areas: "toolbar" "content" "footer"
- &--filters
- grid-area: filters
+ &--toolbar
+ grid-area: toolbar
- &--viewport
- grid-area: entries
- flex: 1
+ &--content
+ grid-area: content
&--entries
list-style: none
+ &--footer
+ grid-area: footer
+
&--entry
display: list-item
@@ -20,8 +23,8 @@
text-align: center
font-style: italic
-:host
- .-browser-safari &
- // Because of Safari's viewport bug, the address bar overlaps content with height: 100vh
- // Check #38082 before changing it
- height: 100%
+ :host
+ .-browser-safari &
+ // Because of Safari's viewport bug, the address bar overlaps content with height: 100vh
+ // Check #38082 before changing it
+ height: 100%
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.ts
index 4115b2c56c7..dbd529cc8d8 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
@@ -3,12 +3,8 @@ import {
ChangeDetectorRef,
Component,
ElementRef,
- Inject,
OnInit,
} from '@angular/core';
-import { OpModalComponent } from 'core-app/shared/components/modal/modal.component';
-import { OpModalLocalsToken } from 'core-app/shared/components/modal/modal.service';
-import { OpModalLocalsMap } from 'core-app/shared/components/modal/modal.types';
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { InAppNotificationsQuery } from 'core-app/features/in-app-notifications/store/in-app-notifications.query';
import { InAppNotificationsService } from 'core-app/features/in-app-notifications/store/in-app-notifications.service';
@@ -21,7 +17,7 @@ import { map } from 'rxjs/operators';
styleUrls: ['./in-app-notification-center.component.sass'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
-export class InAppNotificationCenterComponent extends OpModalComponent implements OnInit {
+export class InAppNotificationCenterComponent implements OnInit {
activeFacet$ = this.ianQuery.activeFacet$;
notifications$ = this.ianQuery.selectAll();
@@ -44,43 +40,26 @@ export class InAppNotificationCenterComponent extends OpModalComponent implement
text = {
title: this.I18n.t('js.notifications.title'),
- mark_all_read: this.I18n.t('js.notifications.center.mark_all_read'),
button_close: this.I18n.t('js.button_close'),
no_results: {
unread: this.I18n.t('js.notifications.no_unread'),
all: this.I18n.t('js.notice_no_results_to_display'),
},
- facets: {
- unread: this.I18n.t('js.notifications.facets.unread'),
- all: this.I18n.t('js.notifications.facets.all'),
- },
};
constructor(
- @Inject(OpModalLocalsToken) public locals:OpModalLocalsMap,
readonly cdRef:ChangeDetectorRef,
readonly elementRef:ElementRef,
readonly I18n:I18nService,
readonly ianService:InAppNotificationsService,
readonly ianQuery:InAppNotificationsQuery,
) {
- super(locals, cdRef, elementRef);
}
ngOnInit():void {
this.ianService.get();
}
- markAllRead():void {
- this.ianService.markAllRead();
- this.closeMe();
- }
-
- activateFacet(facet:string):void {
- this.ianService.setActiveFacet(facet);
- this.ianService.get();
- }
-
totalCountWarning():string {
const state = this.ianQuery.getValue();
diff --git a/frontend/src/app/features/in-app-notifications/center/toolbar/in-app-notification-toolbar.component.html b/frontend/src/app/features/in-app-notifications/center/toolbar/in-app-notification-toolbar.component.html
new file mode 100644
index 00000000000..80c65fdec29
--- /dev/null
+++ b/frontend/src/app/features/in-app-notifications/center/toolbar/in-app-notification-toolbar.component.html
@@ -0,0 +1,56 @@
+<div class="toolbar-container">
+ <div class="toolbar">
+ <div class="title-container">
+ <h2 [textContent]="text.title"></h2>
+ </div>
+ <ul class="toolbar-items">
+ <li class="toolbar-item form--field-inline-buttons-container">
+ <ng-container *ngFor="let facet of availableFacets">
+ <button
+ type="button"
+ class="button form--field-inline-button"
+ [class.-active]="facet === (activeFacet$ | async)"
+ (click)="activateFacet(facet)"
+ >
+ <span
+ class="button--text"
+ [textContent]="text.facets[facet]"
+ >
+ </span>
+ </button>
+ </ng-container>
+ </li>
+ <li class="toolbar-item">
+ <button
+ type="button"
+ class="button"
+ (click)="markAllRead()"
+ >
+ <op-icon icon-classes="button--icon icon-yes">
+ </op-icon>
+ <span
+ class="button--text"
+ [textContent]="text.mark_all_read"
+ >
+ </span>
+ </button>
+ </li>
+
+ <li class="toolbar-item">
+ <a
+ class="button"
+ [href]="myNotificationSettingsLink"
+ target="_blank"
+ >
+ <op-icon icon-classes="button--icon icon-settings">
+ </op-icon>
+ <span
+ class="button--text"
+ [textContent]="text.my_settings"
+ >
+ </span>
+ </a>
+ </li>
+ </ul>
+ </div>
+</div>
diff --git a/frontend/src/app/features/in-app-notifications/center/toolbar/in-app-notification-toolbar.component.ts b/frontend/src/app/features/in-app-notifications/center/toolbar/in-app-notification-toolbar.component.ts
new file mode 100644
index 00000000000..5dc7ec38d6f
--- /dev/null
+++ b/frontend/src/app/features/in-app-notifications/center/toolbar/in-app-notification-toolbar.component.ts
@@ -0,0 +1,49 @@
+import {
+ ChangeDetectionStrategy,
+ Component,
+} from '@angular/core';
+import { I18nService } from 'core-app/core/i18n/i18n.service';
+import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';
+import { InAppNotificationsQuery } from 'core-app/features/in-app-notifications/store/in-app-notifications.query';
+import { InAppNotificationsService } from 'core-app/features/in-app-notifications/store/in-app-notifications.service';
+import { IAN_FACETS } from 'core-app/features/in-app-notifications/store/in-app-notification.model';
+
+@Component({
+ selector: 'op-ian-center-toolbar',
+ templateUrl: './in-app-notification-toolbar.component.html',
+ changeDetection: ChangeDetectionStrategy.OnPush,
+})
+export class InAppNotificationToolbarComponent {
+ activeFacet$ = this.ianQuery.activeFacet$
+
+ text = {
+ title: this.I18n.t('js.notifications.title'),
+ my_settings: this.I18n.t('js.notifications.settings.title'),
+ mark_all_read: this.I18n.t('js.notifications.center.mark_all_read'),
+ facets: {
+ unread: this.I18n.t('js.notifications.facets.unread'),
+ all: this.I18n.t('js.notifications.facets.all'),
+ },
+ };
+
+ myNotificationSettingsLink = this.pathHelper.myNotificationsSettingsPath();
+
+ availableFacets = IAN_FACETS;
+
+ constructor(
+ private I18n:I18nService,
+ private pathHelper:PathHelperService,
+ private ianQuery:InAppNotificationsQuery,
+ private ianService:InAppNotificationsService,
+ ) {
+ }
+
+ markAllRead():void {
+ this.ianService.markAllRead();
+ }
+
+ activateFacet(facet:string):void {
+ this.ianService.setActiveFacet(facet);
+ this.ianService.get();
+ }
+}
diff --git a/frontend/src/app/features/in-app-notifications/in-app-notifications.lazy-routes.ts b/frontend/src/app/features/in-app-notifications/in-app-notifications.lazy-routes.ts
new file mode 100644
index 00000000000..d792b0f183f
--- /dev/null
+++ b/frontend/src/app/features/in-app-notifications/in-app-notifications.lazy-routes.ts
@@ -0,0 +1,38 @@
+// -- copyright
+// OpenProject is an open source project management software.
+// Copyright (C) 2012-2021 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 docs/COPYRIGHT.rdoc for more details.
+//++
+
+import { Ng2StateDeclaration } from '@uirouter/angular';
+
+export const IAN_LAZY_ROUTES:Ng2StateDeclaration[] = [
+ {
+ name: 'notifications.**',
+ parent: 'root',
+ url: '/notifications',
+ loadChildren: () => import('./in-app-notifications.module').then((m) => m.OpenProjectInAppNotificationsModule),
+ },
+];
diff --git a/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts b/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts
index f4ff9ee6078..a3bebed4d3e 100644
--- a/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts
+++ b/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts
@@ -7,16 +7,22 @@ import { InAppNotificationEntryComponent } from 'core-app/features/in-app-notifi
import { OpenprojectPrincipalRenderingModule } from 'core-app/shared/components/principal/principal-rendering.module';
import { UIRouterModule } from '@uirouter/angular';
import { ScrollingModule } from '@angular/cdk/scrolling';
-import { InAppNotificationCenterComponent } from './center/in-app-notification-center.component';
+import { IAN_ROUTES } from 'core-app/features/in-app-notifications/in-app-notifications.routes';
+import { InAppNotificationCenterComponent } from 'core-app/features/in-app-notifications/center/in-app-notification-center.component';
+import { InAppNotificationToolbarComponent } from "core-app/features/in-app-notifications/center/toolbar/in-app-notification-toolbar.component";
@NgModule({
declarations: [
InAppNotificationBellComponent,
InAppNotificationCenterComponent,
InAppNotificationEntryComponent,
+ InAppNotificationToolbarComponent,
],
imports: [
- UIRouterModule,
+ // Routes for /backlogs
+ UIRouterModule.forChild({
+ states: IAN_ROUTES,
+ }),
CommonModule,
IconModule,
OpenprojectModalModule,
@@ -24,4 +30,5 @@ import { InAppNotificationCenterComponent } from './center/in-app-notification-c
ScrollingModule,
],
})
-export class OpenProjectInAppNotificationsModule { }
+export class OpenProjectInAppNotificationsModule {
+}
diff --git a/frontend/src/app/features/in-app-notifications/in-app-notifications.routes.ts b/frontend/src/app/features/in-app-notifications/in-app-notifications.routes.ts
new file mode 100644
index 00000000000..d23ce58ca69
--- /dev/null
+++ b/frontend/src/app/features/in-app-notifications/in-app-notifications.routes.ts
@@ -0,0 +1,39 @@
+// -- copyright
+// OpenProject is an open source project management software.
+// Copyright (C) 2012-2021 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 docs/COPYRIGHT.rdoc for more details.
+//++
+
+import { Ng2StateDeclaration } from '@uirouter/angular';
+import { InAppNotificationCenterComponent } from 'core-app/features/in-app-notifications/center/in-app-notification-center.component';
+
+export const IAN_ROUTES:Ng2StateDeclaration[] = [
+ {
+ name: 'notifications',
+ parent: 'root',
+ url: '/notifications',
+ component: InAppNotificationCenterComponent,
+ },
+];
diff --git a/frontend/src/app/features/in-app-notifications/store/in-app-notification.model.ts b/frontend/src/app/features/in-app-notifications/store/in-app-notification.model.ts
index 2a6d379ce9b..b98afe8806a 100644
--- a/frontend/src/app/features/in-app-notifications/store/in-app-notification.model.ts
+++ b/frontend/src/app/features/in-app-notifications/store/in-app-notification.model.ts
@@ -8,6 +8,8 @@ export type InAppNotificationFormat = 'markdown'|'custom';
export const NOTIFICATIONS_MAX_SIZE = 100;
+export const IAN_FACETS = ['unread', 'all'];
+
export interface InAppNotificationDetail {
format:InAppNotificationFormat;
raw:string|null;
diff --git a/frontend/src/app/features/user-preferences/user-preferences.lazy-routes.ts b/frontend/src/app/features/user-preferences/user-preferences.lazy-routes.ts
index a6c29f38085..b99f150ed66 100644
--- a/frontend/src/app/features/user-preferences/user-preferences.lazy-routes.ts
+++ b/frontend/src/app/features/user-preferences/user-preferences.lazy-routes.ts
@@ -30,7 +30,7 @@ import { Ng2StateDeclaration } from '@uirouter/angular';
export const MY_ACCOUNT_LAZY_ROUTES:Ng2StateDeclaration[] = [
{
- name: 'my_notifications.**',
+ name: 'my_notification.**',
parent: 'root',
url: '/my/notifications',
loadChildren: () => import('./user-preferences.module').then((m) => m.OpenProjectMyAccountModule),