Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Shahzad <shahzad.muhammad@elastic.co>
This commit is contained in:
parent
80dc8d0cad
commit
a5ceb362b1
3 changed files with 5 additions and 6 deletions
|
@ -36,7 +36,7 @@ export const QueryBar = () => {
|
|||
|
||||
const { query, setQuery } = useQueryBar();
|
||||
|
||||
const { index_pattern: indexPattern } = useIndexPattern(query.language ?? SyntaxType.text);
|
||||
const { index_pattern: indexPattern } = useIndexPattern();
|
||||
|
||||
const [inputVal, setInputVal] = useState<string>(query.query);
|
||||
|
||||
|
|
|
@ -9,18 +9,17 @@ import { useEffect } from 'react';
|
|||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { getIndexPattern } from '../../../state/actions';
|
||||
import { selectIndexPattern } from '../../../state/selectors';
|
||||
import { SyntaxType } from './use_query_bar';
|
||||
|
||||
export const useIndexPattern = (queryLanguage?: string) => {
|
||||
export const useIndexPattern = () => {
|
||||
const dispatch = useDispatch();
|
||||
const indexPattern = useSelector(selectIndexPattern);
|
||||
|
||||
useEffect(() => {
|
||||
// we only use index pattern for kql queries
|
||||
if (!indexPattern.index_pattern && (!queryLanguage || queryLanguage === SyntaxType.kuery)) {
|
||||
if (!indexPattern.index_pattern) {
|
||||
dispatch(getIndexPattern());
|
||||
}
|
||||
}, [indexPattern.index_pattern, dispatch, queryLanguage]);
|
||||
}, [indexPattern.index_pattern, dispatch]);
|
||||
|
||||
return indexPattern;
|
||||
};
|
||||
|
|
|
@ -44,7 +44,7 @@ export const useQueryBar = () => {
|
|||
}
|
||||
);
|
||||
|
||||
const { index_pattern: indexPattern } = useIndexPattern(query.language);
|
||||
const { index_pattern: indexPattern } = useIndexPattern();
|
||||
|
||||
const updateUrlParams = useUrlParams()[1];
|
||||
|
||||
|
|
Loading…
Reference in a new issue