From 24ba08b78d3bbfc0bc8c55b987ec9e9da960d6ea Mon Sep 17 00:00:00 2001 From: dominikiwanekhyland <141320833+dominikiwanekhyland@users.noreply.github.com> Date: Tue, 23 Jul 2024 11:59:55 +0530 Subject: [PATCH] refactor DI into inject() methods (#3954) --- .../ms-office/src/effects/aos.effects.ts | 7 +++-- .../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/viewer.effects.ts | 30 +++++++++---------- .../store/src/effects/snackbar.effects.ts | 16 +++++----- 6 files changed, 44 insertions(+), 46 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/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/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/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( () =>