mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +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 { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||
import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
|
||||
import { hasValue } from '../../../shared/empty.util';
|
||||
import { hasValue, isNotEmpty } from '../../../shared/empty.util';
|
||||
import {
|
||||
getAllSucceededRemoteDataPayload, getFirstSucceededRemoteData, getRemoteDataPayload,
|
||||
getAllSucceededRemoteDataPayload, getFirstCompletedRemoteData, getFirstSucceededRemoteData, getRemoteDataPayload,
|
||||
} from '../../../core/shared/operators';
|
||||
import { IdentifierDataService } from '../../../core/data/identifier-data.service';
|
||||
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
|
||||
let registerConfigEnabled$: Observable<boolean> = this.configurationService.findByPropertyName('identifiers.item-status.register-doi').pipe(
|
||||
getFirstSucceededRemoteData(),
|
||||
getRemoteDataPayload(),
|
||||
map((enabled: ConfigurationProperty) => {
|
||||
if (enabled !== undefined && enabled.values) {
|
||||
return true;
|
||||
getFirstCompletedRemoteData(),
|
||||
map((rd: RemoteData<ConfigurationProperty>) => {
|
||||
// If the config property is exposed via rest and has a value set, return it
|
||||
if (rd.hasSucceeded && hasValue(rd.payload) && isNotEmpty(rd.payload.values)) {
|
||||
return rd.payload.values[0] === 'true';
|
||||
}
|
||||
// Otherwise, return false
|
||||
return false;
|
||||
})
|
||||
);
|
||||
|
Reference in New Issue
Block a user