From 25ce50e6fe289d36d18f92797aa76100ff5efaab Mon Sep 17 00:00:00 2001 From: DominikIwanek Date: Thu, 18 Jul 2024 09:36:38 +0200 Subject: [PATCH] refactor DI into inject() methods --- .../ms-office/src/effects/aos.effects.ts | 7 +-- .../src/lib/store/effects/app.effects.ts | 9 ++-- .../lib/store/effects/contextmenu.effects.ts | 9 ++-- .../src/lib/store/effects/download.effects.ts | 18 +++---- .../src/lib/store/effects/favorite.effects.ts | 10 ++-- .../src/lib/store/effects/library.effects.ts | 18 +++---- .../src/lib/store/effects/node.effects.ts | 52 +++++++++---------- .../src/lib/store/effects/search.effects.ts | 8 +-- .../src/lib/store/effects/template.effects.ts | 32 ++++++------ .../src/lib/store/effects/upload.effects.ts | 27 +++++----- .../src/lib/store/effects/viewer.effects.ts | 30 +++++------ .../store/src/effects/dialog.effects.ts | 7 +-- .../store/src/effects/router.effects.ts | 11 ++-- .../store/src/effects/snackbar.effects.ts | 16 +++--- 14 files changed, 127 insertions(+), 127 deletions(-) diff --git a/projects/aca-content/ms-office/src/effects/aos.effects.ts b/projects/aca-content/ms-office/src/effects/aos.effects.ts index 6b4697b441..a52cc1b2f0 100755 --- a/projects/aca-content/ms-office/src/effects/aos.effects.ts +++ b/projects/aca-content/ms-office/src/effects/aos.effects.ts @@ -22,8 +22,8 @@ * from Hyland Software. If not, see . */ -import { Injectable } from '@angular/core'; -import { Actions, ofType, createEffect } from '@ngrx/effects'; +import { inject, Injectable } from '@angular/core'; +import { Actions, createEffect, ofType } from '@ngrx/effects'; import { map } from 'rxjs/operators'; import { AOS_ACTION, AosAction } from '../actions/aos.actions'; @@ -31,7 +31,8 @@ import { AosEditOnlineService } from '../aos-extension.service'; @Injectable() export class AosEffects { - constructor(private actions$: Actions, private aosEditOnlineService: AosEditOnlineService) {} + private actions$ = inject(Actions); + private aosEditOnlineService = inject(AosEditOnlineService); openOffice$ = createEffect( () => diff --git a/projects/aca-content/src/lib/store/effects/app.effects.ts b/projects/aca-content/src/lib/store/effects/app.effects.ts index 47dceae05e..08af8703d5 100644 --- a/projects/aca-content/src/lib/store/effects/app.effects.ts +++ b/projects/aca-content/src/lib/store/effects/app.effects.ts @@ -22,8 +22,8 @@ * from Hyland Software. If not, see . */ -import { Actions, ofType, createEffect } from '@ngrx/effects'; -import { Injectable } from '@angular/core'; +import { Actions, createEffect, ofType } from '@ngrx/effects'; +import { inject, Injectable } from '@angular/core'; import { map } from 'rxjs/operators'; import { AppActionTypes, LogoutAction, ReloadDocumentListAction, ResetSelectionAction } from '@alfresco/aca-shared/store'; import { AuthenticationService } from '@alfresco/adf-core'; @@ -32,7 +32,10 @@ import { AppHookService } from '@alfresco/aca-shared'; @Injectable() export class AppEffects { - constructor(private actions$: Actions, private auth: AuthenticationService, private router: Router, private appHookService: AppHookService) {} + actions$ = inject(Actions); + auth = inject(AuthenticationService); + router = inject(Router); + appHookService = inject(AppHookService); reload = createEffect( () => diff --git a/projects/aca-content/src/lib/store/effects/contextmenu.effects.ts b/projects/aca-content/src/lib/store/effects/contextmenu.effects.ts index 32e2229888..0121b19431 100644 --- a/projects/aca-content/src/lib/store/effects/contextmenu.effects.ts +++ b/projects/aca-content/src/lib/store/effects/contextmenu.effects.ts @@ -22,9 +22,9 @@ * from Hyland Software. If not, see . */ -import { ContextMenuActionTypes, ContextMenu } from '@alfresco/aca-shared/store'; -import { Injectable } from '@angular/core'; -import { Actions, ofType, createEffect } from '@ngrx/effects'; +import { ContextMenu, ContextMenuActionTypes } from '@alfresco/aca-shared/store'; +import { inject, Injectable } from '@angular/core'; +import { Actions, createEffect, ofType } from '@ngrx/effects'; import { map } from 'rxjs/operators'; import { ContextMenuOverlayRef } from '../../components/context-menu/context-menu-overlay'; import { ContextMenuService } from '../../components/context-menu/context-menu.service'; @@ -33,7 +33,8 @@ import { ContextMenuService } from '../../components/context-menu/context-menu.s export class ContextMenuEffects { private overlayRef: ContextMenuOverlayRef = null; - constructor(private contextMenuService: ContextMenuService, private actions$: Actions) {} + contextMenuService = inject(ContextMenuService); + actions$ = inject(Actions); contextMenu$ = createEffect( () => diff --git a/projects/aca-content/src/lib/store/effects/download.effects.ts b/projects/aca-content/src/lib/store/effects/download.effects.ts index 98640d34c1..13aef525e2 100644 --- a/projects/aca-content/src/lib/store/effects/download.effects.ts +++ b/projects/aca-content/src/lib/store/effects/download.effects.ts @@ -22,12 +22,12 @@ * from Hyland Software. If not, see . */ -import { AppStore, DownloadNodesAction, NodeActionTypes, NodeInfo, getAppSelection, getCurrentVersion } from '@alfresco/aca-shared/store'; +import { AppStore, DownloadNodesAction, getAppSelection, getCurrentVersion, NodeActionTypes, NodeInfo } from '@alfresco/aca-shared/store'; import { DownloadZipDialogComponent } from '@alfresco/adf-content-services'; import { NodeEntry, Version } from '@alfresco/js-api'; -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; -import { Actions, ofType, createEffect } from '@ngrx/effects'; +import { Actions, createEffect, ofType } from '@ngrx/effects'; import { Store } from '@ngrx/store'; import { map, take } from 'rxjs/operators'; import { ContentApiService } from '@alfresco/aca-shared'; @@ -35,13 +35,11 @@ import { ContentUrlService } from '../../services/content-url.service'; @Injectable() export class DownloadEffects { - constructor( - private store: Store, - private actions$: Actions, - private contentApi: ContentApiService, - private dialog: MatDialog, - private contentUrlService: ContentUrlService - ) {} + private store = inject(Store); + private actions$ = inject(Actions); + private contentApi = inject(ContentApiService); + private dialog = inject(MatDialog); + private contentUrlService = inject(ContentUrlService); downloadNode$ = createEffect( () => diff --git a/projects/aca-content/src/lib/store/effects/favorite.effects.ts b/projects/aca-content/src/lib/store/effects/favorite.effects.ts index 5beacf0fd0..593b86aca7 100644 --- a/projects/aca-content/src/lib/store/effects/favorite.effects.ts +++ b/projects/aca-content/src/lib/store/effects/favorite.effects.ts @@ -22,16 +22,18 @@ * from Hyland Software. If not, see . */ -import { Actions, ofType, createEffect } from '@ngrx/effects'; -import { Injectable } from '@angular/core'; +import { Actions, createEffect, ofType } from '@ngrx/effects'; +import { inject, Injectable } from '@angular/core'; import { map, take } from 'rxjs/operators'; -import { AppStore, NodeActionTypes, AddFavoriteAction, RemoveFavoriteAction, getAppSelection } from '@alfresco/aca-shared/store'; +import { AddFavoriteAction, AppStore, getAppSelection, NodeActionTypes, RemoveFavoriteAction } from '@alfresco/aca-shared/store'; import { Store } from '@ngrx/store'; import { ContentManagementService } from '../../services/content-management.service'; @Injectable() export class FavoriteEffects { - constructor(private store: Store, private actions$: Actions, private content: ContentManagementService) {} + private store = inject(Store); + private actions$ = inject(Actions); + private content = inject(ContentManagementService); addFavorite$ = createEffect( () => diff --git a/projects/aca-content/src/lib/store/effects/library.effects.ts b/projects/aca-content/src/lib/store/effects/library.effects.ts index e2791b7cfc..8939986c3c 100644 --- a/projects/aca-content/src/lib/store/effects/library.effects.ts +++ b/projects/aca-content/src/lib/store/effects/library.effects.ts @@ -26,16 +26,16 @@ import { AppStore, CreateLibraryAction, DeleteLibraryAction, + getAppSelection, LeaveLibraryAction, LibraryActionTypes, NavigateLibraryAction, NavigateRouteAction, SnackbarErrorAction, - UpdateLibraryAction, - getAppSelection + UpdateLibraryAction } from '@alfresco/aca-shared/store'; -import { Injectable } from '@angular/core'; -import { Actions, ofType, createEffect } from '@ngrx/effects'; +import { inject, Injectable } from '@angular/core'; +import { Actions, createEffect, ofType } from '@ngrx/effects'; import { Store } from '@ngrx/store'; import { map, mergeMap, take } from 'rxjs/operators'; import { ContentApiService } from '@alfresco/aca-shared'; @@ -43,12 +43,10 @@ import { ContentManagementService } from '../../services/content-management.serv @Injectable() export class LibraryEffects { - constructor( - private store: Store, - private actions$: Actions, - private content: ContentManagementService, - private contentApi: ContentApiService - ) {} + private store = inject(Store); + private actions$ = inject(Actions); + private content = inject(ContentManagementService); + private contentApi = inject(ContentApiService); deleteLibrary$ = createEffect( () => diff --git a/projects/aca-content/src/lib/store/effects/node.effects.ts b/projects/aca-content/src/lib/store/effects/node.effects.ts index 5b59fd6d5d..ba1d678096 100644 --- a/projects/aca-content/src/lib/store/effects/node.effects.ts +++ b/projects/aca-content/src/lib/store/effects/node.effects.ts @@ -22,36 +22,36 @@ * from Hyland Software. If not, see . */ -import { Actions, ofType, createEffect } from '@ngrx/effects'; -import { Injectable } from '@angular/core'; +import { Actions, createEffect, ofType } from '@ngrx/effects'; +import { inject, Injectable } from '@angular/core'; import { first, map, take } from 'rxjs/operators'; import { Store } from '@ngrx/store'; import { AppStore, - NodeActionTypes, - PurgeDeletedNodesAction, - DeleteNodesAction, - UndoDeleteNodesAction, + CopyNodesAction, CreateFolderAction, + DeleteNodesAction, EditFolderAction, - RestoreDeletedNodesAction, - ShareNodeAction, - ManageVersionsAction, - UnlockWriteAction, - UnshareNodesAction, - CopyNodesAction, - MoveNodesAction, - ManagePermissionsAction, - PrintFileAction, - getCurrentFolder, + ExpandInfoDrawerAction, getAppSelection, + getCurrentFolder, ManageAspectsAction, - NavigateRouteAction, - ExpandInfoDrawerAction, + ManagePermissionsAction, ManageRulesAction, - ShowLoaderAction, + ManageVersionsAction, + MoveNodesAction, + NavigateRouteAction, + NavigateUrlAction, + NodeActionTypes, + PrintFileAction, + PurgeDeletedNodesAction, + RestoreDeletedNodesAction, SetInfoDrawerStateAction, - NavigateUrlAction + ShareNodeAction, + ShowLoaderAction, + UndoDeleteNodesAction, + UnlockWriteAction, + UnshareNodesAction } from '@alfresco/aca-shared/store'; import { ContentManagementService } from '../../services/content-management.service'; import { RenditionService } from '@alfresco/adf-content-services'; @@ -59,13 +59,11 @@ import { NavigationEnd, Router } from '@angular/router'; @Injectable() export class NodeEffects { - constructor( - private store: Store, - private actions$: Actions, - private router: Router, - private contentService: ContentManagementService, - private renditionViewer: RenditionService - ) {} + store = inject(Store); + actions$ = inject(Actions); + router = inject(Router); + contentService = inject(ContentManagementService); + renditionViewer = inject(RenditionService); shareNode$ = createEffect( () => diff --git a/projects/aca-content/src/lib/store/effects/search.effects.ts b/projects/aca-content/src/lib/store/effects/search.effects.ts index 8e99db58f0..0ae8f15ec1 100644 --- a/projects/aca-content/src/lib/store/effects/search.effects.ts +++ b/projects/aca-content/src/lib/store/effects/search.effects.ts @@ -22,8 +22,8 @@ * from Hyland Software. If not, see . */ -import { Actions, ofType, createEffect } from '@ngrx/effects'; -import { Injectable } from '@angular/core'; +import { Actions, createEffect, ofType } from '@ngrx/effects'; +import { inject, Injectable } from '@angular/core'; import { map } from 'rxjs/operators'; import { SearchAction, SearchActionTypes, SearchByTermAction, SearchOptionIds } from '@alfresco/aca-shared/store'; import { Router } from '@angular/router'; @@ -31,7 +31,9 @@ import { SearchNavigationService } from '../../components/search/search-navigati @Injectable() export class SearchEffects { - constructor(private actions$: Actions, private router: Router, private searchNavigationService: SearchNavigationService) {} + private actions$ = inject(Actions); + private router = inject(Router); + private searchNavigationService = inject(SearchNavigationService); search$ = createEffect( () => diff --git a/projects/aca-content/src/lib/store/effects/template.effects.ts b/projects/aca-content/src/lib/store/effects/template.effects.ts index 4a06434212..dd3eca6038 100644 --- a/projects/aca-content/src/lib/store/effects/template.effects.ts +++ b/projects/aca-content/src/lib/store/effects/template.effects.ts @@ -22,25 +22,25 @@ * from Hyland Software. If not, see . */ -import { Actions, ofType, createEffect } from '@ngrx/effects'; -import { Injectable } from '@angular/core'; -import { map, switchMap, debounceTime, take, catchError } from 'rxjs/operators'; +import { Actions, createEffect, ofType } from '@ngrx/effects'; +import { inject, Injectable } from '@angular/core'; +import { catchError, debounceTime, map, switchMap, take } from 'rxjs/operators'; import { Store } from '@ngrx/store'; import { - FileFromTemplate, - FolderFromTemplate, + AppStore, CreateFromTemplate, CreateFromTemplateSuccess, - TemplateActionTypes, + FileFromTemplate, + FolderFromTemplate, getCurrentFolder, - AppStore, - SnackbarErrorAction + SnackbarErrorAction, + TemplateActionTypes } from '@alfresco/aca-shared/store'; import { NodeTemplateService, TemplateDialogConfig } from '../../services/node-template.service'; import { AlfrescoApiService } from '@alfresco/adf-core'; import { AppHookService } from '@alfresco/aca-shared'; import { from, Observable, of } from 'rxjs'; -import { NodeEntry, NodeBodyUpdate, Node, NodesApi } from '@alfresco/js-api'; +import { Node, NodeBodyUpdate, NodeEntry, NodesApi } from '@alfresco/js-api'; import { MatDialog } from '@angular/material/dialog'; @Injectable() @@ -51,14 +51,12 @@ export class TemplateEffects { return this._nodesApi; } - constructor( - private matDialog: MatDialog, - private appHookService: AppHookService, - private store: Store, - private apiService: AlfrescoApiService, - private actions$: Actions, - private nodeTemplateService: NodeTemplateService - ) {} + private matDialog = inject(MatDialog); + private appHookService = inject(AppHookService); + private store = inject(Store); + private apiService = inject(AlfrescoApiService); + private actions$ = inject(Actions); + private nodeTemplateService = inject(NodeTemplateService); fileFromTemplate$ = createEffect( () => diff --git a/projects/aca-content/src/lib/store/effects/upload.effects.ts b/projects/aca-content/src/lib/store/effects/upload.effects.ts index bbbcfc1955..501fdc8105 100644 --- a/projects/aca-content/src/lib/store/effects/upload.effects.ts +++ b/projects/aca-content/src/lib/store/effects/upload.effects.ts @@ -24,23 +24,23 @@ import { AppStore, + getCurrentFolder, SnackbarErrorAction, UnlockWriteAction, UploadActionTypes, UploadFilesAction, UploadFileVersionAction, - UploadFolderAction, - getCurrentFolder + UploadFolderAction } from '@alfresco/aca-shared/store'; import { FileUtils } from '@alfresco/adf-core'; -import { Injectable, NgZone, RendererFactory2 } from '@angular/core'; -import { Actions, ofType, createEffect } from '@ngrx/effects'; +import { inject, Injectable, NgZone, RendererFactory2 } from '@angular/core'; +import { Actions, createEffect, ofType } from '@ngrx/effects'; import { Store } from '@ngrx/store'; import { of } from 'rxjs'; import { catchError, map, take } from 'rxjs/operators'; import { ContentManagementService } from '../../services/content-management.service'; import { Node } from '@alfresco/js-api'; -import { UploadService, FileModel } from '@alfresco/adf-content-services'; +import { FileModel, UploadService } from '@alfresco/adf-content-services'; @Injectable() export class UploadEffects { @@ -49,15 +49,14 @@ export class UploadEffects { private readonly fileVersionInput: HTMLInputElement; private readonly uploadMenuButtonSelector = 'app-toolbar-menu button[id="app.toolbar.upload"]'; - constructor( - private store: Store, - private actions$: Actions, - private ngZone: NgZone, - private uploadService: UploadService, - rendererFactory: RendererFactory2, - private contentService: ContentManagementService - ) { - const renderer = rendererFactory.createRenderer(null, null); + private store = inject(Store); + private actions$ = inject(Actions); + private ngZone = inject(NgZone); + private uploadService = inject(UploadService); + rendererFactory = inject(RendererFactory2); + private contentService = inject(ContentManagementService); + constructor() { + const renderer = this.rendererFactory.createRenderer(null, null); this.fileInput = renderer.createElement('input') as HTMLInputElement; this.fileInput.id = 'app-upload-files'; diff --git a/projects/aca-content/src/lib/store/effects/viewer.effects.ts b/projects/aca-content/src/lib/store/effects/viewer.effects.ts index f3797d255a..a98631f55b 100644 --- a/projects/aca-content/src/lib/store/effects/viewer.effects.ts +++ b/projects/aca-content/src/lib/store/effects/viewer.effects.ts @@ -22,22 +22,22 @@ * from Hyland Software. If not, see . */ -import { Actions, ofType, createEffect } from '@ngrx/effects'; -import { Injectable } from '@angular/core'; +import { Actions, createEffect, ofType } from '@ngrx/effects'; +import { inject, Injectable } from '@angular/core'; import { map, take, tap } from 'rxjs/operators'; import { AppStore, + FullscreenViewerAction, + getAppSelection, + getCurrentFolder, + PluginPreviewAction, ViewerActionTypes, ViewFileAction, ViewNodeAction, - getCurrentFolder, - getAppSelection, - FullscreenViewerAction, - ViewNodeVersionAction, - PluginPreviewAction + ViewNodeVersionAction } from '@alfresco/aca-shared/store'; -import { Router, UrlTree, UrlSegmentGroup, PRIMARY_OUTLET, UrlSegment } from '@angular/router'; -import { Store, createSelector } from '@ngrx/store'; +import { PRIMARY_OUTLET, Router, UrlSegment, UrlSegmentGroup, UrlTree } from '@angular/router'; +import { createSelector, Store } from '@ngrx/store'; import { AppExtensionService } from '@alfresco/aca-shared'; import { MatDialog } from '@angular/material/dialog'; @@ -48,13 +48,11 @@ export const fileToPreview = createSelector(getAppSelection, getCurrentFolder, ( @Injectable() export class ViewerEffects { - constructor( - private store: Store, - private actions$: Actions, - private router: Router, - private extensions: AppExtensionService, - private dialog: MatDialog - ) {} + private store = inject(Store); + private actions$ = inject(Actions); + private router = inject(Router); + private extensions = inject(AppExtensionService); + private dialog = inject(MatDialog); fullscreenViewer$ = createEffect( () => diff --git a/projects/aca-shared/store/src/effects/dialog.effects.ts b/projects/aca-shared/store/src/effects/dialog.effects.ts index 1af7169a66..3bd4ba6884 100644 --- a/projects/aca-shared/store/src/effects/dialog.effects.ts +++ b/projects/aca-shared/store/src/effects/dialog.effects.ts @@ -22,8 +22,8 @@ * from Hyland Software. If not, see . */ -import { Actions, ofType, createEffect } from '@ngrx/effects'; -import { Injectable } from '@angular/core'; +import { Actions, createEffect, ofType } from '@ngrx/effects'; +import { inject, Injectable } from '@angular/core'; import { map } from 'rxjs/operators'; import { MatDialog } from '@angular/material/dialog'; import { CloseModalDialogsAction } from '../actions/app.actions'; @@ -31,7 +31,8 @@ import { AppActionTypes } from '../actions/app-action-types'; @Injectable() export class DialogEffects { - constructor(private actions$: Actions, private matDialog: MatDialog) {} + private actions$ = inject(Actions); + private matDialog = inject(MatDialog); closeAll$ = createEffect( () => diff --git a/projects/aca-shared/store/src/effects/router.effects.ts b/projects/aca-shared/store/src/effects/router.effects.ts index 624ec58291..bf6e664fef 100644 --- a/projects/aca-shared/store/src/effects/router.effects.ts +++ b/projects/aca-shared/store/src/effects/router.effects.ts @@ -22,21 +22,24 @@ * from Hyland Software. If not, see . */ -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { Router } from '@angular/router'; -import { Actions, ofType, createEffect } from '@ngrx/effects'; +import { Actions, createEffect, ofType } from '@ngrx/effects'; import { Node, PathInfo } from '@alfresco/js-api'; import { map } from 'rxjs/operators'; import { Store } from '@ngrx/store'; import { AppStore } from '../states/app.state'; import { Location } from '@angular/common'; -import { NavigateUrlAction, NavigateRouteAction, NavigateToFolder, NavigateToParentFolder, NavigateToPreviousPage } from '../actions/router.actions'; +import { NavigateRouteAction, NavigateToFolder, NavigateToParentFolder, NavigateToPreviousPage, NavigateUrlAction } from '../actions/router.actions'; import { SnackbarErrorAction } from '../actions/snackbar.actions'; import { RouterActionTypes } from '../actions/router-action-types'; @Injectable() export class RouterEffects { - constructor(private store: Store, private actions$: Actions, private router: Router, private location: Location) {} + private store = inject(Store); + private actions$ = inject(Actions); + private router = inject(Router); + private location = inject(Location); navigateUrl$ = createEffect( () => diff --git a/projects/aca-shared/store/src/effects/snackbar.effects.ts b/projects/aca-shared/store/src/effects/snackbar.effects.ts index ee78e6a8d3..8be6313f7b 100644 --- a/projects/aca-shared/store/src/effects/snackbar.effects.ts +++ b/projects/aca-shared/store/src/effects/snackbar.effects.ts @@ -23,22 +23,20 @@ */ import { SnackbarContentComponent, SnackBarData, TranslationService } from '@alfresco/adf-core'; -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { MatSnackBar } from '@angular/material/snack-bar'; -import { Actions, ofType, createEffect } from '@ngrx/effects'; +import { Actions, createEffect, ofType } from '@ngrx/effects'; import { Store } from '@ngrx/store'; import { map } from 'rxjs/operators'; import { AppStore } from '../states/app.state'; -import { SnackbarInfoAction, SnackbarActionTypes, SnackbarWarningAction, SnackbarErrorAction, SnackbarAction } from '../actions/snackbar.actions'; +import { SnackbarAction, SnackbarActionTypes, SnackbarErrorAction, SnackbarInfoAction, SnackbarWarningAction } from '../actions/snackbar.actions'; @Injectable() export class SnackbarEffects { - constructor( - private store: Store, - private actions$: Actions, - private snackBar: MatSnackBar, - private translationService: TranslationService - ) {} + private store = inject(Store); + private actions$ = inject(Actions); + private snackBar = inject(MatSnackBar); + private translationService = inject(TranslationService); infoEffect = createEffect( () =>