* Loki: Fix running queries without an `expr`
* rever previous change
* only dispatch `initQuery` if the DS is uninitialized
* moved `isUninitialized` to static var
(cherry picked from commit a3ff758874)
Co-authored-by: Sven Grossmann <Svennergr@gmail.com>
This commit is contained in:
co-authored by
Sven Grossmann
parent
4c1225219c
commit
404abe2be6
+6
-4
@@ -1,4 +1,4 @@
|
||||
import React, { Context, createContext, PropsWithChildren, useCallback, useContext, useEffect } from 'react';
|
||||
import React, { Context, createContext, PropsWithChildren, useCallback, useContext, useEffect, useState } from 'react';
|
||||
|
||||
import { TimeRange } from '@grafana/data';
|
||||
|
||||
@@ -54,14 +54,16 @@ export const ElasticsearchProvider = ({
|
||||
|
||||
const isUninitialized = !query.metrics || !query.bucketAggs || query.query === undefined;
|
||||
|
||||
const [shouldRunInit, setShouldRunInit] = useState(isUninitialized);
|
||||
|
||||
// This initializes the query by dispatching an init action to each reducer.
|
||||
// useStatelessReducer will then call `onChange` with the newly generated query
|
||||
|
||||
useEffect(() => {
|
||||
if (isUninitialized) {
|
||||
if (shouldRunInit) {
|
||||
dispatch(initQuery());
|
||||
setShouldRunInit(false);
|
||||
}
|
||||
});
|
||||
}, [shouldRunInit, dispatch]);
|
||||
|
||||
if (isUninitialized) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user