[ACA-4022] Remove custom redirect strategy, the viewer doesn not reload (#1719)

* remove custom redirect strategy, the viewer doesn not reload

* Update extensions-data-loader.guard.ts

add return in case of no loaders

* remove the route strategy

* fix lint

* Fix link error

* Align unit test

Co-authored-by: Maurizio Vitale <maurizio.vitale@alfresco.com>
Co-authored-by: Andras Popovics <popovics@ndras.hu>
This commit is contained in:
Eugenio Romano
2020-10-06 17:45:03 +01:00
committed by GitHub
parent 50c76f21e7
commit ba2961157a
8 changed files with 12 additions and 247 deletions

View File

@@ -126,13 +126,15 @@ describe('ExtensionsDataLoaderGuard', () => {
return subject1.asObservable();
}
};
const extensionLoaderSpy = spyOn(extensionLoaders, 'fct1');
const extensionLoaderSpy = spyOn(extensionLoaders, 'fct1').and.callThrough();
const guard = new ExtensionsDataLoaderGuard([extensionLoaders.fct1]);
guard.canActivate(route).subscribe(emittedSpy, erroredSpy, completedSpy);
expect(extensionLoaderSpy).toHaveBeenCalled();
extensionLoaderSpy.calls.reset();
subject1.next(true);
subject1.complete();
guard.canActivate(route).subscribe(emittedSpy, erroredSpy, completedSpy);
expect(extensionLoaderSpy).not.toHaveBeenCalled();
});

View File

@@ -26,7 +26,7 @@
import { Injectable, InjectionToken, Inject } from '@angular/core';
import { CanActivate, ActivatedRouteSnapshot } from '@angular/router';
import { Observable, forkJoin, of } from 'rxjs';
import { map, catchError } from 'rxjs/operators';
import { tap, map, catchError } from 'rxjs/operators';
export type ExtensionLoaderCallback = (route: ActivatedRouteSnapshot) => Observable<boolean>;
@@ -50,9 +50,8 @@ export class ExtensionsDataLoaderGuard implements CanActivate {
canActivate(route: ActivatedRouteSnapshot): Observable<boolean> {
if (!this.invoked) {
this.invoked = true;
if (!this.extensionDataLoaders.length) {
this.invoked = true;
return of(true);
}
@@ -63,6 +62,7 @@ export class ExtensionsDataLoaderGuard implements CanActivate {
// So all callbacks need to emit before completion, otherwise forkJoin will short circuit
return forkJoin(...dataLoaderCallbacks).pipe(
map(() => true),
tap(() => (this.invoked = true)),
catchError((e) => {
// tslint:disable-next-line
console.error('Some of the extension data loader guards has been errored.');