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

Extract toolbar component into separate components to use standardised way to implement the partitioned page toolbar

Henriette Darge2d6cc2ac7276
diff --git a/frontend/src/app/features/boards/board/board-partitioned-page/board-partitioned-page.component.ts b/frontend/src/app/features/boards/board/board-partitioned-page/board-partitioned-page.component.ts
index 7b0c830d2f9..2ab350757cb 100644
--- a/frontend/src/app/features/boards/board/board-partitioned-page/board-partitioned-page.component.ts
+++ b/frontend/src/app/features/boards/board/board-partitioned-page/board-partitioned-page.component.ts
@@ -88,6 +88,7 @@ export class BoardPartitionedPageComponent extends UntilDestroyedMixin {
/** Listener callbacks */
removeTransitionSubscription:Function;
+ /** Show a toolbar */
showToolbar = true;
/** Whether filtering is allowed */
@@ -117,7 +118,6 @@ export class BoardPartitionedPageComponent extends UntilDestroyedMixin {
},
);
- toolbarComponent = null;
toolbarButtonComponents:ToolbarButtonComponentDefinition[] = [
{
component: WorkPackageFilterButtonComponent,
diff --git a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center-page.component.ts b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center-page.component.ts
index 8799dc82cff..6c318f42524 100644
--- a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center-page.component.ts
+++ b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center-page.component.ts
@@ -4,7 +4,11 @@ import {
Component,
Injector,
} from '@angular/core';
-import { ViewPartitionState } from 'core-app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component';
+import {
+ PartitionedQuerySpacePageComponent,
+ ToolbarButtonComponentDefinition,
+ ViewPartitionState,
+} from 'core-app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component';
import {
StateService,
TransitionService,
@@ -13,7 +17,9 @@ import { NotificationsService } from 'core-app/shared/components/notifications/n
import { I18nService } from 'core-app/core/i18n/i18n.service';
import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
import { APIV3Service } from 'core-app/core/apiv3/api-v3.service';
-import { InAppNotificationToolbarComponent } from 'core-app/features/in-app-notifications/center/toolbar/in-app-notification-toolbar.component';
+import { NotificationSettingsButtonComponent } from 'core-app/features/in-app-notifications/center/toolbar/settings/notification-settings-button.component';
+import { ActivateFacetButtonComponent } from 'core-app/features/in-app-notifications/center/toolbar/facet/activate-facet-button.component';
+import { MarkAllAsReadButtonComponent } from 'core-app/features/in-app-notifications/center/toolbar/mark-all-as-read/mark-all-as-read-button.component';
@Component({
templateUrl: '../../work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.html',
@@ -22,24 +28,40 @@ import { InAppNotificationToolbarComponent } from 'core-app/features/in-app-noti
],
changeDetection: ChangeDetectionStrategy.OnPush,
})
-export class InAppNotificationCenterPageComponent extends UntilDestroyedMixin {
+export class InAppNotificationCenterPageComponent extends PartitionedQuerySpacePageComponent {
text = {
title: this.I18n.t('js.notifications.title'),
};
- /** Go back to boards using back-button */
+ /** Go back using back-button */
+ // TODO: Use better Function which actually leaves the notification page and don't only toggle the split views
backButtonCallback = ():void => window.history.back();
/** Current query title to render */
selectedTitle = this.text.title;
- /** Disable filter container for now */
- filterContainerDefinition = null;
-
/** We need to pass the correct partition state to the view to manage the grid */
currentPartition:ViewPartitionState = '-split';
- toolbarComponent = InAppNotificationToolbarComponent;
+ /** Show a toolbar */
+ showToolbar = true;
+
+ /** Toolbar is not editable */
+ titleEditingEnabled = false;
+
+ toolbarButtonComponents:ToolbarButtonComponentDefinition[] = [
+ {
+ component: ActivateFacetButtonComponent,
+ containerClasses: 'form--field-inline-buttons-container',
+ },
+ {
+ component: MarkAllAsReadButtonComponent,
+ },
+ {
+ component: NotificationSettingsButtonComponent,
+ containerClasses: 'hidden-for-mobile',
+ },
+ ];
constructor(
readonly I18n:I18nService,
@@ -50,7 +72,7 @@ export class InAppNotificationCenterPageComponent extends UntilDestroyedMixin {
readonly injector:Injector,
readonly apiV3Service:APIV3Service,
) {
- super();
+ super(injector);
}
/**
diff --git a/frontend/src/app/features/in-app-notifications/center/toolbar/facet/activate-facet-button.component.html b/frontend/src/app/features/in-app-notifications/center/toolbar/facet/activate-facet-button.component.html
new file mode 100644
index 00000000000..5393752bbbc
--- /dev/null
+++ b/frontend/src/app/features/in-app-notifications/center/toolbar/facet/activate-facet-button.component.html
@@ -0,0 +1,14 @@
+<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>
\ No newline at end of file
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/facet/activate-facet-button.component.ts
similarity index 52%
rename from frontend/src/app/features/in-app-notifications/center/toolbar/in-app-notification-toolbar.component.ts
rename to frontend/src/app/features/in-app-notifications/center/toolbar/facet/activate-facet-button.component.ts
index 5dc7ec38d6f..6d6ac1a436a 100644
--- 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/facet/activate-facet-button.component.ts
@@ -1,45 +1,30 @@
-import {
- ChangeDetectionStrategy,
- Component,
-} from '@angular/core';
+import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';
+import { IAN_FACETS } from 'core-app/features/in-app-notifications/store/in-app-notification.model';
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',
+ selector: 'op-activate-facet',
+ templateUrl: './activate-facet-button.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
-export class InAppNotificationToolbarComponent {
- activeFacet$ = this.ianQuery.activeFacet$
+export class ActivateFacetButtonComponent {
+ 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();
+ private ianService:InAppNotificationsService) {
}
activateFacet(facet:string):void {
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
deleted file mode 100644
index 80c65fdec29..00000000000
--- a/frontend/src/app/features/in-app-notifications/center/toolbar/in-app-notification-toolbar.component.html
+++ /dev/null
@@ -1,56 +0,0 @@
-<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/mark-all-as-read/mark-all-as-read-button.component.html b/frontend/src/app/features/in-app-notifications/center/toolbar/mark-all-as-read/mark-all-as-read-button.component.html
new file mode 100644
index 00000000000..1cf77dd44b8
--- /dev/null
+++ b/frontend/src/app/features/in-app-notifications/center/toolbar/mark-all-as-read/mark-all-as-read-button.component.html
@@ -0,0 +1,13 @@
+<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>
\ No newline at end of file
diff --git a/frontend/src/app/features/in-app-notifications/center/toolbar/mark-all-as-read/mark-all-as-read-button.component.ts b/frontend/src/app/features/in-app-notifications/center/toolbar/mark-all-as-read/mark-all-as-read-button.component.ts
new file mode 100644
index 00000000000..1fb2846a7a1
--- /dev/null
+++ b/frontend/src/app/features/in-app-notifications/center/toolbar/mark-all-as-read/mark-all-as-read-button.component.ts
@@ -0,0 +1,24 @@
+import { Component, ChangeDetectionStrategy } from '@angular/core';
+import { I18nService } from 'core-app/core/i18n/i18n.service';
+import { InAppNotificationsService } from 'core-app/features/in-app-notifications/store/in-app-notifications.service';
+
+@Component({
+ selector: 'op-mark-all-as-read-button',
+ templateUrl: './mark-all-as-read-button.component.html',
+ changeDetection: ChangeDetectionStrategy.OnPush,
+})
+export class MarkAllAsReadButtonComponent {
+ text = {
+ mark_all_read: this.I18n.t('js.notifications.center.mark_all_read'),
+
+ };
+
+ constructor(
+ private I18n:I18nService,
+ private ianService:InAppNotificationsService,) {
+ }
+
+ markAllRead():void {
+ this.ianService.markAllRead();
+ }
+}
diff --git a/frontend/src/app/features/in-app-notifications/center/toolbar/settings/notification-settings-button.component.html b/frontend/src/app/features/in-app-notifications/center/toolbar/settings/notification-settings-button.component.html
new file mode 100644
index 00000000000..15b3ac1747b
--- /dev/null
+++ b/frontend/src/app/features/in-app-notifications/center/toolbar/settings/notification-settings-button.component.html
@@ -0,0 +1,13 @@
+<a
+ class="button"
+ [href]="myNotificationSettingsLink"
+ target="_blank"
+>
+ <op-icon icon-classes="button--icon icon-settings">
+ </op-icon>
+ <span
+ class="button--text"
+ [textContent]="text.mySettings"
+ >
+ </span>
+</a>
\ No newline at end of file
diff --git a/frontend/src/app/features/in-app-notifications/center/toolbar/settings/notification-settings-button.component.ts b/frontend/src/app/features/in-app-notifications/center/toolbar/settings/notification-settings-button.component.ts
new file mode 100644
index 00000000000..03f3b59e3e8
--- /dev/null
+++ b/frontend/src/app/features/in-app-notifications/center/toolbar/settings/notification-settings-button.component.ts
@@ -0,0 +1,21 @@
+import { ChangeDetectionStrategy, Component } from '@angular/core';
+import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';
+import { I18nService } from 'core-app/core/i18n/i18n.service';
+
+@Component({
+ selector: 'op-notification-settings-button',
+ templateUrl: './notification-settings-button.component.html',
+ changeDetection: ChangeDetectionStrategy.OnPush,
+})
+export class NotificationSettingsButtonComponent {
+ myNotificationSettingsLink = this.pathHelper.myNotificationsSettingsPath();
+
+ text = {
+ mySettings: this.I18n.t('js.notifications.settings.title'),
+ };
+
+ constructor(
+ private I18n:I18nService,
+ private pathHelper:PathHelperService) {
+ }
+}
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 6ddbb281f52..0238ec29baa 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
@@ -8,22 +8,28 @@ import { UIRouterModule } from '@uirouter/angular';
import { ScrollingModule } from '@angular/cdk/scrolling';
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';
import { InAppNotificationCenterPageComponent } from 'core-app/features/in-app-notifications/center/in-app-notification-center-page.component';
import { OpenprojectWorkPackagesModule } from 'core-app/features/work-packages/openproject-work-packages.module';
import { DynamicModule } from 'ng-dynamic-component';
import { InAppNotificationStatusComponent } from './entry/status/in-app-notification-status.component';
+import { NotificationSettingsButtonComponent } from './center/toolbar/settings/notification-settings-button.component';
+import { ActivateFacetButtonComponent } from './center/toolbar/facet/activate-facet-button.component';
+import { MarkAllAsReadButtonComponent } from './center/toolbar/mark-all-as-read/mark-all-as-read-button.component';
+import { OPSharedModule } from 'core-app/shared/shared.module';
@NgModule({
declarations: [
InAppNotificationBellComponent,
InAppNotificationCenterComponent,
InAppNotificationEntryComponent,
- InAppNotificationToolbarComponent,
InAppNotificationCenterPageComponent,
InAppNotificationStatusComponent,
+ NotificationSettingsButtonComponent,
+ ActivateFacetButtonComponent,
+ MarkAllAsReadButtonComponent,
],
imports: [
+ OPSharedModule,
// Routes for /backlogs
UIRouterModule.forChild({
states: IAN_ROUTES,
diff --git a/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.html b/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.html
index 4cf0a8fb98a..d921c662e9f 100644
--- a/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.html
+++ b/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.html
@@ -1,11 +1,6 @@
<div class="work-packages-partitioned-query-space--container"
[ngClass]="currentPartition">
- <ng-container *ngIf="toolbarComponent">
- <ng-container *ngComponentOutlet="toolbarComponent; injector: injector"
- ></ng-container>
- </ng-container>
- <div *ngIf="!toolbarComponent"
- class="toolbar-container -editable">
+ <div class="toolbar-container -editable">
<div class="toolbar">
<op-back-button *ngIf="backButtonCallback"
linkClass="back-button"
diff --git a/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts b/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts
index 0d11d9b315e..eb103b27148 100644
--- a/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts
+++ b/frontend/src/app/features/work-packages/routing/partitioned-query-space-page/partitioned-query-space-page.component.ts
@@ -109,9 +109,6 @@ export class PartitionedQuerySpacePageComponent extends WorkPackagesViewBase imp
/** Determine when query is initially loaded */
showToolbar = false;
- /** The toolbar to render */
- toolbarComponent:ComponentRef<unknown>|undefined;
-
/** The toolbar buttons to render */
toolbarButtonComponents:ToolbarButtonComponentDefinition[] = [];