From da91c93f4acedfa38305a6bbe85864fe5ae92f22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Bedi?= Date: Wed, 16 Feb 2022 11:48:22 +0100 Subject: [PATCH] QueryEditor: Fix setting panel state to done if query had no error (#45453) --- .../query/components/QueryEditorRow.test.ts | 17 +++++++++++++++++ .../query/components/QueryEditorRow.tsx | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/public/app/features/query/components/QueryEditorRow.test.ts b/public/app/features/query/components/QueryEditorRow.test.ts index e5bac2a77c3..6117923d66c 100644 --- a/public/app/features/query/components/QueryEditorRow.test.ts +++ b/public/app/features/query/components/QueryEditorRow.test.ts @@ -74,4 +74,21 @@ describe('filterPanelDataToQuery', () => { expect(panelDataA?.series[0].refId).toBe('A'); expect(panelDataA?.state).toBe(LoadingState.Done); }); + + it('should not set the state to done if the frame is loading and has no errors', () => { + const loadingData: PanelData = { + state: LoadingState.Loading, + series: [ + toDataFrame({ refId: 'A', fields: [{ name: 'AAA' }], meta: {} }), + toDataFrame({ refId: 'B', fields: [{ name: 'B111' }], meta: {} }), + ], + timeRange: { from: dateTime(), to: dateTime(), raw: { from: 'now-1d', to: 'now' } }, + }; + + const panelDataB = filterPanelDataToQuery(loadingData, 'B'); + expect(panelDataB?.state).toBe(LoadingState.Loading); + + const panelDataA = filterPanelDataToQuery(loadingData, 'A'); + expect(panelDataA?.state).toBe(LoadingState.Loading); + }); }); diff --git a/public/app/features/query/components/QueryEditorRow.tsx b/public/app/features/query/components/QueryEditorRow.tsx index 7462010ce6d..fb7a32444c3 100644 --- a/public/app/features/query/components/QueryEditorRow.tsx +++ b/public/app/features/query/components/QueryEditorRow.tsx @@ -480,7 +480,7 @@ export function filterPanelDataToQuery(data: PanelData, refId: string): PanelDat const error = data.error && data.error.refId === refId ? data.error : undefined; if (error) { state = LoadingState.Error; - } else { + } else if (!error && data.state === LoadingState.Error) { state = LoadingState.Done; }