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
Replace ng-effects with ts-actions directly
Oliver Günther50f233dd934a
diff --git a/frontend/package-lock.json b/frontend/package-lock.jsonindex b9449ad228b..04f78ecf466 100644--- a/frontend/package-lock.json+++ b/frontend/package-lock.json@@ -1878,15 +1878,6 @@"schematics-utilities": "^2.0.3"}},- "@datorama/akita-ng-effects": {- "version": "1.0.5",- "resolved": "https://registry.npmjs.org/@datorama/akita-ng-effects/-/akita-ng-effects-1.0.5.tgz",- "integrity": "sha512-nP5BSNY2ubOcyMFSIAjd4oyIslUVYj+H7imzoZP62w6Firt+4YZVJ3EreuVkthEVcGN0y85NqdJ4SjvWcSgGMQ==",- "requires": {- "ts-action": "^11.0.0",- "ts-action-operators": "^9.1.1"- }- },"@discoveryjs/json-ext": {"version": "0.5.2","resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.2.tgz",diff --git a/frontend/package.json b/frontend/package.jsonindex 3a260d98bd9..0c3f48ac6c2 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -71,7 +71,6 @@"@angular/platform-browser-dynamic": "~12.0.2","@angular/router": "~12.0.2","@datorama/akita": "^6.2.0",- "@datorama/akita-ng-effects": "^1.0.5","@fullcalendar/angular": "5.5.0","@fullcalendar/core": "5.5.0","@fullcalendar/daygrid": "5.5.0",@@ -127,6 +126,7 @@"swagger-ui": "^3.50.0","tablesorter": "^2.31.3","ts-action": "^11.0.0",+ "ts-action-operators": "^9.1.2","typedjson": "^1.5.1","urijs": "^1.19.2","zone.js": "~0.11.4"diff --git a/frontend/src/app/app.module.ts b/frontend/src/app/app.module.tsindex e34506a52b4..0e1d9675884 100644--- a/frontend/src/app/app.module.ts+++ b/frontend/src/app/app.module.ts@@ -82,7 +82,6 @@ import { LinkedPluginsModule } from 'core-app/features/plugins/linked-plugins.moimport { OpenProjectInAppNotificationsModule } from 'core-app/features/in-app-notifications/in-app-notifications.module';import { OpenProjectBackupService } from './core/backup/op-backup.service';import { OpenProjectDirectFileUploadService } from './core/file-upload/op-direct-file-upload.service';-import { AkitaNgEffectsModule } from '@datorama/akita-ng-effects';import { OpenProjectStateModule } from 'core-app/core/state/openproject-state.module';export function initializeServices(injector:Injector) {diff --git a/frontend/src/app/core/state/actions/actions.service.ts b/frontend/src/app/core/state/actions/actions.service.tsindex 44b38a2b41a..43e1a8f5b14 100644--- a/frontend/src/app/core/state/actions/actions.service.ts+++ b/frontend/src/app/core/state/actions/actions.service.ts@@ -3,10 +3,15 @@ import {Observable,Subject,} from 'rxjs';-import { Action } from '@datorama/akita-ng-effects/lib/types';-import { ofType } from '@datorama/akita-ng-effects';import { ActionCreator } from 'ts-action/action';import { ActionType } from 'ts-action';+import { ofType } from 'ts-action-operators';++export interface Action {+ type:string;++ [key:string]:any;+}@Injectable({ providedIn: 'root' })export class ActionsService {diff --git a/frontend/src/app/core/state/collection-store.type.ts b/frontend/src/app/core/state/collection-store.type.tsindex b4be16f843b..c9cdb64730f 100644--- a/frontend/src/app/core/state/collection-store.type.ts+++ b/frontend/src/app/core/state/collection-store.type.ts@@ -1,7 +1,12 @@import { EntityState, ID, QueryEntity } from '@datorama/akita';import { Apiv3ListParameters, listParamsString } from 'core-app/core/apiv3/paths/apiv3-list-resource.interface';import { Observable } from 'rxjs';-import { filter, switchMap } from 'rxjs/operators';+import {+ distinctUntilChanged,+ filter,+ map,+ switchMap,+} from 'rxjs/operators';export interface CollectionResponse {ids:ID[];@@ -29,6 +34,7 @@ export function createInitialCollectionState():{ collections:Record<string, Coll};}+/*** Returns the collection key for the given APIv3 parameters*@@ -63,12 +69,19 @@ export function selectCollection$<T extends CollectionItem>(service:CollectionSe* @param params*/export function selectCollectionEntities$<T extends CollectionItem>(service:CollectionService<T>, params:Apiv3ListParameters):Observable<T[]> {- return selectCollection$<T>(service, params)+ const key = collectionKey(params);++ return service+ .query+ .select().pipe(- switchMap((collection:CollectionResponse) => (- service.query.selectAll({- filterBy: ({ id }) => collection.ids.includes(id),- })- )),+ map((state) => {+ const collection = state.collections[key];+ const ids = collection?.ids || [];++ return ids+ .map((id) => service.query.getEntity(id))+ .filter((item) => !!item) as T[];+ }),);}diff --git a/frontend/src/app/core/state/effects/effect-handler.decorator.ts b/frontend/src/app/core/state/effects/effect-handler.decorator.tsindex 1e9764ebfd0..91d2a7aad55 100644--- a/frontend/src/app/core/state/effects/effect-handler.decorator.ts+++ b/frontend/src/app/core/state/effects/effect-handler.decorator.ts@@ -2,10 +2,10 @@ import 'reflect-metadata';import { debugLog } from 'core-app/shared/helpers/debug_output';import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';import { untilComponentDestroyed } from '@w11k/ngx-componentdestroyed';-import { Action } from '@datorama/akita-ng-effects/lib/types';import { ActionsService } from 'core-app/core/state/actions/actions.service';import { ActionCreator } from 'ts-action/action';import { Injector } from '@angular/core';+import { Action } from 'ts-action';// We're opening a baseclass through the decorator, the decorator enforces using any *//* eslint-disable @typescript-eslint/no-explicit-any */diff --git a/frontend/src/app/core/state/in-app-notifications/in-app-notifications.actions.ts b/frontend/src/app/core/state/in-app-notifications/in-app-notifications.actions.tsindex 3a0fd289335..94a725ffea0 100644--- a/frontend/src/app/core/state/in-app-notifications/in-app-notifications.actions.ts+++ b/frontend/src/app/core/state/in-app-notifications/in-app-notifications.actions.ts@@ -1,12 +1,15 @@-import { createAction, props } from '@datorama/akita-ng-effects';import { ID } from '@datorama/akita';+import {+ action,+ props,+} from 'ts-action';-export const markNotificationsAsRead = createAction(+export const markNotificationsAsRead = action('[IAN] Mark notifications as read',props<{ caller:{ id:string }, notifications:ID[] }>(),);-export const notificationsMarkedRead = createAction(+export const notificationsMarkedRead = action('[IAN] Notifications were marked as read',props<{ caller:{ id:string }, notifications:ID[] }>(),);diff --git a/frontend/src/app/core/state/in-app-notifications/in-app-notifications.service.ts b/frontend/src/app/core/state/in-app-notifications/in-app-notifications.service.tsindex 8ecfcebe1fa..08ef206380a 100644--- a/frontend/src/app/core/state/in-app-notifications/in-app-notifications.service.ts+++ b/frontend/src/app/core/state/in-app-notifications/in-app-notifications.service.ts@@ -13,12 +13,10 @@ import {} from '@datorama/akita';import { APIV3Service } from 'core-app/core/apiv3/api-v3.service';import { NotificationsService } from 'core-app/shared/components/notifications/notifications.service';-import { HalResource } from 'core-app/features/hal/resources/hal-resource';import { InAppNotificationsStore } from './in-app-notifications.store';import { InAppNotification } from './in-app-notification.model';import { IHALCollection } from 'core-app/core/apiv3/types/hal-collection.type';import { HttpClient } from '@angular/common/http';-import { Actions } from '@datorama/akita-ng-effects';import { InAppNotificationsQuery } from 'core-app/core/state/in-app-notifications/in-app-notifications.query';import { Apiv3ListParameters } from 'core-app/core/apiv3/paths/apiv3-list-resource.interface';import { collectionKey } from 'core-app/core/state/collection-store.type';diff --git a/frontend/src/app/core/state/openproject-state.module.ts b/frontend/src/app/core/state/openproject-state.module.tsindex e2a1d247347..fc57ff30553 100644--- a/frontend/src/app/core/state/openproject-state.module.ts+++ b/frontend/src/app/core/state/openproject-state.module.ts@@ -27,20 +27,14 @@//++import {- Injector,NgModule,} from '@angular/core';-import { AkitaNgEffectsModule } from '@datorama/akita-ng-effects';import { InAppNotificationsService } from 'core-app/core/state/in-app-notifications/in-app-notifications.service';@NgModule({- imports: [- // Global effects- AkitaNgEffectsModule.forRoot(),- ],providers: [InAppNotificationsService,- ]+ ],})export class OpenProjectStateModule {}diff --git a/frontend/src/app/features/in-app-notifications/center/toolbar/facet/activate-facet-button.component.ts b/frontend/src/app/features/in-app-notifications/center/toolbar/facet/activate-facet-button.component.tsindex 184c889940f..d2ed3be2f65 100644--- a/frontend/src/app/features/in-app-notifications/center/toolbar/facet/activate-facet-button.component.ts+++ b/frontend/src/app/features/in-app-notifications/center/toolbar/facet/activate-facet-button.component.ts@@ -1,6 +1,5 @@import { ChangeDetectionStrategy, Component } from '@angular/core';import { I18nService } from 'core-app/core/i18n/i18n.service';-import { Actions } from '@datorama/akita-ng-effects';import { IanCenterService } from 'core-app/features/in-app-notifications/center/state/ian-center.service';import {IAN_FACET_FILTERS,@@ -27,7 +26,6 @@ export class ActivateFacetButtonComponent {constructor(private I18n:I18nService,private storeService:IanCenterService,- private actions$:Actions,) {}diff --git a/frontend/src/app/features/work-packages/routing/wp-view-base/state/wp-single-view.service.ts b/frontend/src/app/features/work-packages/routing/wp-view-base/state/wp-single-view.service.tsindex 7903c820cd2..de14bc40beb 100644--- a/frontend/src/app/features/work-packages/routing/wp-view-base/state/wp-single-view.service.ts+++ b/frontend/src/app/features/work-packages/routing/wp-view-base/state/wp-single-view.service.ts@@ -108,9 +108,7 @@ export class WpSingleViewService extends UntilDestroyedMixin {*/@EffectCallback(notificationsMarkedRead)private reloadOnNotificationRead(action:ReturnType<typeof notificationsMarkedRead>) {- if (action.caller !== this) {- const { filters } = this.store.getValue().notifications;- this.reload(filters);- }+ const { filters } = this.store.getValue().notifications;+ this.reload(filters);}}