From 3be51f6c37217229c73d1cb60f28b975db73f90d Mon Sep 17 00:00:00 2001 From: Walter Rafelsberger Date: Thu, 2 Apr 2020 12:02:58 +0200 Subject: [PATCH] [ML] Clear Kibana index pattern cache on creation or form reset. (#62184) Clears the Kibana index pattern cache ... - when reopening the "Create Analytics job" flyout - after creating a transform or analyticsjob (this fixes moving from transforms to discover after creating a transform) --- .../use_create_analytics_form/use_create_analytics_form.ts | 3 +++ .../file_based/components/import_view/import_view.js | 2 ++ .../components/step_create/step_create_form.tsx | 2 ++ 3 files changed, 7 insertions(+) diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/use_create_analytics_form.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/use_create_analytics_form.ts index 34f1d04264900..44bfc0c5a472c 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/use_create_analytics_form.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/hooks/use_create_analytics_form/use_create_analytics_form.ts @@ -138,6 +138,8 @@ export const useCreateAnalyticsForm = (): CreateAnalyticsFormProps => { const id = await newIndexPattern.create(); + await mlContext.indexPatterns.clearCache(); + // id returns false if there's a duplicate index pattern. if (id === false) { addRequestMessage({ @@ -248,6 +250,7 @@ export const useCreateAnalyticsForm = (): CreateAnalyticsFormProps => { }; const openModal = async () => { + await mlContext.indexPatterns.clearCache(); resetForm(); await prepareFormValidation(); dispatch({ type: ACTION.OPEN_MODAL }); diff --git a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_view/import_view.js b/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_view/import_view.js index 94627b688b03a..0a58153e374df 100644 --- a/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_view/import_view.js +++ b/x-pack/plugins/ml/public/application/datavisualizer/file_based/components/import_view/import_view.js @@ -610,6 +610,8 @@ async function createKibanaIndexPattern( const id = await emptyPattern.create(); + await indexPatterns.clearCache(); + // check if there's a default index pattern, if not, // set the newly created one as the default index pattern. if (!kibanaConfig.get('defaultIndex')) { diff --git a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx index 49be2e67ce552..5dcaece28bdde 100644 --- a/x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx +++ b/x-pack/plugins/transform/public/app/sections/create_transform/components/step_create/step_create_form.tsx @@ -185,6 +185,8 @@ export const StepCreateForm: FC = React.memo( const id = await newIndexPattern.create(); + await indexPatterns.clearCache(); + // id returns false if there's a duplicate index pattern. if (id === false) { toastNotifications.addDanger(