Skip to content

Commit

Permalink
only show warning message when dashboard has unsaved changes
Browse files Browse the repository at this point in the history
  • Loading branch information
eokoneyo committed Dec 10, 2024
1 parent 25be26e commit d0a5912
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
}),
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -212,7 +212,7 @@ export function ShowShareModal({
}),
config: {
link: {
draftModeCallOut: allowShortUrl ? (
draftModeCallOut: (
<EuiCallOut
color="warning"
data-test-subj="DashboardDraftModeCopyLinkCallOut"
Expand All @@ -223,9 +223,11 @@ export function ShowShareModal({
/>
}
>
{shareModalStrings.getDraftShareWarning()}
{Boolean(unsavedDashboardState?.panels)
? shareModalStrings.getDraftSharePanelChangesWarning()
: shareModalStrings.getDraftShareWarning()}
</EuiCallOut>
) : null,
),
},
},
},
Expand Down

0 comments on commit d0a5912

Please sign in to comment.