Skip to content

Commit

Permalink
fix(alerts reports): use default value it not defined in conf
Browse files Browse the repository at this point in the history
  • Loading branch information
Always-prog committed Feb 1, 2023
1 parent 5e36047 commit f01fc4b
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions superset-frontend/src/views/CRUD/alert/AlertReportModal.tsx
Original file line number Diff line number Diff line change
@@ -84,11 +84,10 @@ interface AlertReportModalProps {
show: boolean;
}

const DEFAULT_ALERT_RUNTIME_VALUES = {
ALERT_REPORTS_DEFAULT_WORKING_TIMEOUT: 3600,
ALERT_REPORTS_DEFAULT_CRON_VALUE: '0 * * * *', // every hour
ALERT_REPORTS_DEFAULT_RETENTION: 90,
};
const DEFAULT_WORKING_TIMEOUT = 3600;
const DEFAULT_CRON_VALUE = '0 * * * *'; // every hour
const DEFAULT_RETENTION = 90;

const DEFAULT_NOTIFICATION_METHODS: NotificationMethodOption[] = ['Email'];
const DEFAULT_NOTIFICATION_FORMAT = 'PNG';
const CONDITIONS = [
@@ -504,9 +503,17 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
ALERT_REPORTS_DEFAULT_WORKING_TIMEOUT,
ALERT_REPORTS_DEFAULT_CRON_VALUE,
ALERT_REPORTS_DEFAULT_RETENTION,
} =
useSelector<any, AlertsReportsConfig>(state => state.common?.conf) ||
DEFAULT_ALERT_RUNTIME_VALUES;
} = useSelector<any, AlertsReportsConfig>(state => {
const conf = state.common?.conf;
return {
ALERT_REPORTS_DEFAULT_WORKING_TIMEOUT:
conf.ALERT_REPORTS_DEFAULT_WORKING_TIMEOUT ?? DEFAULT_WORKING_TIMEOUT,
ALERT_REPORTS_DEFAULT_CRON_VALUE:
conf.ALERT_REPORTS_DEFAULT_CRON_VALUE ?? DEFAULT_CRON_VALUE,
ALERT_REPORTS_DEFAULT_RETENTION:
conf.ALERT_REPORTS_DEFAULT_RETENTION ?? DEFAULT_RETENTION,
};
});

const defaultAlert = {
active: true,

0 comments on commit f01fc4b

Please sign in to comment.