mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-14 05:23:06 +00:00
[DURACOM-234] Fixes after migrating to functional guards
This commit is contained in:
@@ -9,6 +9,7 @@ import {
|
||||
Component,
|
||||
Injector,
|
||||
OnInit,
|
||||
runInInjectionContext,
|
||||
} from '@angular/core';
|
||||
import {
|
||||
ActivatedRoute,
|
||||
@@ -28,7 +29,6 @@ import {
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { RemoteData } from '../../core/data/remote-data';
|
||||
import { GenericConstructor } from '../../core/shared/generic-constructor';
|
||||
import { Item } from '../../core/shared/item.model';
|
||||
import {
|
||||
fadeIn,
|
||||
@@ -88,15 +88,10 @@ export class EditItemPageComponent implements OnInit {
|
||||
.map((child: Route) => {
|
||||
let enabled = observableOf(true);
|
||||
if (isNotEmpty(child.canActivate)) {
|
||||
enabled = observableCombineLatest(child.canActivate.map((guardConstructor: GenericConstructor<{
|
||||
canActivate: CanActivateFn;
|
||||
}>) => {
|
||||
const guard: {
|
||||
canActivate: CanActivateFn;
|
||||
} = this.injector.get<{
|
||||
canActivate: CanActivateFn;
|
||||
}>(guardConstructor);
|
||||
return guard.canActivate(this.route.snapshot, this.router.routerState.snapshot);
|
||||
enabled = observableCombineLatest(child.canActivate.map((guardFn: CanActivateFn) => {
|
||||
return runInInjectionContext(this.injector, () => {
|
||||
return guardFn(this.route.snapshot, this.router.routerState.snapshot);
|
||||
});
|
||||
}),
|
||||
).pipe(
|
||||
map((canActivateOutcomes: any[]) => canActivateOutcomes.every((e) => e === true)),
|
||||
|
Reference in New Issue
Block a user