Skip to content

Commit 7fa6813

Browse files
authored
dataviews.clearCache cleanup (#136256)
1 parent bfa1968 commit 7fa6813

5 files changed

Lines changed: 22 additions & 10 deletions

File tree

src/plugins/data_view_management/public/components/index_pattern_table/index_pattern_table.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ export const IndexPatternTable = ({
267267
id={dataView.id}
268268
title={dataView.title}
269269
refresh={() => {
270-
dataViews.clearCache(dataView.id);
270+
dataViews.clearInstanceCache(dataView.id);
271271
loadDataViews();
272272
}}
273273
/>

src/plugins/data_views/common/data_views/data_views.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ describe('IndexPatterns', () => {
210210

211211
// Create a normal index patterns
212212
const pattern = await indexPatterns.get('foo');
213-
indexPatterns.clearCache();
213+
indexPatterns.clearInstanceCache();
214214

215215
// Create the same one - we're going to handle concurrency
216216
const samePattern = await indexPatterns.get('foo');

src/plugins/data_views/common/data_views/data_views.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,15 @@ export interface DataViewsServiceDeps {
123123
*/
124124
export interface DataViewsServicePublicMethods {
125125
/**
126-
* Clear the cache of data views.
127-
* @param id
126+
* Clear the cache of data view saved objects.
128127
*/
129-
clearCache: (id?: string | undefined) => void;
128+
clearCache: () => void;
129+
130+
/**
131+
* Clear the cache of data view instances.
132+
*/
133+
clearInstanceCache: (id?: string) => void;
134+
130135
/**
131136
* Create data view based on the provided spec.
132137
* @param spec - Data view spec.
@@ -396,11 +401,16 @@ export class DataViewsService {
396401
};
397402

398403
/**
399-
* Clear index pattern list cache.
400-
* @param id optionally clear a single id
404+
* Clear index pattern saved objects cache.
401405
*/
402-
clearCache = (id?: string) => {
406+
clearCache = () => {
403407
this.savedObjectsCache = null;
408+
};
409+
410+
/**
411+
* Clear index pattern instance cache
412+
*/
413+
clearInstanceCache = (id?: string) => {
404414
if (id) {
405415
this.dataViewCache.clear(id);
406416
} else {

src/plugins/discover/public/application/main/discover_main_route.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export function DiscoverMainRoute(props: Props) {
102102

103103
const ipList = ip.list as Array<SavedObject<DataViewAttributes>>;
104104
const indexPatternData = resolveIndexPattern(ip, searchSource, toastNotifications);
105-
105+
await data.dataViews.refreshFields(indexPatternData);
106106
setIndexPatternList(ipList);
107107

108108
return indexPatternData;

src/plugins/unified_search/public/dataview_picker/change_dataview.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,9 @@ export function ChangeDataView({
166166
panelItems.push(
167167
<DataViewsList
168168
dataViewsList={dataViewsList}
169-
onChangeDataView={(newId) => {
169+
onChangeDataView={async (newId) => {
170+
const dataView = await data.dataViews.get(newId);
171+
await data.dataViews.refreshFields(dataView);
170172
onChangeDataView(newId);
171173
setPopoverIsOpen(false);
172174
}}

0 commit comments

Comments
 (0)