From dde11215e91b1234811f2f027d39a65446aba2b1 Mon Sep 17 00:00:00 2001 From: Sofia Papagiannaki Date: Mon, 15 Feb 2021 10:31:08 +0200 Subject: [PATCH] Alerting: Fix modal text for deleting obsolete notifier (#31171) --- public/app/features/alerting/AlertTabCtrl.ts | 35 +++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/public/app/features/alerting/AlertTabCtrl.ts b/public/app/features/alerting/AlertTabCtrl.ts index 66608f7ae06..c0c7bdf696b 100644 --- a/public/app/features/alerting/AlertTabCtrl.ts +++ b/public/app/features/alerting/AlertTabCtrl.ts @@ -219,25 +219,28 @@ export class AlertTabCtrl { ThresholdMapper.alertToGraphThresholds(this.panel); for (const addedNotification of alert.notifications) { + let identifier = addedNotification.uid; // lookup notifier type by uid - let model: any = _.find(this.notifications, { uid: addedNotification.uid }); + let model: any = _.find(this.notifications, { uid: identifier }); + + // fallback using id if uid is missing + if (!model && addedNotification.id) { + identifier = addedNotification.id; + model = _.find(this.notifications, { id: identifier }); + } - // fallback to using id if uid is missing if (!model) { - model = _.find(this.notifications, { id: addedNotification.id }); - if (!model) { - appEvents.emit(CoreEvents.showConfirmModal, { - title: 'Notifier with invalid ID is detected', - text: `Do you want to delete notifier with invalid ID: ${addedNotification.id} from the dashboard JSON?`, - text2: 'After successful deletion, make sure to save the dashboard for storing the update JSON.', - icon: 'trash-alt', - confirmText: 'Delete', - yesText: 'Delete', - onConfirm: async () => { - this.removeNotification(addedNotification); - }, - }); - } + appEvents.emit(CoreEvents.showConfirmModal, { + title: 'Notifier with invalid identifier is detected', + text: `Do you want to delete notifier with invalid identifier: ${identifier} from the dashboard JSON?`, + text2: 'After successful deletion, make sure to save the dashboard for storing the update JSON.', + icon: 'trash-alt', + confirmText: 'Delete', + yesText: 'Delete', + onConfirm: async () => { + this.removeNotification(addedNotification); + }, + }); } if (model && model.isDefault === false) {