mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[AAE-7145] upgrade to Ngrx 10 (#2479)
* upgrade to ngrx 10 * fix auth proxy * migrate effects to newer syntax
This commit is contained in:
@@ -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(
|
||||
ofType<CloseModalDialogsAction>(AppActionTypes.CloseModalDialogs),
|
||||
map(() => this.matDialog.closeAll())
|
||||
closeAll$ = createEffect(
|
||||
() =>
|
||||
this.actions$.pipe(
|
||||
ofType<CloseModalDialogsAction>(AppActionTypes.CloseModalDialogs),
|
||||
map(() => this.matDialog.closeAll())
|
||||
),
|
||||
{ dispatch: false }
|
||||
);
|
||||
}
|
||||
|
@@ -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(
|
||||
ofType<NavigateUrlAction>(RouterActionTypes.NavigateUrl),
|
||||
map((action) => {
|
||||
if (action.payload) {
|
||||
this.router.navigateByUrl(action.payload);
|
||||
}
|
||||
})
|
||||
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(
|
||||
ofType<NavigateRouteAction>(RouterActionTypes.NavigateRoute),
|
||||
map((action) => {
|
||||
this.router.navigate(action.payload);
|
||||
})
|
||||
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(
|
||||
ofType<NavigateToFolder>(RouterActionTypes.NavigateFolder),
|
||||
map((action) => {
|
||||
if (action.payload && action.payload.entry) {
|
||||
this.navigateToFolder(action.payload.entry);
|
||||
}
|
||||
})
|
||||
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(
|
||||
ofType<NavigateToParentFolder>(RouterActionTypes.NavigateParentFolder),
|
||||
map((action) => {
|
||||
if (action.payload && action.payload.entry) {
|
||||
this.navigateToParentFolder(action.payload.entry);
|
||||
}
|
||||
})
|
||||
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(
|
||||
ofType<NavigateToPreviousPage>(RouterActionTypes.NavigateToPreviousPage),
|
||||
map(() => this.location.back())
|
||||
navigateToPreviousPage$ = createEffect(
|
||||
() =>
|
||||
this.actions$.pipe(
|
||||
ofType<NavigateToPreviousPage>(RouterActionTypes.NavigateToPreviousPage),
|
||||
map(() => this.location.back())
|
||||
),
|
||||
{ dispatch: false }
|
||||
);
|
||||
|
||||
private navigateToFolder(node: MinimalNodeEntryEntity) {
|
||||
|
@@ -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(
|
||||
ofType<SnackbarInfoAction>(SnackbarActionTypes.Info),
|
||||
map((action: SnackbarInfoAction) => {
|
||||
this.showSnackBar(action, 'adf-info-snackbar');
|
||||
})
|
||||
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(
|
||||
ofType<SnackbarWarningAction>(SnackbarActionTypes.Warning),
|
||||
map((action: SnackbarWarningAction) => {
|
||||
this.showSnackBar(action, 'adf-warning-snackbar');
|
||||
})
|
||||
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(
|
||||
ofType<SnackbarErrorAction>(SnackbarActionTypes.Error),
|
||||
map((action: SnackbarErrorAction) => {
|
||||
this.showSnackBar(action, 'adf-error-snackbar');
|
||||
})
|
||||
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) {
|
||||
|
Reference in New Issue
Block a user