Query Panels: Pass on loading state (#62545)

This commit is contained in:
Ida Štambuk 2023-02-02 16:48:13 +01:00 committed by GitHub
parent b78af0b0f0
commit ec01e6d6b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 6 deletions

View File

@ -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: [],

View File

@ -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;