Commits
Giuseppe Digilio authored 054a3d56c59
6 6 | Component, |
7 7 | Input, |
8 8 | } from '@angular/core'; |
9 9 | import { RouterLink } from '@angular/router'; |
10 10 | import { TranslateModule } from '@ngx-translate/core'; |
11 11 | import { |
12 12 | combineLatest, |
13 13 | map, |
14 14 | Observable, |
15 15 | } from 'rxjs'; |
16 - | import { |
17 - | getFirstCompletedRemoteData, |
18 - | getPaginatedListPayload, |
19 - | getRemoteDataPayload, |
20 - | } from 'src/app/core/shared/operators'; |
16 + | import { getFirstCompletedRemoteData } from 'src/app/core/shared/operators'; |
21 17 | |
22 18 | import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service'; |
23 19 | import { FeatureID } from '../../core/data/feature-authorization/feature-id'; |
20 + | import { PaginatedList } from '../../core/data/paginated-list.model'; |
21 + | import { RemoteData } from '../../core/data/remote-data'; |
24 22 | import { Item } from '../../core/shared/item.model'; |
25 23 | import { CorrectionTypeDataService } from '../../core/submission/correctiontype-data.service'; |
24 + | import { CorrectionType } from '../../core/submission/models/correctiontype.model'; |
26 25 | import { AlertComponent } from '../../shared/alert/alert.component'; |
27 26 | import { AlertType } from '../../shared/alert/alert-type'; |
28 27 | import { |
29 28 | DsoWithdrawnReinstateModalService, |
30 29 | REQUEST_REINSTATE, |
31 30 | } from '../../shared/dso-page/dso-withdrawn-reinstate-service/dso-withdrawn-reinstate-modal.service'; |
32 31 | |
33 32 | @Component({ |
34 33 | selector: 'ds-item-alerts', |
35 34 | templateUrl: './item-alerts.component.html', |
66 65 | } |
67 66 | |
68 67 | /** |
69 68 | * Determines whether to show the reinstate button. |
70 69 | * The button is shown if the user is not an admin and the item has a reinstate request. |
71 70 | * @returns An Observable that emits a boolean value indicating whether to show the reinstate button. |
72 71 | */ |
73 72 | showReinstateButton$(): Observable<boolean> { |
74 73 | const correction$ = this.correctionTypeDataService.findByItem(this.item.uuid, true).pipe( |
75 74 | getFirstCompletedRemoteData(), |
76 - | getRemoteDataPayload(), |
77 - | getPaginatedListPayload(), |
75 + | map((correctionTypeRD: RemoteData<PaginatedList<CorrectionType>>) => correctionTypeRD.hasSucceeded ? correctionTypeRD.payload.page : []), |
78 76 | ); |
79 77 | const isAdmin$ = this.authService.isAuthorized(FeatureID.AdministratorOf); |
80 78 | return combineLatest([isAdmin$, correction$]).pipe( |
81 79 | map(([isAdmin, correction]) => { |
82 80 | return !isAdmin && correction.some((correctionType) => correctionType.topic === REQUEST_REINSTATE); |
83 81 | }, |
84 82 | )); |
85 83 | } |
86 84 | |
87 85 | /** |