This is an automated email from the ASF dual-hosted git repository.

rusackas pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new e3514054f9 fix(alert modal): set current user as default alert owner 
during new alert initialization (#24070)
e3514054f9 is described below

commit e3514054f90789da8ab6d03291ed55f0b4eb8f97
Author: curious86 <[email protected]>
AuthorDate: Tue May 16 14:55:37 2023 -0700

    fix(alert modal): set current user as default alert owner during new alert 
initialization (#24070)
    
    Co-authored-by: aadhikari <[email protected]>
---
 .../src/features/alerts/AlertReportModal.tsx             | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/superset-frontend/src/features/alerts/AlertReportModal.tsx 
b/superset-frontend/src/features/alerts/AlertReportModal.tsx
index ab78895a17..dff549cf56 100644
--- a/superset-frontend/src/features/alerts/AlertReportModal.tsx
+++ b/superset-frontend/src/features/alerts/AlertReportModal.tsx
@@ -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');
     }

Reply via email to