From d0a5912b1f57f853b9d97d8b7358f8e8c9627747 Mon Sep 17 00:00:00 2001 From: Eyo Okon Eyo Date: Thu, 24 Oct 2024 21:51:03 +0200 Subject: [PATCH] only show warning message when dashboard has unsaved changes --- .../public/dashboard_app/_dashboard_app_strings.ts | 7 ++++++- .../dashboard_app/top_nav/share/show_share_modal.tsx | 10 ++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/plugins/dashboard/public/dashboard_app/_dashboard_app_strings.ts b/src/plugins/dashboard/public/dashboard_app/_dashboard_app_strings.ts index a937717e5ba45..2e4ab554394e4 100644 --- a/src/plugins/dashboard/public/dashboard_app/_dashboard_app_strings.ts +++ b/src/plugins/dashboard/public/dashboard_app/_dashboard_app_strings.ts @@ -139,10 +139,15 @@ export const shareModalStrings = { defaultMessage: 'One or more panels on this dashboard have changed. Before you generate a snapshot, save the dashboard.', }), + getDraftSharePanelChangesWarning: () => + i18n.translate('dashboard.snapshotShare.panelChangesWarning', { + defaultMessage: + 'One or more panels on this dashboard have changed. Before generating a link, save the dashboard.', + }), getDraftShareWarning: () => i18n.translate('dashboard.snapshotShare.draftWarning', { defaultMessage: - 'One or more panels on this dashboard have changed, save the dashboard to create a permanent link.', + 'This dashboard has unsaved changes. Consider saving your dashboard before generating the link.', }), }; diff --git a/src/plugins/dashboard/public/dashboard_app/top_nav/share/show_share_modal.tsx b/src/plugins/dashboard/public/dashboard_app/top_nav/share/show_share_modal.tsx index d940d734460ef..2c83ef11df327 100644 --- a/src/plugins/dashboard/public/dashboard_app/top_nav/share/show_share_modal.tsx +++ b/src/plugins/dashboard/public/dashboard_app/top_nav/share/show_share_modal.tsx @@ -123,7 +123,7 @@ export function ShowShareModal({ const allUnsavedPanels = (() => { if ( Object.keys(unsavedDashboardState?.panels ?? {}).length === 0 && - Object.keys(panelModifications ?? {}).length === 0 + Object.keys(omit(panelModifications ?? {}, PANELS_CONTROL_GROUP_KEY)).length === 0 ) { // if this dashboard has no modifications or unsaved panels return early. No overrides needed. return; @@ -212,7 +212,7 @@ export function ShowShareModal({ }), config: { link: { - draftModeCallOut: allowShortUrl ? ( + draftModeCallOut: ( } > - {shareModalStrings.getDraftShareWarning()} + {Boolean(unsavedDashboardState?.panels) + ? shareModalStrings.getDraftSharePanelChangesWarning() + : shareModalStrings.getDraftShareWarning()} - ) : null, + ), }, }, },