Skip to content

Commit

Permalink
fix(alert modal): set current user as default alert owner during new …
Browse files Browse the repository at this point in the history
…alert initialization (#24070)

Co-authored-by: aadhikari <aadhikari@apple.com>
  • Loading branch information
anamitraadhikari and aadhikari authored May 16, 2023
1 parent 36bcdfe commit e351405
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion superset-frontend/src/features/alerts/AlertReportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import {
AlertsReportsConfig,
} from 'src/features/alerts/types';
import { useSelector } from 'react-redux';
import { UserWithPermissionsAndRoles } from 'src/types/bootstrapTypes';
import { AlertReportCronScheduler } from './components/AlertReportCronScheduler';
import { NotificationMethod } from './components/NotificationMethod';

Expand Down Expand Up @@ -449,6 +450,9 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
isReport = false,
addSuccessToast,
}) => {
const currentUser = useSelector<any, UserWithPermissionsAndRoles>(
state => state.user,
);
const conf = useCommonConf();
const allowedNotificationMethods: NotificationMethodOption[] =
conf?.ALERT_REPORTS_NOTIFICATION_METHODS || DEFAULT_NOTIFICATION_METHODS;
Expand Down Expand Up @@ -1011,7 +1015,17 @@ const AlertReportModal: FunctionComponent<AlertReportModalProps> = ({
!isEditMode &&
(!currentAlert || currentAlert.id || (isHidden && show))
) {
setCurrentAlert({ ...defaultAlert });
setCurrentAlert({
...defaultAlert,
owners: currentUser
? [
{
value: currentUser.userId,
label: `${currentUser.firstName} ${currentUser.lastName}`,
},
]
: [],
});
setNotificationSettings([]);
setNotificationAddState('active');
}
Expand Down

0 comments on commit e351405

Please sign in to comment.