Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dashboard scenes: Fix min interval not saving #86962

Merged
merged 3 commits into from Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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',
Expand Down
Expand Up @@ -258,6 +258,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;
Expand Down
Expand Up @@ -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);

Expand All @@ -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) {
Expand Down
Expand Up @@ -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,
},
Expand Down