[AAE-7145] upgrade to Ngrx 10 (#2479)

* upgrade to ngrx 10

* fix auth proxy

* migrate effects to newer syntax
This commit is contained in:
Denys Vuika 2022-03-24 11:36:21 +00:00 committed by GitHub
parent 305ec58e2b
commit 1727554517
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 975 additions and 759 deletions

View File

@ -10,6 +10,17 @@ module.exports = {
"^/alfresco/alfresco": ""
},
"changeOrigin": true,
'logLevel': 'debug'
'logLevel': 'debug',
onProxyReq: function(request) {
if(request["method"] !== "GET")
request.setHeader("origin", APP_CONFIG_ECM_HOST);
},
// workaround for REPO-2260
onProxyRes: function (proxyRes) {
const header = proxyRes.headers['www-authenticate'];
if (header && header.startsWith('Basic')) {
proxyRes.headers['www-authenticate'] = 'x' + header;
}
}
}
};

View File

@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Effect, Actions, ofType } from '@ngrx/effects';
import { Actions, ofType, createEffect } from '@ngrx/effects';
import { Injectable } from '@angular/core';
import { map } from 'rxjs/operators';
import { AppActionTypes, LogoutAction, ReloadDocumentListAction, ResetSelectionAction } from '@alfresco/aca-shared/store';
@ -35,24 +35,31 @@ import { AppHookService } from '@alfresco/aca-shared';
export class AppEffects {
constructor(private actions$: Actions, private auth: AuthenticationService, private router: Router, private appHookService: AppHookService) {}
@Effect({ dispatch: false })
reload = this.actions$.pipe(
reload = createEffect(
() =>
this.actions$.pipe(
ofType<ReloadDocumentListAction>(AppActionTypes.ReloadDocumentList),
map((action) => {
this.appHookService.reload.next(action);
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
resetSelection = this.actions$.pipe(
resetSelection = createEffect(
() =>
this.actions$.pipe(
ofType<ResetSelectionAction>(AppActionTypes.ResetSelection),
map((action) => {
this.appHookService.reset.next(action);
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
logout$ = this.actions$.pipe(
logout$ = createEffect(
() =>
this.actions$.pipe(
ofType<LogoutAction>(AppActionTypes.Logout),
map(() => {
this.auth.logout().subscribe(
@ -60,6 +67,8 @@ export class AppEffects {
() => this.redirectToLogin()
);
})
),
{ dispatch: false }
);
private redirectToLogin(): Promise<boolean> {

View File

@ -25,7 +25,7 @@
import { ContextMenuActionTypes, ContextMenu } from '@alfresco/aca-shared/store';
import { Injectable } from '@angular/core';
import { Actions, Effect, ofType } from '@ngrx/effects';
import { Actions, ofType, createEffect } 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';
@ -36,8 +36,9 @@ export class ContextMenuEffects {
constructor(private contextMenuService: ContextMenuService, private actions$: Actions) {}
@Effect({ dispatch: false })
contextMenu$ = this.actions$.pipe(
contextMenu$ = createEffect(
() =>
this.actions$.pipe(
ofType<ContextMenu>(ContextMenuActionTypes.ContextMenu),
map((action) => {
if (this.overlayRef) {
@ -51,5 +52,7 @@ export class ContextMenuEffects {
panelClass: 'cdk-overlay-pane'
});
})
),
{ dispatch: false }
);
}

View File

@ -28,7 +28,7 @@ import { DownloadZipDialogComponent } from '@alfresco/adf-core';
import { MinimalNodeEntity, Version } from '@alfresco/js-api';
import { Injectable } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { Actions, Effect, ofType } from '@ngrx/effects';
import { Actions, ofType, createEffect } from '@ngrx/effects';
import { Store } from '@ngrx/store';
import { map, take } from 'rxjs/operators';
import { ContentApiService } from '@alfresco/aca-shared';
@ -44,8 +44,9 @@ export class DownloadEffects {
private contentUrlService: ContentUrlService
) {}
@Effect({ dispatch: false })
downloadNode$ = this.actions$.pipe(
downloadNode$ = createEffect(
() =>
this.actions$.pipe(
ofType<DownloadNodesAction>(NodeActionTypes.Download),
map((action) => {
if (action.payload && action.payload.length > 0) {
@ -70,6 +71,8 @@ export class DownloadEffects {
});
}
})
),
{ dispatch: false }
);
private downloadNodes(toDownload: Array<MinimalNodeEntity>) {

View File

@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Effect, Actions, ofType } from '@ngrx/effects';
import { Actions, ofType, createEffect } from '@ngrx/effects';
import { Injectable } from '@angular/core';
import { map, take } from 'rxjs/operators';
import { AppStore, NodeActionTypes, AddFavoriteAction, RemoveFavoriteAction, getAppSelection } from '@alfresco/aca-shared/store';
@ -34,8 +34,9 @@ import { ContentManagementService } from '../../services/content-management.serv
export class FavoriteEffects {
constructor(private store: Store<AppStore>, private actions$: Actions, private content: ContentManagementService) {}
@Effect({ dispatch: false })
addFavorite$ = this.actions$.pipe(
addFavorite$ = createEffect(
() =>
this.actions$.pipe(
ofType<AddFavoriteAction>(NodeActionTypes.AddFavorite),
map((action) => {
if (action.payload && action.payload.length > 0) {
@ -51,10 +52,13 @@ export class FavoriteEffects {
});
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
removeFavorite$ = this.actions$.pipe(
removeFavorite$ = createEffect(
() =>
this.actions$.pipe(
ofType<RemoveFavoriteAction>(NodeActionTypes.RemoveFavorite),
map((action) => {
if (action.payload && action.payload.length > 0) {
@ -70,5 +74,7 @@ export class FavoriteEffects {
});
}
})
),
{ dispatch: false }
);
}

View File

@ -36,7 +36,7 @@ import {
getAppSelection
} from '@alfresco/aca-shared/store';
import { Injectable } from '@angular/core';
import { Actions, Effect, ofType } from '@ngrx/effects';
import { Actions, ofType, createEffect } from '@ngrx/effects';
import { Store } from '@ngrx/store';
import { map, mergeMap, take } from 'rxjs/operators';
import { ContentApiService } from '@alfresco/aca-shared';
@ -51,8 +51,9 @@ export class LibraryEffects {
private contentApi: ContentApiService
) {}
@Effect({ dispatch: false })
deleteLibrary$ = this.actions$.pipe(
deleteLibrary$ = createEffect(
() =>
this.actions$.pipe(
ofType<DeleteLibraryAction>(LibraryActionTypes.Delete),
map((action) => {
if (action.payload) {
@ -68,10 +69,13 @@ export class LibraryEffects {
});
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
leaveLibrary$ = this.actions$.pipe(
leaveLibrary$ = createEffect(
() =>
this.actions$.pipe(
ofType<LeaveLibraryAction>(LibraryActionTypes.Leave),
map((action) => {
if (action.payload) {
@ -87,17 +91,23 @@ export class LibraryEffects {
});
}
})
),
{ dispatch: false }
);
@Effect()
createLibrary$ = this.actions$.pipe(
createLibrary$ = createEffect(
() =>
this.actions$.pipe(
ofType<CreateLibraryAction>(LibraryActionTypes.Create),
mergeMap(() => this.content.createLibrary()),
map((libraryId) => new NavigateLibraryAction(libraryId))
),
{ dispatch: true }
);
@Effect({ dispatch: false })
navigateLibrary$ = this.actions$.pipe(
navigateLibrary$ = createEffect(
() =>
this.actions$.pipe(
ofType<NavigateLibraryAction>(LibraryActionTypes.Navigate),
map((action) => {
const libraryId = action.payload;
@ -116,10 +126,13 @@ export class LibraryEffects {
);
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
updateLibrary$ = this.actions$.pipe(
updateLibrary$ = createEffect(
() =>
this.actions$.pipe(
ofType<UpdateLibraryAction>(LibraryActionTypes.Update),
map((action) => {
this.store
@ -140,5 +153,7 @@ export class LibraryEffects {
}
});
})
),
{ dispatch: false }
);
}

View File

@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Effect, Actions, ofType } from '@ngrx/effects';
import { Actions, ofType, createEffect } from '@ngrx/effects';
import { Injectable } from '@angular/core';
import { map, take } from 'rxjs/operators';
import { Store } from '@ngrx/store';
@ -62,8 +62,9 @@ export class NodeEffects {
private viewUtils: ViewUtilService
) {}
@Effect({ dispatch: false })
shareNode$ = this.actions$.pipe(
shareNode$ = createEffect(
() =>
this.actions$.pipe(
ofType<ShareNodeAction>(NodeActionTypes.Share),
map((action) => {
if (action.payload) {
@ -79,10 +80,13 @@ export class NodeEffects {
});
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
unshareNodes$ = this.actions$.pipe(
unshareNodes$ = createEffect(
() =>
this.actions$.pipe(
ofType<UnshareNodesAction>(NodeActionTypes.Unshare),
map((action) => {
if (action && action.payload && action.payload.length > 0) {
@ -98,10 +102,13 @@ export class NodeEffects {
});
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
purgeDeletedNodes$ = this.actions$.pipe(
purgeDeletedNodes$ = createEffect(
() =>
this.actions$.pipe(
ofType<PurgeDeletedNodesAction>(NodeActionTypes.PurgeDeleted),
map((action) => {
if (action && action.payload && action.payload.length > 0) {
@ -117,10 +124,13 @@ export class NodeEffects {
});
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
restoreDeletedNodes$ = this.actions$.pipe(
restoreDeletedNodes$ = createEffect(
() =>
this.actions$.pipe(
ofType<RestoreDeletedNodesAction>(NodeActionTypes.RestoreDeleted),
map((action) => {
if (action && action.payload && action.payload.length > 0) {
@ -136,10 +146,13 @@ export class NodeEffects {
});
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
deleteNodes$ = this.actions$.pipe(
deleteNodes$ = createEffect(
() =>
this.actions$.pipe(
ofType<DeleteNodesAction>(NodeActionTypes.Delete),
map((action) => {
if (action && action.payload && action.payload.length > 0) {
@ -155,20 +168,26 @@ export class NodeEffects {
});
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
undoDeleteNodes$ = this.actions$.pipe(
undoDeleteNodes$ = createEffect(
() =>
this.actions$.pipe(
ofType<UndoDeleteNodesAction>(NodeActionTypes.UndoDelete),
map((action) => {
if (action.payload.length > 0) {
this.contentService.undoDeleteNodes(action.payload);
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
createFolder$ = this.actions$.pipe(
createFolder$ = createEffect(
() =>
this.actions$.pipe(
ofType<CreateFolderAction>(NodeActionTypes.CreateFolder),
map((action) => {
if (action.payload) {
@ -184,10 +203,13 @@ export class NodeEffects {
});
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
editFolder$ = this.actions$.pipe(
editFolder$ = createEffect(
() =>
this.actions$.pipe(
ofType<EditFolderAction>(NodeActionTypes.EditFolder),
map((action) => {
if (action.payload) {
@ -203,10 +225,13 @@ export class NodeEffects {
});
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
copyNodes$ = this.actions$.pipe(
copyNodes$ = createEffect(
() =>
this.actions$.pipe(
ofType<CopyNodesAction>(NodeActionTypes.Copy),
map((action) => {
if (action.payload && action.payload.length > 0) {
@ -222,10 +247,13 @@ export class NodeEffects {
});
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
moveNodes$ = this.actions$.pipe(
moveNodes$ = createEffect(
() =>
this.actions$.pipe(
ofType<MoveNodesAction>(NodeActionTypes.Move),
map((action) => {
if (action.payload && action.payload.length > 0) {
@ -241,10 +269,13 @@ export class NodeEffects {
});
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
managePermissions$ = this.actions$.pipe(
managePermissions$ = createEffect(
() =>
this.actions$.pipe(
ofType<ManagePermissionsAction>(NodeActionTypes.ManagePermissions),
map((action) => {
if (action && action.payload) {
@ -262,10 +293,13 @@ export class NodeEffects {
});
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
expandInfoDrawer$ = this.actions$.pipe(
expandInfoDrawer$ = createEffect(
() =>
this.actions$.pipe(
ofType<ExpandInfoDrawerAction>(NodeActionTypes.ExpandInfoDrawer),
map((action) => {
if (action && action.payload) {
@ -283,10 +317,13 @@ export class NodeEffects {
});
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
manageVersions$ = this.actions$.pipe(
manageVersions$ = createEffect(
() =>
this.actions$.pipe(
ofType<ManageVersionsAction>(NodeActionTypes.ManageVersions),
map((action) => {
if (action && action.payload) {
@ -302,10 +339,13 @@ export class NodeEffects {
});
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
printFile$ = this.actions$.pipe(
printFile$ = createEffect(
() =>
this.actions$.pipe(
ofType<PrintFileAction>(NodeActionTypes.PrintFile),
map((action) => {
if (action && action.payload) {
@ -321,10 +361,13 @@ export class NodeEffects {
});
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
unlockWrite$ = this.actions$.pipe(
unlockWrite$ = createEffect(
() =>
this.actions$.pipe(
ofType<UnlockWriteAction>(NodeActionTypes.UnlockForWriting),
map((action) => {
if (action && action.payload) {
@ -340,10 +383,13 @@ export class NodeEffects {
});
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
aspectList$ = this.actions$.pipe(
aspectList$ = createEffect(
() =>
this.actions$.pipe(
ofType<ManageAspectsAction>(NodeActionTypes.ChangeAspects),
map((action) => {
if (action && action.payload) {
@ -359,6 +405,8 @@ export class NodeEffects {
});
}
})
),
{ dispatch: false }
);
printFile(node: any) {

View File

@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Effect, Actions, ofType } from '@ngrx/effects';
import { Actions, ofType, createEffect } from '@ngrx/effects';
import { Injectable } from '@angular/core';
import { map } from 'rxjs/operators';
import { SearchActionTypes, SearchByTermAction, SearchOptionIds } from '@alfresco/aca-shared/store';
@ -33,8 +33,9 @@ import { Router } from '@angular/router';
export class SearchEffects {
constructor(private actions$: Actions, private router: Router) {}
@Effect({ dispatch: false })
searchByTerm$ = this.actions$.pipe(
searchByTerm$ = createEffect(
() =>
this.actions$.pipe(
ofType<SearchByTermAction>(SearchActionTypes.SearchByTerm),
map((action) => {
const query = action.payload.replace(/[(]/g, '%28').replace(/[)]/g, '%29');
@ -47,5 +48,7 @@ export class SearchEffects {
this.router.navigateByUrl('/search;q=' + encodeURIComponent(query));
}
})
),
{ dispatch: false }
);
}

View File

@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Effect, Actions, ofType } from '@ngrx/effects';
import { Actions, ofType, createEffect } from '@ngrx/effects';
import { Injectable } from '@angular/core';
import { map, switchMap, debounceTime, take, catchError } from 'rxjs/operators';
import { Store } from '@ngrx/store';
@ -46,7 +46,7 @@ import { MatDialog } from '@angular/material/dialog';
@Injectable()
export class TemplateEffects {
_nodesApi: NodesApi;
private _nodesApi: NodesApi;
get nodesApi(): NodesApi {
this._nodesApi = this._nodesApi ?? new NodesApi(this.apiService.getInstance());
return this._nodesApi;
@ -61,8 +61,9 @@ export class TemplateEffects {
private nodeTemplateService: NodeTemplateService
) {}
@Effect({ dispatch: false })
fileFromTemplate$ = this.actions$.pipe(
fileFromTemplate$ = createEffect(
() =>
this.actions$.pipe(
ofType<FileFromTemplate>(TemplateActionTypes.FileFromTemplate),
map(() => {
this.openDialog({
@ -70,10 +71,13 @@ export class TemplateEffects {
selectionType: 'file'
});
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
folderFromTemplate$ = this.actions$.pipe(
folderFromTemplate$ = createEffect(
() =>
this.actions$.pipe(
ofType<FolderFromTemplate>(TemplateActionTypes.FolderFromTemplate),
map(() =>
this.openDialog({
@ -81,10 +85,13 @@ export class TemplateEffects {
selectionType: 'folder'
})
)
),
{ dispatch: false }
);
@Effect({ dispatch: false })
createFromTemplate$ = this.actions$.pipe(
createFromTemplate$ = createEffect(
() =>
this.actions$.pipe(
ofType<CreateFromTemplate>(TemplateActionTypes.CreateFromTemplate),
map((action) => {
this.store
@ -99,15 +106,20 @@ export class TemplateEffects {
}
});
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
createFromTemplateSuccess$ = this.actions$.pipe(
createFromTemplateSuccess$ = createEffect(
() =>
this.actions$.pipe(
ofType<CreateFromTemplateSuccess>(TemplateActionTypes.CreateFromTemplateSuccess),
map((payload) => {
this.matDialog.closeAll();
this.appHookService.reload.next(payload.node);
})
),
{ dispatch: false }
);
private openDialog(config: TemplateDialogConfig) {

View File

@ -35,7 +35,7 @@ import {
} from '@alfresco/aca-shared/store';
import { FileModel, FileUtils, UploadService } from '@alfresco/adf-core';
import { Injectable, NgZone, RendererFactory2 } from '@angular/core';
import { Actions, Effect, ofType } from '@ngrx/effects';
import { Actions, ofType, createEffect } from '@ngrx/effects';
import { Store } from '@ngrx/store';
import { of } from 'rxjs';
import { catchError, map, take } from 'rxjs/operators';
@ -85,24 +85,31 @@ export class UploadEffects {
renderer.appendChild(document.body, this.folderInput);
}
@Effect({ dispatch: false })
uploadFiles$ = this.actions$.pipe(
uploadFiles$ = createEffect(
() =>
this.actions$.pipe(
ofType<UploadFilesAction>(UploadActionTypes.UploadFiles),
map(() => {
this.fileInput.click();
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
uploadFolder$ = this.actions$.pipe(
uploadFolder$ = createEffect(
() =>
this.actions$.pipe(
ofType<UploadFolderAction>(UploadActionTypes.UploadFolder),
map(() => {
this.folderInput.click();
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
uploadVersion$ = this.actions$.pipe(
uploadVersion$ = createEffect(
() =>
this.actions$.pipe(
ofType<UploadFileVersionAction>(UploadActionTypes.UploadFileVersion),
map((action) => {
if (action?.payload) {
@ -113,6 +120,8 @@ export class UploadEffects {
this.fileVersionInput.click();
}
})
),
{ dispatch: false }
);
uploadVersion() {

View File

@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Effect, Actions, ofType } from '@ngrx/effects';
import { Actions, ofType, createEffect } from '@ngrx/effects';
import { Injectable } from '@angular/core';
import { map, take, tap } from 'rxjs/operators';
import {
@ -57,16 +57,20 @@ export class ViewerEffects {
private dialog: MatDialog
) {}
@Effect({ dispatch: false })
fullscreenViewer$ = this.actions$.pipe(
fullscreenViewer$ = createEffect(
() =>
this.actions$.pipe(
ofType<FullscreenViewerAction>(ViewerActionTypes.FullScreen),
map(() => {
this.enterFullScreen();
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
viewNode$ = this.actions$.pipe(
viewNode$ = createEffect(
() =>
this.actions$.pipe(
ofType<ViewNodeAction>(ViewerActionTypes.ViewNode),
map((action) => {
if (action.viewNodeExtras) {
@ -89,10 +93,13 @@ export class ViewerEffects {
this.router.navigate(['view', { outlets: { viewer: [action.nodeId] } }]);
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
viewFile$ = this.actions$.pipe(
viewFile$ = createEffect(
() =>
this.actions$.pipe(
ofType<ViewFileAction>(ViewerActionTypes.ViewFile),
map((action) => {
if (action.payload && action.payload.entry) {
@ -117,10 +124,13 @@ export class ViewerEffects {
});
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
viewNodeVersion$ = this.actions$.pipe(
viewNodeVersion$ = createEffect(
() =>
this.actions$.pipe(
ofType<ViewNodeVersionAction>(ViewerActionTypes.ViewNodeVersion),
map((action) => {
this.dialog.closeAll();
@ -142,10 +152,13 @@ export class ViewerEffects {
this.router.navigate(['view', { outlets: { viewer: [action.nodeId, action.versionId] } }]);
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
pluginPreview$ = this.actions$.pipe(
pluginPreview$ = createEffect(
() =>
this.actions$.pipe(
ofType<PluginPreviewAction>(ViewerActionTypes.PluginPreview),
tap((action) => {
this.router.navigate([
@ -157,6 +170,8 @@ export class ViewerEffects {
}
]);
})
),
{ dispatch: false }
);
private displayPreview(nodeId: string, parentId: string) {

View File

@ -63,14 +63,17 @@ See also:
Update `src/app/store/effects/app.effects.ts`:
```ts
import { createEffect } from '@ngrx/effects';
import { ShowMydDialogAction, SHOW_MY_DIALOG } from '../actions/app.actions';
@Injectable()
export class AppEffects {
@Effect({ dispatch: false })
showMyDialog$ = this.actions$.pipe(
showMyDialog$ = createEffect(
() => this.actions$.pipe(
ofType<ShowMydDialogAction>(SHOW_MY_DIALOG),
map(() => {})
),
{ dispatch: false }
);
}
```
@ -82,6 +85,7 @@ See also:
Update to raise a dialog
```ts
import { createEffect } from '@ngrx/effects';
import { MatDialog } from '@angular/material/dialog';
import { MyExtensionDialogComponent } from '../../dialogs/my-extension-dialog/my-extension-dialog.component';
@ -89,12 +93,14 @@ import { MyExtensionDialogComponent } from '../../dialogs/my-extension-dialog/my
export class AppEffects {
constructor(private dialog: MatDialog) {}
@Effect({ dispatch: false })
showMyDialog$ = this.actions$.pipe(
showMyDialog$ = createEffect(
() => this.actions$.pipe(
ofType<ShowMydDialogAction>(SHOW_MY_DIALOG),
map(() => {
this.dialog.open(MyExtensionDialogComponent)
})
),
{ dispatch: false }
);
}
```

View File

@ -189,14 +189,17 @@ export class ShowMydDialogAction implements Action {
`src/app/store/effects/app.effects.ts` を更新します:
```ts
import { createEffect } from '@ngrx/effects';
import { ShowMydDialogAction, SHOW_MY_DIALOG } from '../actions/app.actions';
@Injectable()
export class AppEffects {
@Effect({ dispatch: false })
showMyDialog$ = this.actions$.pipe(
showMyDialog$ = createEffect(
() => this.actions$.pipe(
ofType<ShowMydDialogAction>(SHOW_MY_DIALOG),
map(() => {})
),
{ dispatch: false }
);
}
```
@ -208,6 +211,7 @@ export class AppEffects {
ダイアログを表示するための更新
```ts
import { createEffect } from '@ngrx/effects';
import { MatDialog } from '@angular/material/dialog';
import { MyExtensionDialogComponent } from '../../dialogs/my-extension-dialog/my-extension-dialog.component';
@ -215,12 +219,14 @@ import { MyExtensionDialogComponent } from '../../dialogs/my-extension-dialog/my
export class AppEffects {
constructor(private dialog: MatDialog) {}
@Effect({ dispatch: false })
showMyDialog$ = this.actions$.pipe(
showMyDialog$ = createEffect(
() => this.actions$.pipe(
ofType<ShowMydDialogAction>(SHOW_MY_DIALOG),
map(() => {
this.dialog.open(MyExtensionDialogComponent)
})
),
{ dispatch: false }
);
}
```

View File

@ -74,14 +74,17 @@ export class ShowMydDialogAction implements Action {
`src/app/store/effects/app.effects.ts` を更新します:
```ts
import { createEffect } from '@ngrx/effects';
import { ShowMydDialogAction, SHOW_MY_DIALOG } from '../actions/app.actions';
@Injectable()
export class AppEffects {
@Effect({ dispatch: false })
showMyDialog$ = this.actions$.pipe(
showMyDialog$ = createEffect(
() => this.actions$.pipe(
ofType<ShowMydDialogAction>(SHOW_MY_DIALOG),
map(() => {})
),
{ dispatch: false }
);
}
```
@ -93,6 +96,7 @@ export class AppEffects {
ダイアログを表示するための更新
```ts
import { createEffect } from '@ngrx/effects';
import { MatDialog } from '@angular/material/dialog';
import { MyExtensionDialogComponent } from '../../dialogs/my-extension-dialog/my-extension-dialog.component';
@ -100,12 +104,14 @@ import { MyExtensionDialogComponent } from '../../dialogs/my-extension-dialog/my
export class AppEffects {
constructor(private dialog: MatDialog) {}
@Effect({ dispatch: false })
showMyDialog$ = this.actions$.pipe(
showMyDialog$ = createEffect(
() => this.actions$.pipe(
ofType<ShowMydDialogAction>(SHOW_MY_DIALOG),
map(() => {
this.dialog.open(MyExtensionDialogComponent)
})
),
{ dispatch: false }
);
}
```

View File

@ -63,14 +63,17 @@ See also:
Update `src/app/store/effects/app.effects.ts`:
```ts
import { createEffect } from '@ngrx/effects';
import { ShowMydDialogAction, SHOW_MY_DIALOG } from '../actions/app.actions';
@Injectable()
export class AppEffects {
@Effect({ dispatch: false })
showMyDialog$ = this.actions$.pipe(
showMyDialog$ = createEffect(
() => this.actions$.pipe(
ofType<ShowMydDialogAction>(SHOW_MY_DIALOG),
map(() => {})
),
{ dispatch: false }
);
}
```
@ -82,6 +85,7 @@ See also:
Update to raise a dialog
```ts
import { createEffect } from '@ngrx/effects';
import { MatDialog } from '@angular/material/dialog';
import { MyExtensionDialogComponent } from '../../dialogs/my-extension-dialog/my-extension-dialog.component';
@ -89,12 +93,14 @@ import { MyExtensionDialogComponent } from '../../dialogs/my-extension-dialog/my
export class AppEffects {
constructor(private dialog: MatDialog) {}
@Effect({ dispatch: false })
showMyDialog$ = this.actions$.pipe(
showMyDialog$ = createEffect(
() => this.actions$.pipe(
ofType<ShowMydDialogAction>(SHOW_MY_DIALOG),
map(() => {
this.dialog.open(MyExtensionDialogComponent)
})
),
{ dispatch: false }
);
}
```

62
package-lock.json generated
View File

@ -2693,24 +2693,36 @@
}
},
"@ngrx/effects": {
"version": "9.2.1",
"resolved": "https://registry.npmjs.org/@ngrx/effects/-/effects-9.2.1.tgz",
"integrity": "sha512-qWOnRYHdKzjCvcH6WOKra+KPlrMyS9ahoVvOSboJK7S3xzj9Pp5mgtcDBXqN9LlPbXDEzjZjFDJQMAtlP4c3Ig=="
"version": "10.1.2",
"resolved": "https://registry.npmjs.org/@ngrx/effects/-/effects-10.1.2.tgz",
"integrity": "sha512-6pX6FEzLlqdbtFVMbCvscsaL6QC/L95e72JKj76Xz+8V77UTlpVsxWyMo7YU9pM4EXNpBGmOpMs2xKjfBfK05Q==",
"requires": {
"tslib": "^2.0.0"
}
},
"@ngrx/router-store": {
"version": "9.2.1",
"resolved": "https://registry.npmjs.org/@ngrx/router-store/-/router-store-9.2.1.tgz",
"integrity": "sha512-r7IS7OqvM2/4HO2lDP96r0zMMgiF2iNXFJF38DMstGEp23BlRkcsNz+2PSgNT8B1YgTUjUAbtnhCSRxs/kl5kw=="
"version": "10.1.2",
"resolved": "https://registry.npmjs.org/@ngrx/router-store/-/router-store-10.1.2.tgz",
"integrity": "sha512-IBsZee5ZUmLbXkY/O4OjhJP1Q6mdu4lcLcQ9jeXsdCMH/Vvc0EGK+MlhsZrxv5+v2ZXb1bhtKsLBUsTovanLWA==",
"requires": {
"tslib": "^2.0.0"
}
},
"@ngrx/store": {
"version": "9.2.1",
"resolved": "https://registry.npmjs.org/@ngrx/store/-/store-9.2.1.tgz",
"integrity": "sha512-18mLKH7CAi5+F1zYbbxoCDKE8piCxZkwOoPlXEsq/LBKrZvYIvOeSlEXMjiUp3cCL3QOT27QvWIqQkIuE9b7mg=="
"version": "10.1.2",
"resolved": "https://registry.npmjs.org/@ngrx/store/-/store-10.1.2.tgz",
"integrity": "sha512-FUjN786ch4Qt9WgJ78ef7Yquq3mPCekgcWgZrs4ycZw1f+KdfTHLTk1bGDtO8A8CzOya5yTT7KhxbdVjbOS5ng==",
"requires": {
"tslib": "^2.0.0"
}
},
"@ngrx/store-devtools": {
"version": "9.2.1",
"resolved": "https://registry.npmjs.org/@ngrx/store-devtools/-/store-devtools-9.2.1.tgz",
"integrity": "sha512-f7/hg884uSKsXiQbcdBJS/3rpk1KKFmy6gR0OeCqxjkZRjSq/onCsEXPKURt7MqJcRYCiNA2rIHxF/fz2j+8Kg=="
"version": "10.1.2",
"resolved": "https://registry.npmjs.org/@ngrx/store-devtools/-/store-devtools-10.1.2.tgz",
"integrity": "sha512-HE681GuZ+lRgSXpgt7y7LKzsfu/+Tgy9yPZpaitvkhg+eCIjnN5Uvs1rWqETHYWnsKliW25yoqFUAVw+xb7hug==",
"requires": {
"tslib": "^2.0.0"
}
},
"@ngtools/webpack": {
"version": "10.2.3",
@ -18439,18 +18451,18 @@
}
},
"string.prototype.matchall": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.6.tgz",
"integrity": "sha512-6WgDX8HmQqvEd7J+G6VtAahhsQIssiZ8zl7zKh1VDMFyL3hRTJP4FTNA3RbIp2TOQ9AYNDcc7e3fH0Qbup+DBg==",
"version": "4.0.7",
"resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-4.0.7.tgz",
"integrity": "sha512-f48okCX7JiwVi1NXCVWcFnZgADDC/n2vePlQ/KUCNqCikLLilQvwjMO8+BHVKvgzH0JB0J9LEPgxOGT02RoETg==",
"dev": true,
"requires": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.3",
"es-abstract": "^1.19.1",
"get-intrinsic": "^1.1.1",
"has-symbols": "^1.0.2",
"has-symbols": "^1.0.3",
"internal-slot": "^1.0.3",
"regexp.prototype.flags": "^1.3.1",
"regexp.prototype.flags": "^1.4.1",
"side-channel": "^1.0.4"
},
"dependencies": {
@ -18482,6 +18494,12 @@
"unbox-primitive": "^1.0.1"
}
},
"has-symbols": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
"dev": true
},
"is-callable": {
"version": "1.2.4",
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.4.tgz",
@ -18512,6 +18530,16 @@
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.0.tgz",
"integrity": "sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g==",
"dev": true
},
"regexp.prototype.flags": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.4.1.tgz",
"integrity": "sha512-pMR7hBVUUGI7PMA37m2ofIdQCsomVnas+Jn5UPGAHQ+/LlwKm/aTLJHdasmHRzlfeZwHiAOaRSo2rbBDm3nNUQ==",
"dev": true,
"requires": {
"call-bind": "^1.0.2",
"define-properties": "^1.1.3"
}
}
}
},

View File

@ -43,10 +43,10 @@
"@angular/router": "10.0.4",
"@mat-datetimepicker/core": "5.1.1",
"@mat-datetimepicker/moment": "5.1.1",
"@ngrx/effects": "^9.2.0",
"@ngrx/router-store": "^9.2.0",
"@ngrx/store": "^9.2.0",
"@ngrx/store-devtools": "^9.2.0",
"@ngrx/effects": "^10.1.2",
"@ngrx/router-store": "^10.1.2",
"@ngrx/store": "^10.1.2",
"@ngrx/store-devtools": "^10.1.2",
"@ngx-translate/core": "^13.0.0",
"minimatch-browser": "^1.0.0",
"moment": "^2.27.0",

View File

@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { Effect, Actions, ofType } from '@ngrx/effects';
import { Actions, ofType, createEffect } from '@ngrx/effects';
import { Injectable } from '@angular/core';
import { map } from 'rxjs/operators';
import { MatDialog } from '@angular/material/dialog';
@ -33,9 +33,12 @@ import { CloseModalDialogsAction, AppActionTypes } from '../actions/app.actions'
export class DialogEffects {
constructor(private actions$: Actions, private matDialog: MatDialog) {}
@Effect({ dispatch: false })
closeAll$ = this.actions$.pipe(
closeAll$ = createEffect(
() =>
this.actions$.pipe(
ofType<CloseModalDialogsAction>(AppActionTypes.CloseModalDialogs),
map(() => this.matDialog.closeAll())
),
{ dispatch: false }
);
}

View File

@ -25,7 +25,7 @@
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { Actions, Effect, ofType } from '@ngrx/effects';
import { Actions, ofType, createEffect } from '@ngrx/effects';
import { MinimalNodeEntryEntity, PathInfoEntity } from '@alfresco/js-api';
import { map } from 'rxjs/operators';
import { Store } from '@ngrx/store';
@ -45,48 +45,63 @@ import { SnackbarErrorAction } from '../actions/snackbar.actions';
export class RouterEffects {
constructor(private store: Store<AppStore>, private actions$: Actions, private router: Router, private location: Location) {}
@Effect({ dispatch: false })
navigateUrl$ = this.actions$.pipe(
navigateUrl$ = createEffect(
() =>
this.actions$.pipe(
ofType<NavigateUrlAction>(RouterActionTypes.NavigateUrl),
map((action) => {
if (action.payload) {
this.router.navigateByUrl(action.payload);
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
navigateRoute$ = this.actions$.pipe(
navigateRoute$ = createEffect(
() =>
this.actions$.pipe(
ofType<NavigateRouteAction>(RouterActionTypes.NavigateRoute),
map((action) => {
this.router.navigate(action.payload);
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
navigateToFolder$ = this.actions$.pipe(
navigateToFolder$ = createEffect(
() =>
this.actions$.pipe(
ofType<NavigateToFolder>(RouterActionTypes.NavigateFolder),
map((action) => {
if (action.payload && action.payload.entry) {
this.navigateToFolder(action.payload.entry);
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
navigateToParentFolder$ = this.actions$.pipe(
navigateToParentFolder$ = createEffect(
() =>
this.actions$.pipe(
ofType<NavigateToParentFolder>(RouterActionTypes.NavigateParentFolder),
map((action) => {
if (action.payload && action.payload.entry) {
this.navigateToParentFolder(action.payload.entry);
}
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
navigateToPreviousPage$ = this.actions$.pipe(
navigateToPreviousPage$ = createEffect(
() =>
this.actions$.pipe(
ofType<NavigateToPreviousPage>(RouterActionTypes.NavigateToPreviousPage),
map(() => this.location.back())
),
{ dispatch: false }
);
private navigateToFolder(node: MinimalNodeEntryEntity) {

View File

@ -26,7 +26,7 @@
import { TranslationService } from '@alfresco/adf-core';
import { Injectable } from '@angular/core';
import { MatSnackBar } from '@angular/material/snack-bar';
import { Actions, Effect, ofType } from '@ngrx/effects';
import { Actions, ofType, createEffect } from '@ngrx/effects';
import { Store } from '@ngrx/store';
import { map } from 'rxjs/operators';
import { AppStore } from '../states/app.state';
@ -41,28 +41,37 @@ export class SnackbarEffects {
private translationService: TranslationService
) {}
@Effect({ dispatch: false })
infoEffect = this.actions$.pipe(
infoEffect = createEffect(
() =>
this.actions$.pipe(
ofType<SnackbarInfoAction>(SnackbarActionTypes.Info),
map((action: SnackbarInfoAction) => {
this.showSnackBar(action, 'adf-info-snackbar');
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
warningEffect = this.actions$.pipe(
warningEffect = createEffect(
() =>
this.actions$.pipe(
ofType<SnackbarWarningAction>(SnackbarActionTypes.Warning),
map((action: SnackbarWarningAction) => {
this.showSnackBar(action, 'adf-warning-snackbar');
})
),
{ dispatch: false }
);
@Effect({ dispatch: false })
errorEffect = this.actions$.pipe(
errorEffect = createEffect(
() =>
this.actions$.pipe(
ofType<SnackbarErrorAction>(SnackbarActionTypes.Error),
map((action: SnackbarErrorAction) => {
this.showSnackBar(action, 'adf-error-snackbar');
})
),
{ dispatch: false }
);
private showSnackBar(action: SnackbarAction, panelClass: string) {

View File

@ -24,7 +24,7 @@
*/
import { Injectable } from '@angular/core';
import { Actions, Effect, ofType } from '@ngrx/effects';
import { Actions, ofType, createEffect } from '@ngrx/effects';
import { map } from 'rxjs/operators';
import { AOS_ACTION, AosAction } from '../actions/aos.actions';
@ -34,13 +34,16 @@ import { AosEditOnlineService } from '../aos-extension.service';
export class AosEffects {
constructor(private actions$: Actions, private aosEditOnlineService: AosEditOnlineService) {}
@Effect({ dispatch: false })
openOffice$ = this.actions$.pipe(
openOffice$ = createEffect(
() =>
this.actions$.pipe(
ofType<AosAction>(AOS_ACTION),
map((action) => {
if (action.payload) {
this.aosEditOnlineService.onActionEditOnlineAos(action.payload);
}
})
),
{ dispatch: false }
);
}