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

Merge remote-tracking branch 'origin/dev' into automatically-open-next-notification

Henriette Darge60436e37cb64
diff --cc frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.ts
index f887ffcd0f5,5b7a6b5698a..46c2ead8215
--- 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
@@@ -15,6 -20,8 +15,7 @@@ import
InAppNotification,
NOTIFICATIONS_MAX_SIZE,
} from 'core-app/core/state/in-app-notifications/in-app-notification.model';
-import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
-import { APIV3Service } from 'core-app/core/apiv3/api-v3.service';
++import { UIRouterGlobals } from '@uirouter/core';
@Component({
selector: 'op-in-app-notification-center',
@@@ -75,7 -90,11 +76,8 @@@ export class InAppNotificationCenterCom
readonly elementRef:ElementRef,
readonly I18n:I18nService,
readonly storeService:IanCenterService,
+ readonly uiRouterGlobals:UIRouterGlobals,
- readonly state:StateService,
- readonly apiV3:APIV3Service,
) {
- super();
}
ngOnInit():void {
diff --cc frontend/src/app/features/in-app-notifications/center/state/ian-center.query.ts
index 7b4dc0d4977,ea6bdb609bd..b0cd25ed315
--- a/frontend/src/app/features/in-app-notifications/center/state/ian-center.query.ts
+++ b/frontend/src/app/features/in-app-notifications/center/state/ian-center.query.ts
@@@ -1,4 -1,8 +1,6 @@@
import { Query } from '@datorama/akita';
-import {
- map,
- switchMap,
-} from 'rxjs/operators';
++import { map } from 'rxjs/operators';
++import { combineLatest } from 'rxjs';
import {
IAN_FACET_FILTERS,
IanCenterState,
diff --cc frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts
index 19a48fb817c,aec31b913c6..7a856b3d27a
--- 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
@@@ -2,19 -2,16 +2,20 @@@ import
Injectable,
Injector,
} from '@angular/core';
- import {
- IanCenterStore,
- InAppNotificationFacet,
- } from './ian-center.store';
import {
+ distinctUntilChanged,
map,
+ pluck,
+ share,
switchMap,
take,
+ tap,
} from 'rxjs/operators';
+ import { from } from 'rxjs';
+ import {
+ ID,
+ setLoading,
+ } from '@datorama/akita';
import {
markNotificationsAsRead,
notificationsMarkedRead,
@@@ -32,13 -25,13 +29,17 @@@ import
import { ActionsService } from 'core-app/core/state/actions/actions.service';
import { HalResource } from 'core-app/features/hal/resources/hal-resource';
import { APIV3Service } from 'core-app/core/apiv3/api-v3.service';
- import { from } from 'rxjs';
import { InAppNotificationsResourceService } from 'core-app/core/state/in-app-notifications/in-app-notifications.service';
import { selectCollectionAsHrefs$ } from 'core-app/core/state/collection-store';
+ import { INotificationPageQueryParameters } from 'core-app/features/in-app-notifications/in-app-notifications.routes';
+ import {
+ IanCenterStore,
+ InAppNotificationFacet,
+ } from './ian-center.store';
++import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
++import { UIRouterGlobals } from '@uirouter/core';
+import { StateService } from '@uirouter/angular';
+import idFromLink from 'core-app/features/hal/helpers/id-from-link';
- import { UIRouterGlobals } from '@uirouter/core';
- import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';
@Injectable()
@EffectHandler
@@@ -65,15 -47,17 +66,20 @@@ export class IanCenterService extends U
readonly resourceService:InAppNotificationsResourceService,
readonly actions$:ActionsService,
readonly apiV3Service:APIV3Service,
+ readonly uiRouterGlobals:UIRouterGlobals,
+ readonly state:StateService,
) {
+ super();
}
+ setFilters(filters:INotificationPageQueryParameters):void {
+ this.store.update({ filters });
+ this.debouncedReload();
+ }
+
setFacet(facet:InAppNotificationFacet):void {
this.store.update({ activeFacet: facet });
- this.reload().subscribe();
+ this.debouncedReload();
}
markAsRead(notifications:ID[]):void {
@@@ -92,34 -76,6 +98,36 @@@
});
}
+ openSplitScreen(wpId:string|null):void {
+ void this.state.go(
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
- `${(this.state.current.data).baseRoute}.details.tabs`,
++ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/restrict-template-expressions
++ `${this.state.current.data.baseRoute}.details.tabs`,
+ { workPackageId: wpId, tabIdentifier: 'activity' },
+ );
+ }
+
+ showNextNotification():void {
+ void this
+ .query
+ .notifications$
+ .pipe(
+ take(1),
+ ).subscribe((notifications) => {
+ if (notifications.length <= 0) {
+ void this.state.go(
- `${(this.state.current.data).baseRoute}`,
++ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/restrict-template-expressions
++ `${this.state.current.data.baseRoute}`,
+ );
+ return;
+ }
+ if (notifications[0][0]._links.resource || notifications[this.selectedNotificationIndex][0]._links.resource) {
++ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
+ const wpId = idFromLink(notifications[this.selectedNotificationIndex >= notifications.length ? 0 : this.selectedNotificationIndex][0]._links.resource!.href);
+ this.openSplitScreen(wpId);
+ }
+ });
+ }
+
/**
* Reload after notifications were successfully marked as read
*/
@@@ -129,16 -85,15 +137,18 @@@
this
.resourceService
.removeFromCollection(this.query.params, action.notifications);
- this.showNextNotification();
++ this.showNextNotification();
} else {
- this.reload().subscribe(() => {
- this.showNextNotification();
- });
- this.debouncedReload();
++ this.debouncedReload(this.showNextNotification.bind(this));
}
}
- private debouncedReload = _.debounce(() => { this.reload(); });
++ private debouncedReload(execFn:Function = () => {}) {
++ _.debounce(() => { this.reload().subscribe(execFn()); });
++ }
+
private reload() {
- return this.resourceService
- this.resourceService
++ return this.resourceService
.fetchNotifications(this.query.params)
.pipe(
setLoading(this.store),