diff --git a/public/app/features/dashboard-scene/serialization/__snapshots__/transformSceneToSaveModel.test.ts.snap b/public/app/features/dashboard-scene/serialization/__snapshots__/transformSceneToSaveModel.test.ts.snap index 9b5c0a119ae..8ab27fc7a70 100644 --- a/public/app/features/dashboard-scene/serialization/__snapshots__/transformSceneToSaveModel.test.ts.snap +++ b/public/app/features/dashboard-scene/serialization/__snapshots__/transformSceneToSaveModel.test.ts.snap @@ -280,7 +280,7 @@ exports[`transformSceneToSaveModel Given a scene with rows Should transform back ], "preload": false, "refresh": "", - "schemaVersion": 39, + "schemaVersion": 40, "tags": [ "templating", "gdev", @@ -548,7 +548,7 @@ exports[`transformSceneToSaveModel Given a simple scene with custom settings Sho ], "preload": false, "refresh": "5m", - "schemaVersion": 39, + "schemaVersion": 40, "tags": [ "tag1", "tag2", @@ -906,7 +906,7 @@ exports[`transformSceneToSaveModel Given a simple scene with variables Should tr ], "preload": false, "refresh": "", - "schemaVersion": 39, + "schemaVersion": 40, "tags": [ "gdev", "graph-ng", diff --git a/public/app/features/dashboard/state/DashboardMigrator.test.ts b/public/app/features/dashboard/state/DashboardMigrator.test.ts index b3aef514daf..6ba62a860e5 100644 --- a/public/app/features/dashboard/state/DashboardMigrator.test.ts +++ b/public/app/features/dashboard/state/DashboardMigrator.test.ts @@ -2413,6 +2413,21 @@ describe('when migrating table cell display mode to cell options', () => { }); }); +describe('when migrating variable refresh to on dashboard load', () => { + let model: DashboardModel; + + beforeEach(() => { + model = new DashboardModel({ + //@ts-ignore + refresh: false, + }); + }); + + it('should migrate to empty string', () => { + expect(model.refresh).toBe(''); + }); +}); + function createRow(options: any, panelDescriptions: any[]) { const PANEL_HEIGHT_STEP = GRID_CELL_HEIGHT + GRID_CELL_VMARGIN; const { collapse, showTitle, title, repeat, repeatIteration } = options; diff --git a/public/app/features/dashboard/state/DashboardMigrator.ts b/public/app/features/dashboard/state/DashboardMigrator.ts index bd04031eebd..618d684ab16 100644 --- a/public/app/features/dashboard/state/DashboardMigrator.ts +++ b/public/app/features/dashboard/state/DashboardMigrator.ts @@ -81,7 +81,7 @@ type PanelSchemeUpgradeHandler = (panel: PanelModel) => PanelModel; * kinds/dashboard/dashboard_kind.cue * Example PR: #87712 */ -export const DASHBOARD_SCHEMA_VERSION = 39; +export const DASHBOARD_SCHEMA_VERSION = 40; export class DashboardMigrator { dashboard: DashboardModel; @@ -904,6 +904,13 @@ export class DashboardMigrator { }); } + if (oldVersion < 40) { + // In old ashboards refresh property can be a boolean + if (typeof this.dashboard.refresh !== 'string') { + this.dashboard.refresh = ''; + } + } + /** * -==- Add migration here -==- * Your migration should go below the previous