mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Elasticsearch: Fix infinite loop when using mixed datasources (#70386)
* Elasticsearch context: do not init query when it is already initialized * Fix buggy conditional
This commit is contained in:
parent
e60966d977
commit
dbf7ebb923
@ -107,10 +107,9 @@ export const createReducer =
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (initQuery.match(action)) {
|
if (initQuery.match(action)) {
|
||||||
if (state?.length || 0 > 0) {
|
if (state && state.length > 0) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [{ ...defaultBucketAgg('2'), field: defaultTimeField }];
|
return [{ ...defaultBucketAgg('2'), field: defaultTimeField }];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,11 +59,11 @@ export const ElasticsearchProvider = ({
|
|||||||
// This initializes the query by dispatching an init action to each reducer.
|
// This initializes the query by dispatching an init action to each reducer.
|
||||||
// useStatelessReducer will then call `onChange` with the newly generated query
|
// useStatelessReducer will then call `onChange` with the newly generated query
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (shouldRunInit) {
|
if (shouldRunInit && isUninitialized) {
|
||||||
dispatch(initQuery());
|
dispatch(initQuery());
|
||||||
setShouldRunInit(false);
|
setShouldRunInit(false);
|
||||||
}
|
}
|
||||||
}, [shouldRunInit, dispatch]);
|
}, [shouldRunInit, dispatch, isUninitialized]);
|
||||||
|
|
||||||
if (isUninitialized) {
|
if (isUninitialized) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -155,7 +155,7 @@ export const reducer = (state: ElasticsearchQuery['metrics'], action: Action): E
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (initQuery.match(action)) {
|
if (initQuery.match(action)) {
|
||||||
if (state?.length || 0 > 0) {
|
if (state && state.length > 0) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
return [defaultMetricAgg('1')];
|
return [defaultMetricAgg('1')];
|
||||||
|
Loading…
Reference in New Issue
Block a user