BrandanBurgess commented on code in PR #45753:
URL: https://github.com/apache/superset/pull/45753#discussion_r4418951822
##########
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:
Pushed changes to address this
--
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]