mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
QueryEditors: include error when no data is returned (#23632)
This commit is contained in:
parent
f30074c70a
commit
806dd3f604
@ -43,4 +43,17 @@ describe('filterPanelDataToQuery', () => {
|
||||
expect(panelData?.series[0].refId).toBe('B');
|
||||
expect(panelData?.error!.refId).toBe('B');
|
||||
});
|
||||
|
||||
it('should include errors when missing data', () => {
|
||||
const withError = ({
|
||||
series: [],
|
||||
error: {
|
||||
message: 'Error!!',
|
||||
},
|
||||
} as unknown) as PanelData;
|
||||
|
||||
const panelData = filterPanelDataToQuery(withError, 'B');
|
||||
expect(panelData.state).toBe(LoadingState.Error);
|
||||
expect(panelData.error).toBe(withError.error);
|
||||
});
|
||||
});
|
||||
|
@ -335,6 +335,13 @@ export function filterPanelDataToQuery(data: PanelData, refId: string): PanelDat
|
||||
|
||||
// No matching series
|
||||
if (!series.length) {
|
||||
// If there was an error with no data, pass it to the QueryEditors
|
||||
if (data.error && !data.series.length) {
|
||||
return {
|
||||
...data,
|
||||
state: LoadingState.Error,
|
||||
};
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user