mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-16 06:23:03 +00:00
fix issue where create com/col guards would redirect to 404 for the wrong reason
This commit is contained in:
@@ -5,8 +5,7 @@ import { hasNoValue, hasValue } from '../../shared/empty.util';
|
|||||||
import { CommunityDataService } from '../../core/data/community-data.service';
|
import { CommunityDataService } from '../../core/data/community-data.service';
|
||||||
import { RemoteData } from '../../core/data/remote-data';
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
import { Community } from '../../core/shared/community.model';
|
import { Community } from '../../core/shared/community.model';
|
||||||
import { getFinishedRemoteData } from '../../core/shared/operators';
|
import { map, tap, find } from 'rxjs/operators';
|
||||||
import { map, tap } from 'rxjs/operators';
|
|
||||||
import { Observable, of as observableOf } from 'rxjs';
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,18 +28,15 @@ export class CreateCollectionPageGuard implements CanActivate {
|
|||||||
this.router.navigate(['/404']);
|
this.router.navigate(['/404']);
|
||||||
return observableOf(false);
|
return observableOf(false);
|
||||||
}
|
}
|
||||||
const parent: Observable<RemoteData<Community>> = this.communityService.findById(parentID)
|
return this.communityService.findById(parentID)
|
||||||
.pipe(
|
.pipe(
|
||||||
getFinishedRemoteData(),
|
find((communityRD: RemoteData<Community>) => hasValue(communityRD.payload) || hasValue(communityRD.error)),
|
||||||
);
|
map((communityRD: RemoteData<Community>) => hasValue(communityRD) && communityRD.hasSucceeded && hasValue(communityRD.payload)),
|
||||||
|
tap((isValid: boolean) => {
|
||||||
return parent.pipe(
|
if (!isValid) {
|
||||||
map((communityRD: RemoteData<Community>) => hasValue(communityRD) && communityRD.hasSucceeded && hasValue(communityRD.payload)),
|
this.router.navigate(['/404']);
|
||||||
tap((isValid: boolean) => {
|
}
|
||||||
if (!isValid) {
|
})
|
||||||
this.router.navigate(['/404']);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -5,8 +5,7 @@ import { hasNoValue, hasValue } from '../../shared/empty.util';
|
|||||||
import { CommunityDataService } from '../../core/data/community-data.service';
|
import { CommunityDataService } from '../../core/data/community-data.service';
|
||||||
import { RemoteData } from '../../core/data/remote-data';
|
import { RemoteData } from '../../core/data/remote-data';
|
||||||
import { Community } from '../../core/shared/community.model';
|
import { Community } from '../../core/shared/community.model';
|
||||||
import { getFinishedRemoteData } from '../../core/shared/operators';
|
import { map, tap, find } from 'rxjs/operators';
|
||||||
import { map, tap } from 'rxjs/operators';
|
|
||||||
import { Observable, of as observableOf } from 'rxjs';
|
import { Observable, of as observableOf } from 'rxjs';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,18 +28,16 @@ export class CreateCommunityPageGuard implements CanActivate {
|
|||||||
return observableOf(true);
|
return observableOf(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const parent: Observable<RemoteData<Community>> = this.communityService.findById(parentID)
|
return this.communityService.findById(parentID)
|
||||||
.pipe(
|
.pipe(
|
||||||
getFinishedRemoteData(),
|
find((communityRD: RemoteData<Community>) => hasValue(communityRD.payload) || hasValue(communityRD.error)),
|
||||||
);
|
map((communityRD: RemoteData<Community>) => hasValue(communityRD) && communityRD.hasSucceeded && hasValue(communityRD.payload)),
|
||||||
|
tap((isValid: boolean) => {
|
||||||
return parent.pipe(
|
if (!isValid) {
|
||||||
map((communityRD: RemoteData<Community>) => hasValue(communityRD) && communityRD.hasSucceeded && hasValue(communityRD.payload)),
|
this.router.navigate(['/404']);
|
||||||
tap((isValid: boolean) => {
|
}
|
||||||
if (!isValid) {
|
|
||||||
this.router.navigate(['/404']);
|
|
||||||
}
|
}
|
||||||
})
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user