diff --git a/src/app/item-page/alerts/item-alerts.component.html b/src/app/item-page/alerts/item-alerts.component.html
index f6304340f3d..b964327e39b 100644
--- a/src/app/item-page/alerts/item-alerts.component.html
+++ b/src/app/item-page/alerts/item-alerts.component.html
@@ -8,7 +8,7 @@
{{'item.alerts.withdrawn' | translate}}
diff --git a/src/app/item-page/alerts/item-alerts.component.ts b/src/app/item-page/alerts/item-alerts.component.ts
index 1984de0324a..6066ddae069 100644
--- a/src/app/item-page/alerts/item-alerts.component.ts
+++ b/src/app/item-page/alerts/item-alerts.component.ts
@@ -5,6 +5,8 @@ import {
import {
Component,
Input,
+ OnChanges,
+ SimpleChanges,
} from '@angular/core';
import { RouterLink } from '@angular/router';
import { TranslateModule } from '@ngx-translate/core';
@@ -45,12 +47,17 @@ import {
/**
* Component displaying alerts for an item
*/
-export class ItemAlertsComponent {
+export class ItemAlertsComponent implements OnChanges {
/**
* The Item to display alerts for
*/
@Input() item: Item;
+ /**
+ * Whether the reinstate button should be shown
+ */
+ showReinstateButton$: Observable;
+
/**
* The AlertType enumeration
* @type {AlertType}
@@ -64,12 +71,18 @@ export class ItemAlertsComponent {
) {
}
+ ngOnChanges(changes: SimpleChanges): void {
+ if (changes.item?.currentValue.withdrawn && this.showReinstateButton$) {
+ this.showReinstateButton$ = this.shouldShowReinstateButton();
+ }
+ }
+
/**
* Determines whether to show the reinstate button.
* The button is shown if the user is not an admin and the item has a reinstate request.
* @returns An Observable that emits a boolean value indicating whether to show the reinstate button.
*/
- showReinstateButton$(): Observable {
+ shouldShowReinstateButton(): Observable {
const correction$ = this.correctionTypeDataService.findByItem(this.item.uuid, true).pipe(
getFirstCompletedRemoteData(),
map((correctionTypeRD: RemoteData>) => correctionTypeRD.hasSucceeded ? correctionTypeRD.payload.page : []),
@@ -78,8 +91,8 @@ export class ItemAlertsComponent {
return combineLatest([isAdmin$, correction$]).pipe(
map(([isAdmin, correction]) => {
return !isAdmin && correction.some((correctionType) => correctionType.topic === REQUEST_REINSTATE);
- },
- ));
+ }),
+ );
}
/**