Commits

Kim Shepherd authored and github-actions[bot] committed 8b3bc908645
Improve cfg handling in item-status.component.ts

(cherry picked from commit 3e33785311444682eaf1f38ffc0bb8e0b3e3f353)
No tags

src/app/item-page/edit-item-page/item-status/item-status.component.ts

Modified
1 1 import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core';
2 2 import { fadeIn, fadeInOut } from '../../../shared/animations/fade';
3 3 import { Item } from '../../../core/shared/item.model';
4 4 import { ActivatedRoute } from '@angular/router';
5 5 import { ItemOperation } from '../item-operation/itemOperation.model';
6 -import { concatMap, distinctUntilChanged, first, map, mergeMap, switchMap, toArray } from 'rxjs/operators';
6 +import {concatMap, distinctUntilChanged, first, map, mergeMap, switchMap, tap, toArray} from 'rxjs/operators';
7 7 import { BehaviorSubject, combineLatest, Observable, of, Subscription } from 'rxjs';
8 8 import { RemoteData } from '../../../core/data/remote-data';
9 9 import { getItemEditRoute, getItemPageRoute } from '../../item-page-routing-paths';
10 10 import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
11 11 import { FeatureID } from '../../../core/data/feature-authorization/feature-id';
12 12 import { hasValue } from '../../../shared/empty.util';
13 13 import { getAllSucceededRemoteDataPayload, getFirstCompletedRemoteData, } from '../../../core/shared/operators';
14 14 import { IdentifierDataService } from '../../../core/data/identifier-data.service';
15 15 import { Identifier } from '../../../shared/object-list/identifier-data/identifier.model';
16 16 import { ConfigurationProperty } from '../../../core/shared/configuration-property.model';
17 17 import { ConfigurationDataService } from '../../../core/data/configuration-data.service';
18 18 import { IdentifierData } from '../../../shared/object-list/identifier-data/identifier-data.model';
19 19 import { OrcidAuthService } from '../../../core/orcid/orcid-auth.service';
20 +import {getDSORoute} from "../../../app-routing-paths";
20 21
21 22 @Component({
22 23 selector: 'ds-item-status',
23 24 templateUrl: './item-status.component.html',
24 25 changeDetection: ChangeDetectionStrategy.Default,
25 26 animations: [
26 27 fadeIn,
27 28 fadeInOut
28 29 ]
29 30 })
100 101 return identifierRD.payload.identifiers;
101 102 } else {
102 103 return null;
103 104 }
104 105 }),
105 106 );
106 107
107 108 // Observable for configuration determining whether the Register DOI feature is enabled
108 109 let registerConfigEnabled$: Observable<boolean> = this.configurationService.findByPropertyName('identifiers.item-status.register-doi').pipe(
109 110 getFirstCompletedRemoteData(),
110 - map((enabledRD: RemoteData<ConfigurationProperty>) => enabledRD.hasSucceeded && enabledRD.payload.values.length > 0)
111 + map((response: RemoteData<ConfigurationProperty>) => {
112 + // Return true if a successful response with a 'true' value was retrieved, otherwise return false
113 + if (response.hasSucceeded) {
114 + const payload = response.payload;
115 + if (payload.values.length > 0 && hasValue(payload.values[0])) {
116 + return payload.values[0] === 'true';
117 + } else {
118 + return false;
119 + }
120 + } else {
121 + return false;
122 + }
123 + })
111 124 );
112 125
113 126 /**
114 127 * Construct a base list of operations.
115 128 * The key is used to build messages
116 129 * i18n example: 'item.edit.tabs.status.buttons.<key>.label'
117 130 * The value is supposed to be a href for the button
118 131 */
119 132 const currentUrl = this.getCurrentUrl(item);
120 133 const initialOperations: ItemOperation[] = [

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut