From ec01e6d6b25d9c1a05e8c7f81de58d3740d7dba2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ida=20=C5=A0tambuk?= Date: Thu, 2 Feb 2023 16:48:13 +0100 Subject: [PATCH] Query Panels: Pass on loading state (#62545) --- .../query/components/QueryEditorRow.test.ts | 15 ++++++++++++++- .../features/query/components/QueryEditorRow.tsx | 12 +++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/public/app/features/query/components/QueryEditorRow.test.ts b/public/app/features/query/components/QueryEditorRow.test.ts index 0e2670eb5e4..338461e7436 100644 --- a/public/app/features/query/components/QueryEditorRow.test.ts +++ b/public/app/features/query/components/QueryEditorRow.test.ts @@ -109,8 +109,21 @@ describe('filterPanelDataToQuery', () => { const panelDataA = filterPanelDataToQuery(loadingData, 'A'); expect(panelDataA?.state).toBe(LoadingState.Loading); }); + it('should keep the state in loading until all queries are finished, even if the current query has errored', () => { + const loadingData: PanelData = { + state: LoadingState.Loading, + series: [], + error: { + refId: 'A', + message: 'Error', + }, + timeRange: { from: dateTime(), to: dateTime(), raw: { from: 'now-1d', to: 'now' } }, + }; - it('should not set the state to error if the frame is still loading', () => { + const panelDataA = filterPanelDataToQuery(loadingData, 'A'); + expect(panelDataA?.state).toBe(LoadingState.Loading); + }); + it('should keep the state in loading until all queries are finished, if another query has errored', () => { const loadingData: PanelData = { state: LoadingState.Loading, series: [], diff --git a/public/app/features/query/components/QueryEditorRow.tsx b/public/app/features/query/components/QueryEditorRow.tsx index ccf32ab5d08..13fc765567a 100644 --- a/public/app/features/query/components/QueryEditorRow.tsx +++ b/public/app/features/query/components/QueryEditorRow.tsx @@ -10,13 +10,13 @@ import { DataQuery, DataSourceApi, DataSourceInstanceSettings, + DataSourcePluginContextProvider, EventBusExtended, EventBusSrv, HistoryItem, LoadingState, PanelData, PanelEvents, - DataSourcePluginContextProvider, QueryResultMetaNotice, TimeRange, toLegacyResponseData, @@ -568,10 +568,12 @@ export function filterPanelDataToQuery(data: PanelData, refId: string): PanelDat // Only say this is an error if the error links to the query let state = data.state; const error = data.error && data.error.refId === refId ? data.error : undefined; - if (error) { - state = LoadingState.Error; - } else if (!error && data.state === LoadingState.Error) { - state = LoadingState.Done; + if (state !== LoadingState.Loading) { + if (error) { + state = LoadingState.Error; + } else if (data.state === LoadingState.Error) { + state = LoadingState.Done; + } } const timeRange = data.timeRange;