From d9dfa3ece3382e3a9cdb1201e3a0799c9fdc855c Mon Sep 17 00:00:00 2001 From: Victor Marin <36818606+mdvictor@users.noreply.github.com> Date: Fri, 8 Nov 2024 16:22:20 +0200 Subject: [PATCH] DashboardScenes: Fix queryOptions interval not resetting on empty minInterval (#95659) * Fix queryOptions interval not resetting on empty minInterval * fix * refactor + tests --- .../PanelDataQueriesTab.test.tsx | 21 +++++++++++++++++++ .../PanelDataPane/PanelDataQueriesTab.tsx | 4 ++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/public/app/features/dashboard-scene/panel-edit/PanelDataPane/PanelDataQueriesTab.test.tsx b/public/app/features/dashboard-scene/panel-edit/PanelDataPane/PanelDataQueriesTab.test.tsx index 3fa7b13563c..fe807ace5b2 100644 --- a/public/app/features/dashboard-scene/panel-edit/PanelDataPane/PanelDataQueriesTab.test.tsx +++ b/public/app/features/dashboard-scene/panel-edit/PanelDataPane/PanelDataQueriesTab.test.tsx @@ -520,6 +520,27 @@ describe('PanelDataQueriesTab', () => { }); expect(dataObj.state.minInterval).toBe('1s'); }); + + it('should update min interval to undefined if empty input', async () => { + const { queriesTab } = await setupScene('panel-1'); + const dataObj = queriesTab.queryRunner; + + expect(dataObj.state.maxDataPoints).toBeUndefined(); + + queriesTab.onQueryOptionsChange({ + dataSource: { name: 'grafana-testdata', type: 'grafana-testdata-datasource', default: true }, + queries: [], + minInterval: '1s', + }); + expect(dataObj.state.minInterval).toBe('1s'); + + queriesTab.onQueryOptionsChange({ + dataSource: { name: 'grafana-testdata', type: 'grafana-testdata-datasource', default: true }, + queries: [], + minInterval: null, + }); + expect(dataObj.state.minInterval).toBe(undefined); + }); }); describe('query caching', () => { diff --git a/public/app/features/dashboard-scene/panel-edit/PanelDataPane/PanelDataQueriesTab.tsx b/public/app/features/dashboard-scene/panel-edit/PanelDataPane/PanelDataQueriesTab.tsx index 9eb246042fd..9881cca477e 100644 --- a/public/app/features/dashboard-scene/panel-edit/PanelDataPane/PanelDataQueriesTab.tsx +++ b/public/app/features/dashboard-scene/panel-edit/PanelDataPane/PanelDataQueriesTab.tsx @@ -201,8 +201,8 @@ export class PanelDataQueriesTab extends SceneObjectBase