Skip to content

Commit

Permalink
fixing updateNotification setter
Browse files Browse the repository at this point in the history
  • Loading branch information
fisjac committed May 9, 2024
1 parent 5a13e64 commit dd49c60
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion superset-frontend/src/features/alerts/AlertReportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -553,20 +553,26 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
index: number,
setting: NotificationSetting,
) => {
// if you've changed notification method
const settings: NotificationSetting[] = [...notificationSettings];
settings[index] = setting;

// if you've changed notification method -> remove trailing methods
if (notificationSettings[index].method !== setting.method) {
notificationSettings[index] = setting;

setNotificationSettings(
notificationSettings.filter((_, idx) => idx <= index),
);

if (notificationSettings.length - 1 > index) {
setNotificationAddState('active');
}

if (setting.method !== undefined && notificationAddState !== 'hidden') {
setNotificationAddState('active');
}
} else {
setNotificationSettings(settings);
}
};

Expand Down

0 comments on commit dd49c60

Please sign in to comment.