[v11.0.x] Dashboard scenes: Fix min interval not saving (#87022)
Dashboard scenes: Fix min interval not saving (#86962)
* Fix min interval not saving
* Add tests
* Fix test
(cherry picked from commit fdc1023586)
Co-authored-by: Oscar Kilhed <oscar.kilhed@grafana.com>
This commit is contained in:
co-authored by
Oscar Kilhed
parent
cb49b93146
commit
5749f36f52
@@ -417,6 +417,20 @@ describe('transformSaveModelToScene', () => {
|
||||
expect(vizPanel.state.hoverHeader).toEqual(true);
|
||||
});
|
||||
|
||||
it('should initalize the VizPanel with min interval set', () => {
|
||||
const panel = {
|
||||
title: '',
|
||||
type: 'test-plugin',
|
||||
gridPos: { x: 0, y: 0, w: 12, h: 8 },
|
||||
interval: '20m',
|
||||
};
|
||||
|
||||
const { vizPanel } = buildGridItemForTest(panel);
|
||||
|
||||
const queryRunner = getQueryRunnerFor(vizPanel);
|
||||
expect(queryRunner?.state.minInterval).toBe('20m');
|
||||
});
|
||||
|
||||
it('should set PanelTimeRange when timeFrom or timeShift is present', () => {
|
||||
const panel = {
|
||||
type: 'test-plugin',
|
||||
|
||||
@@ -259,6 +259,13 @@ describe('transformSceneToSaveModel', () => {
|
||||
expect(saveModel.transparent).toBe(true);
|
||||
});
|
||||
|
||||
it('interval', () => {
|
||||
const gridItem = buildGridItemFromPanelSchema({ interval: '20m' });
|
||||
const saveModel = gridItemToPanel(gridItem);
|
||||
|
||||
expect(saveModel.interval).toBe('20m');
|
||||
});
|
||||
|
||||
it('With angular options', () => {
|
||||
const gridItem = buildGridItemFromPanelSchema({});
|
||||
const vizPanel = gridItem.state.body as VizPanel;
|
||||
|
||||
@@ -281,7 +281,7 @@ function vizPanelDataToPanel(
|
||||
|
||||
const panel: Pick<
|
||||
Panel,
|
||||
'datasource' | 'targets' | 'maxDataPoints' | 'transformations' | 'cacheTimeout' | 'queryCachingTTL'
|
||||
'datasource' | 'targets' | 'maxDataPoints' | 'transformations' | 'cacheTimeout' | 'queryCachingTTL' | 'interval'
|
||||
> = {};
|
||||
const queryRunner = getQueryRunnerFor(vizPanel);
|
||||
|
||||
@@ -297,6 +297,9 @@ function vizPanelDataToPanel(
|
||||
if (queryRunner.state.queryCachingTTL) {
|
||||
panel.queryCachingTTL = queryRunner.state.queryCachingTTL;
|
||||
}
|
||||
if (queryRunner.state.minInterval) {
|
||||
panel.interval = queryRunner.state.minInterval;
|
||||
}
|
||||
}
|
||||
|
||||
if (dataProvider instanceof SceneDataTransformer) {
|
||||
|
||||
@@ -24,6 +24,7 @@ export function createPanelDataProvider(panel: PanelModel): SceneDataProvider |
|
||||
maxDataPointsFromWidth: true,
|
||||
cacheTimeout: panel.cacheTimeout,
|
||||
queryCachingTTL: panel.queryCachingTTL,
|
||||
minInterval: panel.interval ?? undefined,
|
||||
dataLayerFilter: {
|
||||
panelId: panel.id,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user