diff --git a/src/plugins/data_views/common/data_views/data_views.ts b/src/plugins/data_views/common/data_views/data_views.ts index adce2a0079945..b51ba21a0fc65 100644 --- a/src/plugins/data_views/common/data_views/data_views.ts +++ b/src/plugins/data_views/common/data_views/data_views.ts @@ -824,12 +824,20 @@ export class DataViewsService { displayErrors?: boolean; }) => { const { title, type, typeMeta, runtimeFieldMap } = spec; + + console.log('============= initFromSavedObjectLoadFields', savedObjectId, title); + + const pattern = + savedObjectId === 'alerts' && true ? '.alerts-security.alerts-default' : (title as string); + + console.log('============= initFromSavedObjectLoadFields', pattern); + const { fields, indices, etag } = await this.refreshFieldSpecMap( spec.fields || {}, savedObjectId, spec.title as string, { - pattern: title as string, + pattern, metaFields: await this.getMetaFields(), type, rollupIndex: typeMeta?.params?.rollup_index, @@ -997,20 +1005,20 @@ export class DataViewsService { displayErrors: boolean = true, refreshFields = false ): Promise => { - const dataViewFromCache = this.dataViewCache.get(id)?.then(async (dataView) => { - if (dataView && refreshFields) { - await this.refreshFields(dataView, displayErrors); - } - return dataView; - }); - - let indexPatternPromise: Promise; - if (dataViewFromCache) { - indexPatternPromise = dataViewFromCache; - } else { - indexPatternPromise = this.getSavedObjectAndInit(id, displayErrors); - this.dataViewCache.set(id, indexPatternPromise); - } + // const dataViewFromCache = this.dataViewCache.get(id)?.then(async (dataView) => { + // if (dataView && refreshFields) { + // await this.refreshFields(dataView, displayErrors); + // } + // return dataView; + // }); + + // let indexPatternPromise: Promise; + // if (dataViewFromCache) { + // indexPatternPromise = dataViewFromCache; + // } else { + const indexPatternPromise = this.getSavedObjectAndInit(id, displayErrors); + this.dataViewCache.set(id, indexPatternPromise); + // } // don't cache failed requests indexPatternPromise.catch(() => { diff --git a/x-pack/plugins/security_solution/public/common/containers/sourcerer/index.tsx b/x-pack/plugins/security_solution/public/common/containers/sourcerer/index.tsx index 0a8985d5bfb86..fb34463a72380 100644 --- a/x-pack/plugins/security_solution/public/common/containers/sourcerer/index.tsx +++ b/x-pack/plugins/security_solution/public/common/containers/sourcerer/index.tsx @@ -401,6 +401,11 @@ export const useSourcererDataView = ( const selectedDataView = useMemo(() => { return kibanaDataViews.find((dataView) => dataView.id === selectedDataViewId); }, [kibanaDataViews, selectedDataViewId]); + + // FIXME: + console.log('selectedDataView', selectedDataViewId, selectedDataView); + console.log('defaultDataView', defaultDataView); + const loading = useSelector((state: State) => { return sourcererSelectors.sourcererScopeIsLoading(state, scopeId); }); @@ -485,6 +490,7 @@ export const useSourcererDataView = ( browserFields: browserFields(), dataViewId: sourcererDataView.id, indexPattern: { + // FIXME: fix this omg fields: sourcererDataView.indexFields, title: selectedPatterns.join(','), getName: () => selectedPatterns.join(','), diff --git a/x-pack/plugins/security_solution/public/common/store/sourcerer/selectors.ts b/x-pack/plugins/security_solution/public/common/store/sourcerer/selectors.ts index 71cbef670cb6e..ecca992c4338d 100644 --- a/x-pack/plugins/security_solution/public/common/store/sourcerer/selectors.ts +++ b/x-pack/plugins/security_solution/public/common/store/sourcerer/selectors.ts @@ -77,7 +77,7 @@ export const kibanaDataViews = createSelector( export const defaultDataView = createSelector( selectSourcerer, - (sourcerer) => sourcerer.defaultDataView, + (sourcerer) => sourcerer.kibanaDataViews.find(({ id }) => id === 'alerts') as any, { memoizeOptions: { maxSize: SOURCERER_SCOPE_MAX_SIZE,