DashboardScene: Fixes issue with dashboard starting with auto refresh set (#93756)

This commit is contained in:
Torkel Ödegaard 2024-09-25 20:14:52 +02:00 committed by GitHub
parent b68d9630fb
commit 57ab354139
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 4 deletions

View File

@ -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",

View File

@ -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;

View File

@ -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