[v10.2.x] Dashboards: Fix issue causing crashes when saving new dashboard (#77641)

* Dashboards: Fix issue causing crashes when saving new dashboard (#77620)

Closes #77593

(cherry picked from commit c98add6e5a)

* Test fix

---------

Co-authored-by: kay delaney <45561153+kaydelaney@users.noreply.github.com>
Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
This commit is contained in:
grafana-delivery-bot[bot]
2023-11-13 17:19:46 +02:00
committed by GitHub
co-authored by kay delaney Dominik Prokop
parent d62789601a
commit 9e8afef9ef
4 changed files with 14 additions and 7 deletions
+4 -3
View File
@@ -3121,9 +3121,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"]
@@ -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;
@@ -47,19 +47,19 @@ describe('getDashboardChanges', () => {
' "graphTooltip": 0,\n' +
'- "schemaVersion": 37,\n' +
'+ "schemaVersion": 38,\n' +
' "version": 1,\n' +
' "timezone": "",\n' +
' "panels": [\n' +
' {\n' +
' "type": "timeseries",\n' +
' "title": "Panel 1",\n'
' "type": "timeseries",\n'
);
expect(result.userChanges).toEqual(
'===================================================================\n' +
'--- Before user changes\t\n' +
'+++ After user changes\t\n' +
'@@ -3,16 +3,17 @@\n' +
' "graphTooltip": 0,\n' +
'@@ -4,16 +4,17 @@\n' +
' "schemaVersion": 38,\n' +
' "version": 1,\n' +
' "timezone": "",\n' +
' "panels": [\n' +
' {\n' +
@@ -22,6 +22,7 @@ export function createDashboardModelFixture(
editable: true,
graphTooltip: defaultDashboardCursorSync,
schemaVersion: 1,
version: 1,
timezone: '',
...dashboardInput,
};