Skip to content

Commit

Permalink
updating notification method logic
Browse files Browse the repository at this point in the history
lint
  • Loading branch information
fisjac committed Feb 23, 2024
1 parent b164d2d commit 642b9d3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
19 changes: 17 additions & 2 deletions superset-frontend/src/features/alerts/AlertReportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,16 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
>([]);
const onNotificationAdd = () => {
const settings: NotificationSetting[] = notificationSettings.slice();
const options: NotificationMethodOption[] =
allowedNotificationMethods.slice();
settings.forEach(setting => {
if (setting.method) {
options.splice(options.indexOf(setting.method), 1);
}
});
settings.push({
recipients: '',
options: allowedNotificationMethods,
options,
});

setNotificationSettings(settings);
Expand Down Expand Up @@ -543,8 +550,16 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
setting: NotificationSetting,
) => {
const settings = notificationSettings.slice();

// if you've changed notification method
if (settings[index].method !== setting.method) {
// remove subsequent notification methods
while (settings.length - 1 > index) {
settings.pop();
setNotificationAddState('active');

Check warning on line 558 in superset-frontend/src/features/alerts/AlertReportModal.tsx

View check run for this annotation

Codecov / codecov/patch

superset-frontend/src/features/alerts/AlertReportModal.tsx#L557-L558

Added lines #L557 - L558 were not covered by tests
}
}
settings[index] = setting;

setNotificationSettings(settings);

if (setting.method !== undefined && notificationAddState !== 'hidden') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const NotificationMethod: FunctionComponent<NotificationMethodProps> = ({
)}
value={method}
/>
{method !== undefined && index !== 0 && !!onRemove ? (
{index !== 0 && !!onRemove ? (
<span
role="button"
tabIndex={0}
Expand Down
1 change: 0 additions & 1 deletion superset-frontend/src/features/alerts/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,3 @@ export enum Sections {
Schedule = 'scheduleSection',
Notification = 'notificationSection',
}

0 comments on commit 642b9d3

Please sign in to comment.