@@ -11,7 +11,7 @@ import { useEffect, useMemo, useState } from 'react';
1111import memoizeOne from 'memoize-one' ;
1212import { IIndexPattern } from 'src/plugins/data/public' ;
1313
14- import { DEFAULT_INDEX_KEY } from '../../../../common/constants' ;
14+ import { DEFAULT_INDEX_KEY , NO_ALERT_INDEX } from '../../../../common/constants' ;
1515import { useUiSetting$ } from '../../lib/kibana' ;
1616
1717import { IndexField , SourceQuery } from '../../../graphql/types' ;
@@ -126,8 +126,9 @@ export const useWithSource = (
126126) => {
127127 const [ configIndex ] = useUiSetting$ < string [ ] > ( DEFAULT_INDEX_KEY ) ;
128128 const defaultIndex = useMemo < string [ ] > ( ( ) => {
129- if ( indexToAdd != null && ! isEmpty ( indexToAdd ) ) {
130- return onlyCheckIndexToAdd ? indexToAdd : [ ...configIndex , ...indexToAdd ] ;
129+ const filterIndexAdd = ( indexToAdd ?? [ ] ) . filter ( ( item ) => item !== NO_ALERT_INDEX ) ;
130+ if ( ! isEmpty ( filterIndexAdd ) ) {
131+ return onlyCheckIndexToAdd ? filterIndexAdd : [ ...configIndex , ...filterIndexAdd ] ;
131132 }
132133 return configIndex ;
133134 } , [ configIndex , indexToAdd , onlyCheckIndexToAdd ] ) ;
@@ -138,7 +139,7 @@ export const useWithSource = (
138139 errorMessage : null ,
139140 indexPattern : getIndexFields ( defaultIndex . join ( ) , [ ] ) ,
140141 indicesExist : indicesExistOrDataTemporarilyUnavailable ( undefined ) ,
141- loading : false ,
142+ loading : true ,
142143 } ) ;
143144
144145 const apolloClient = useApolloClient ( ) ;
@@ -155,7 +156,7 @@ export const useWithSource = (
155156 try {
156157 const result = await apolloClient . query < SourceQuery . Query , SourceQuery . Variables > ( {
157158 query : sourceQuery ,
158- fetchPolicy : 'cache-first ' ,
159+ fetchPolicy : 'cache-and-network ' ,
159160 variables : {
160161 sourceId,
161162 defaultIndex,
0 commit comments