gabotorresruiz commented on code in PR #45753:
URL: https://github.com/apache/superset/pull/45753#discussion_r4415319856


##########
superset-frontend/src/features/reports/ReportModal/index.tsx:
##########
@@ -269,26 +277,52 @@ function ReportModal({
         // Subscribe path: creation_method, editors, and recipients are set 
server-side.
         await dispatch(subscribeReport(commonFields as ReportObject));
       }
-      const resourceId =
-        creationMethod === CreationMethod.Charts ? chart?.id : dashboardId;
       if (
         isFeatureEnabled(FeatureFlag.AlertReportDynamicExecutor) &&
         resourceId != null
       ) {
         await dispatch(
           fetchUISpecificReport({
             userId: currentUserId,
-            filterField:
-              creationMethod === CreationMethod.Charts
-                ? 'chart_id'
-                : 'dashboard_id',
+            filterField,
             creationMethod,
             resourceId,
           }),
         );
       }
       onHide();
     } catch (e) {
+      if (
+        !isEditMode &&
+        (e as Response)?.status === 409 &&
+        resourceId != null &&
+        currentUserId !== undefined
+      ) {
+        // The user already subscribed to this chart or dashboard, e.g. from
+        // another tab. Load that subscription so the modal switches to editing
+        // it instead of reporting a failure.
+        await dispatch(
+          fetchUISpecificReport({
+            userId: currentUserId,
+            filterField,
+            creationMethod,
+            resourceId,
+          }),
+        );
+        if (reportSelector(store.getState(), creationMethod, resourceId)) {
+          addInfoToast(
+            creationMethod === CreationMethod.Charts
+              ? t(
+                  'You are already subscribed to this chart. Your existing 
report has been opened for editing.',
+                )
+              : t(
+                  'You are already subscribed to this dashboard. Your existing 
report has been opened for editing.',
+                ),
+          );
+          setCurrentReport({ isSubmitting: false });

Review Comment:
   Not a blocker. The list endpoint behind `fetchUISpecificReport` doesn't 
return `custom_width`, so after this recovery the Screenshot width field keeps 
whatever was typed into the abandoned create form while every other field shows 
the existing report. Clicking Save then PUTs that width onto the existing 
subscription. Clearing it here keeps it out of the PUT, the same as opening the 
report from "Manage email report":
   
   ```suggestion
             setCurrentReport({ isSubmitting: false, custom_width: undefined });
   ```
   
   Typing a width before clicking Add in your first test would pin it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to