From c98add6e5a1653f3c0b494704c63807bcbe744e3 Mon Sep 17 00:00:00 2001 From: kay delaney <45561153+kaydelaney@users.noreply.github.com> Date: Fri, 3 Nov 2023 16:33:59 +0000 Subject: [PATCH] Dashboards: Fix issue causing crashes when saving new dashboard (#77620) Closes #77593 --- .betterer.results | 7 ++++--- .../components/DashboardPrompt/DashboardPrompt.tsx | 5 +++++ .../dashboard/state/__fixtures__/dashboardFixtures.ts | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.betterer.results b/.betterer.results index 0e1dfd0c5a0..140a1f0af24 100644 --- a/.betterer.results +++ b/.betterer.results @@ -3000,9 +3000,10 @@ exports[`better eslint`] = { [0, 0, 0, "Do not use any type assertions.", "2"], [0, 0, 0, "Do not use any type assertions.", "3"], [0, 0, 0, "Do not use any type assertions.", "4"], - [0, 0, 0, "Unexpected any. Specify a different type.", "5"], - [0, 0, 0, "Do not use any type assertions.", "6"], - [0, 0, 0, "Unexpected any. Specify a different type.", "7"] + [0, 0, 0, "Do not use any type assertions.", "5"], + [0, 0, 0, "Unexpected any. Specify a different type.", "6"], + [0, 0, 0, "Do not use any type assertions.", "7"], + [0, 0, 0, "Unexpected any. Specify a different type.", "8"] ], "public/app/features/dashboard/components/DashboardRow/DashboardRow.test.tsx:5381": [ [0, 0, 0, "Unexpected any. Specify a different type.", "0"] diff --git a/public/app/features/dashboard/components/DashboardPrompt/DashboardPrompt.tsx b/public/app/features/dashboard/components/DashboardPrompt/DashboardPrompt.tsx index c5602a8cc44..8956e55afd2 100644 --- a/public/app/features/dashboard/components/DashboardPrompt/DashboardPrompt.tsx +++ b/public/app/features/dashboard/components/DashboardPrompt/DashboardPrompt.tsx @@ -146,6 +146,11 @@ export function ignoreChanges(current: DashboardModel | null, original: object | return true; } + // Ignore changes if original is unsaved + if ((original as DashboardModel).version === 0) { + return true; + } + // Ignore changes if the user has been signed out if (!contextSrv.isSignedIn) { return true; diff --git a/public/app/features/dashboard/state/__fixtures__/dashboardFixtures.ts b/public/app/features/dashboard/state/__fixtures__/dashboardFixtures.ts index d1c6f323c5a..c4259b5eb09 100644 --- a/public/app/features/dashboard/state/__fixtures__/dashboardFixtures.ts +++ b/public/app/features/dashboard/state/__fixtures__/dashboardFixtures.ts @@ -22,6 +22,7 @@ export function createDashboardModelFixture( editable: true, graphTooltip: defaultDashboardCursorSync, schemaVersion: 1, + version: 1, timezone: '', ...dashboardInput, };