Skip to content

Commit 976ac76

Browse files
117287: Fixed UI freezing on withdrawn item pages
1 parent d3de28d commit 976ac76

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

src/app/item-page/alerts/item-alerts.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<span class="align-self-center">{{'item.alerts.withdrawn' | translate}}</span>
99
<div class="gap-2 d-flex">
1010
<a routerLink="/home" class="btn btn-primary btn-sm">{{"404.link.home-page" | translate}}</a>
11-
<a *ngIf="showReinstateButton$() | async" class="btn btn-primary btn-sm" (click)="openReinstateModal()">{{ 'item.alerts.reinstate-request' | translate}}</a>
11+
<a *ngIf="showReinstateButton$ | async" class="btn btn-primary btn-sm" (click)="openReinstateModal()">{{ 'item.alerts.reinstate-request' | translate}}</a>
1212
</div>
1313
</div>
1414
</ds-alert>

src/app/item-page/alerts/item-alerts.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ describe('ItemAlertsComponent', () => {
161161
(authorizationService.isAuthorized).and.returnValue(isAdmin$);
162162
(correctionTypeDataService.findByItem).and.returnValue(correction$);
163163

164-
expectObservable(component.showReinstateButton$()).toBe(expectedMarble, expectedValues);
164+
expectObservable(component.shouldShowReinstateButton()).toBe(expectedMarble, expectedValues);
165165
});
166166
});
167167

src/app/item-page/alerts/item-alerts.component.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import {
55
import {
66
Component,
77
Input,
8+
OnChanges,
9+
SimpleChanges,
810
} from '@angular/core';
911
import { RouterLink } from '@angular/router';
1012
import { TranslateModule } from '@ngx-translate/core';
@@ -45,31 +47,42 @@ import {
4547
/**
4648
* Component displaying alerts for an item
4749
*/
48-
export class ItemAlertsComponent {
50+
export class ItemAlertsComponent implements OnChanges {
4951
/**
5052
* The Item to display alerts for
5153
*/
5254
@Input() item: Item;
5355

56+
/**
57+
* Whether the reinstate button should be shown
58+
*/
59+
showReinstateButton$: Observable<boolean>;
60+
5461
/**
5562
* The AlertType enumeration
5663
* @type {AlertType}
5764
*/
5865
public AlertTypeEnum = AlertType;
5966

6067
constructor(
61-
private authService: AuthorizationDataService,
62-
private dsoWithdrawnReinstateModalService: DsoWithdrawnReinstateModalService,
63-
private correctionTypeDataService: CorrectionTypeDataService,
68+
protected authService: AuthorizationDataService,
69+
protected dsoWithdrawnReinstateModalService: DsoWithdrawnReinstateModalService,
70+
protected correctionTypeDataService: CorrectionTypeDataService,
6471
) {
6572
}
6673

74+
ngOnChanges(changes: SimpleChanges): void {
75+
if (changes.item?.currentValue.withdrawn && this.showReinstateButton$) {
76+
this.showReinstateButton$ = this.shouldShowReinstateButton();
77+
}
78+
}
79+
6780
/**
6881
* Determines whether to show the reinstate button.
6982
* The button is shown if the user is not an admin and the item has a reinstate request.
7083
* @returns An Observable that emits a boolean value indicating whether to show the reinstate button.
7184
*/
72-
showReinstateButton$(): Observable<boolean> {
85+
shouldShowReinstateButton(): Observable<boolean> {
7386
const correction$ = this.correctionTypeDataService.findByItem(this.item.uuid, true).pipe(
7487
getFirstCompletedRemoteData(),
7588
map((correctionTypeRD: RemoteData<PaginatedList<CorrectionType>>) => correctionTypeRD.hasSucceeded ? correctionTypeRD.payload.page : []),
@@ -78,8 +91,8 @@ export class ItemAlertsComponent {
7891
return combineLatest([isAdmin$, correction$]).pipe(
7992
map(([isAdmin, correction]) => {
8093
return !isAdmin && correction.some((correctionType) => correctionType.topic === REQUEST_REINSTATE);
81-
},
82-
));
94+
}),
95+
);
8396
}
8497

8598
/**

0 commit comments

Comments
 (0)