fix rule form crashing when extra query editor actions are provided (#40319)

This commit is contained in:
Domas 2021-10-12 13:49:30 +03:00 committed by GitHub
parent 9fb6dfe11d
commit b1f56b4863
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -3,6 +3,7 @@ import { DragDropContext, Droppable, DropResult } from 'react-beautiful-dnd';
import {
DataQuery,
DataSourceInstanceSettings,
LoadingState,
PanelData,
RelativeTimeRange,
ThresholdsConfig,
@ -230,13 +231,15 @@ export class QueryRows extends PureComponent<Props, State> {
return (
<div ref={provided.innerRef} {...provided.droppableProps}>
{queries.map((query, index) => {
const data = this.props.data ? this.props.data[query.refId] : ({} as PanelData);
const data: PanelData = this.props.data?.[query.refId] ?? {
series: [],
state: LoadingState.NotStarted,
};
const dsSettings = this.getDataSourceSettings(query);
if (!dsSettings) {
return null;
}
return (
<QueryWrapper
index={index}

View File

@ -6,6 +6,7 @@ import {
DataSourceInstanceSettings,
getDefaultRelativeTimeRange,
GrafanaTheme2,
LoadingState,
PanelData,
RelativeTimeRange,
ThresholdsConfig,
@ -83,7 +84,7 @@ export const QueryWrapper: FC<Props> = ({
queries={queries}
renderHeaderExtras={() => renderTimePicker(query, index)}
visualization={
data ? (
data.state !== LoadingState.NotStarted ? (
<VizWrapper
data={data}
changePanel={changePluginId}