fix(alert modal): set current user as default alert owner during new alert initialization (#24070)

Co-authored-by: aadhikari <aadhikari@apple.com>
This commit is contained in:
curious86 2023-05-16 14:55:37 -07:00 committed by GitHub
parent 36bcdfec97
commit e3514054f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 1 deletions

View File

@ -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';
@ -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;
@ -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');
}