mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-08 02:24:11 +00:00
Merge pull request #2271 from kshepherd/item_status_page_config_fix
ItemStatus component should handle missing config gracefully
This commit is contained in:
@@ -9,9 +9,9 @@ import { RemoteData } from '../../../core/data/remote-data';
|
|||||||
import { getItemEditRoute, getItemPageRoute } from '../../item-page-routing-paths';
|
import { getItemEditRoute, getItemPageRoute } from '../../item-page-routing-paths';
|
||||||
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||||
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
||||||
import { hasValue } from '../../../shared/empty.util';
|
import { hasValue, isNotEmpty } from '../../../shared/empty.util';
|
||||||
import {
|
import {
|
||||||
getAllSucceededRemoteDataPayload, getFirstSucceededRemoteData, getRemoteDataPayload,
|
getAllSucceededRemoteDataPayload, getFirstCompletedRemoteData, getFirstSucceededRemoteData, getRemoteDataPayload,
|
||||||
} from '../../../core/shared/operators';
|
} from '../../../core/shared/operators';
|
||||||
import { IdentifierDataService } from '../../../core/data/identifier-data.service';
|
import { IdentifierDataService } from '../../../core/data/identifier-data.service';
|
||||||
import { Identifier } from '../../../shared/object-list/identifier-data/identifier.model';
|
import { Identifier } from '../../../shared/object-list/identifier-data/identifier.model';
|
||||||
@@ -105,12 +105,13 @@ export class ItemStatusComponent implements OnInit {
|
|||||||
|
|
||||||
// Observable for configuration determining whether the Register DOI feature is enabled
|
// Observable for configuration determining whether the Register DOI feature is enabled
|
||||||
let registerConfigEnabled$: Observable<boolean> = this.configurationService.findByPropertyName('identifiers.item-status.register-doi').pipe(
|
let registerConfigEnabled$: Observable<boolean> = this.configurationService.findByPropertyName('identifiers.item-status.register-doi').pipe(
|
||||||
getFirstSucceededRemoteData(),
|
getFirstCompletedRemoteData(),
|
||||||
getRemoteDataPayload(),
|
map((rd: RemoteData<ConfigurationProperty>) => {
|
||||||
map((enabled: ConfigurationProperty) => {
|
// If the config property is exposed via rest and has a value set, return it
|
||||||
if (enabled !== undefined && enabled.values) {
|
if (rd.hasSucceeded && hasValue(rd.payload) && isNotEmpty(rd.payload.values)) {
|
||||||
return true;
|
return rd.payload.values[0] === 'true';
|
||||||
}
|
}
|
||||||
|
// Otherwise, return false
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user