From ad6781a8d3f6e3d1b5cf8b5fe9bfd82b6dcf00cf Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" Date: Wed, 9 Feb 2022 09:09:29 -0300 Subject: [PATCH] Shows toast when recovering --- .../menu/ShareMenuItems/ShareMenuItems.test.tsx | 2 +- .../dashboard/components/menu/ShareMenuItems/index.tsx | 9 +++++---- superset/views/core.py | 7 ++++--- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/superset-frontend/src/dashboard/components/menu/ShareMenuItems/ShareMenuItems.test.tsx b/superset-frontend/src/dashboard/components/menu/ShareMenuItems/ShareMenuItems.test.tsx index ca294d34ee32f..bdf22009efda5 100644 --- a/superset-frontend/src/dashboard/components/menu/ShareMenuItems/ShareMenuItems.test.tsx +++ b/superset-frontend/src/dashboard/components/menu/ShareMenuItems/ShareMenuItems.test.tsx @@ -159,7 +159,7 @@ test('Click on "Share dashboard by email" and succeed', async () => { await waitFor(() => { expect(props.addDangerToast).toBeCalledTimes(0); expect(window.location.href).toBe( - 'mailto:?Subject=Superset dashboard COVID Vaccine Dashboard%20&Body=Check out this dashboard: http%3A%2F%2Flocalhost%3A8088%2Fr%2F3', + 'mailto:?Subject=Superset%20dashboard%20COVID%20Vaccine%20Dashboard%20&Body=Check%20out%20this%20dashboard%3A%20http%3A%2F%2Flocalhost%3A8088%2Fr%2F3', ); }); }); diff --git a/superset-frontend/src/dashboard/components/menu/ShareMenuItems/index.tsx b/superset-frontend/src/dashboard/components/menu/ShareMenuItems/index.tsx index 83a98f1c8a30a..9518e3a4d62d3 100644 --- a/superset-frontend/src/dashboard/components/menu/ShareMenuItems/index.tsx +++ b/superset-frontend/src/dashboard/components/menu/ShareMenuItems/index.tsx @@ -102,10 +102,11 @@ const ShareMenuItems = (props: ShareMenuItemProps) => { async function onShareByEmail() { try { - const bodyWithLink = `${emailBody}${encodeURIComponent( - await generateUrl(), - )}`; - window.location.href = `mailto:?Subject=${emailSubject}%20&Body=${bodyWithLink}`; + const encodedBody = encodeURIComponent( + `${emailBody}${await generateUrl()}`, + ); + const encodedSubject = encodeURIComponent(emailSubject); + window.location.href = `mailto:?Subject=${encodedSubject}%20&Body=${encodedBody}`; } catch (error) { logging.error(error); addDangerToast(t('Sorry, something went wrong. Try again later.')); diff --git a/superset/views/core.py b/superset/views/core.py index 7e0e9aee32435..917b84c1db1f7 100755 --- a/superset/views/core.py +++ b/superset/views/core.py @@ -743,12 +743,13 @@ def explore( if not initial_form_data: slice_id = request.args.get("slice_id") + dataset_id = request.args.get("dataset_id") if slice_id: initial_form_data["slice_id"] = slice_id - - dataset_id = request.args.get("dataset_id") - if dataset_id: + flash(_("Form data not found in cache, reverting to chart metadata.")) + elif dataset_id: initial_form_data["datasource"] = f"{dataset_id}__table" + flash(_("Form data not found in cache, reverting to dataset metadata.")) form_data, slc = get_form_data( use_slice_data=True, initial_form_data=initial_form_data