Skip to content

Commit

Permalink
refactor DI into inject() methods (#3954)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikiwanekhyland authored and swapnil-verma-gl committed Aug 1, 2024
1 parent b5e1700 commit 68d749f
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 124 deletions.
7 changes: 4 additions & 3 deletions projects/aca-content/ms-office/src/effects/aos.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

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';
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(
() =>
Expand Down
7 changes: 4 additions & 3 deletions projects/aca-content/src/lib/store/effects/app.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

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, ReloadDocumentListAction, ResetSelectionAction } from '@alfresco/aca-shared/store';
import { AppHookService } from '@alfresco/aca-shared';

@Injectable()
export class AppEffects {
constructor(private actions$: Actions, private appHookService: AppHookService) {}
actions$ = inject(Actions);
appHookService = inject(AppHookService);

reload = createEffect(
() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

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';
Expand All @@ -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(
() =>
Expand Down
18 changes: 8 additions & 10 deletions projects/aca-content/src/lib/store/effects/download.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,24 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

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';
import { ContentUrlService } from '../../services/content-url.service';

@Injectable()
export class DownloadEffects {
constructor(
private store: Store<AppStore>,
private actions$: Actions,
private contentApi: ContentApiService,
private dialog: MatDialog,
private contentUrlService: ContentUrlService
) {}
private store = inject(Store<AppStore>);
private actions$ = inject(Actions);
private contentApi = inject(ContentApiService);
private dialog = inject(MatDialog);
private contentUrlService = inject(ContentUrlService);

downloadNode$ = createEffect(
() =>
Expand Down
10 changes: 6 additions & 4 deletions projects/aca-content/src/lib/store/effects/favorite.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

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<AppStore>, private actions$: Actions, private content: ContentManagementService) {}
private store = inject(Store<AppStore>);
private actions$ = inject(Actions);
private content = inject(ContentManagementService);

addFavorite$ = createEffect(
() =>
Expand Down
18 changes: 8 additions & 10 deletions projects/aca-content/src/lib/store/effects/library.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,27 @@ 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';
import { ContentManagementService } from '../../services/content-management.service';

@Injectable()
export class LibraryEffects {
constructor(
private store: Store<AppStore>,
private actions$: Actions,
private content: ContentManagementService,
private contentApi: ContentApiService
) {}
private store = inject(Store<AppStore>);
private actions$ = inject(Actions);
private content = inject(ContentManagementService);
private contentApi = inject(ContentApiService);

deleteLibrary$ = createEffect(
() =>
Expand Down
52 changes: 25 additions & 27 deletions projects/aca-content/src/lib/store/effects/node.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,50 +22,48 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

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';
import { NavigationEnd, Router } from '@angular/router';

@Injectable()
export class NodeEffects {
constructor(
private store: Store<AppStore>,
private actions$: Actions,
private router: Router,
private contentService: ContentManagementService,
private renditionViewer: RenditionService
) {}
store = inject(Store<AppStore>);
actions$ = inject(Actions);
router = inject(Router);
contentService = inject(ContentManagementService);
renditionViewer = inject(RenditionService);

shareNode$ = createEffect(
() =>
Expand Down
8 changes: 5 additions & 3 deletions projects/aca-content/src/lib/store/effects/search.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,18 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

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';
import { SearchNavigationService } from '../../components/search/search-navigation.service';

@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(
() =>
Expand Down
32 changes: 15 additions & 17 deletions projects/aca-content/src/lib/store/effects/template.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,25 @@
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
*/

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()
Expand All @@ -51,14 +51,12 @@ export class TemplateEffects {
return this._nodesApi;
}

constructor(
private matDialog: MatDialog,
private appHookService: AppHookService,
private store: Store<AppStore>,
private apiService: AlfrescoApiService,
private actions$: Actions,
private nodeTemplateService: NodeTemplateService
) {}
private matDialog = inject(MatDialog);
private appHookService = inject(AppHookService);
private store = inject(Store<AppStore>);
private apiService = inject(AlfrescoApiService);
private actions$ = inject(Actions);
private nodeTemplateService = inject(NodeTemplateService);

fileFromTemplate$ = createEffect(
() =>
Expand Down
27 changes: 13 additions & 14 deletions projects/aca-content/src/lib/store/effects/upload.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<AppStore>,
private actions$: Actions,
private ngZone: NgZone,
private uploadService: UploadService,
rendererFactory: RendererFactory2,
private contentService: ContentManagementService
) {
const renderer = rendererFactory.createRenderer(null, null);
private store = inject(Store<AppStore>);
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';
Expand Down
Loading

0 comments on commit 68d749f

Please sign in to comment.