From 1831fb3d2dadae43350a1ac77d085760a762120d Mon Sep 17 00:00:00 2001 From: James Gowdy Date: Mon, 14 Sep 2020 20:27:27 +0100 Subject: [PATCH] [ML] DF Analytics creation wizard: Fixing field loading race condition (#77326) --- .../data_frame_analytics/pages/analytics_creation/page.tsx | 3 --- .../routes/data_frame_analytics/analytics_job_creation.tsx | 6 +++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/page.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/page.tsx index da5caf8e3875a..e72af6a0e30c2 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/page.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_creation/page.tsx @@ -21,7 +21,6 @@ import { import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { useMlContext } from '../../../contexts/ml'; -import { newJobCapsService } from '../../../services/new_job_capabilities_service'; import { ml } from '../../../services/ml_api_service'; import { useCreateAnalyticsForm } from '../analytics_management/hooks/use_create_analytics_form'; import { CreateAnalyticsAdvancedEditor } from './components/create_analytics_advanced_editor'; @@ -62,8 +61,6 @@ export const Page: FC = ({ jobId }) => { if (currentIndexPattern) { (async function () { - await newJobCapsService.initializeFromIndexPattern(currentIndexPattern, false, false); - if (jobId !== undefined) { const analyticsConfigs = await ml.dataFrameAnalytics.getDataFrameAnalytics(jobId); if ( diff --git a/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_job_creation.tsx b/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_job_creation.tsx index 8c45398098b2f..4ce2abf3fef60 100644 --- a/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_job_creation.tsx +++ b/x-pack/plugins/ml/public/application/routing/routes/data_frame_analytics/analytics_job_creation.tsx @@ -16,6 +16,7 @@ import { useResolver } from '../../use_resolver'; import { basicResolvers } from '../../resolvers'; import { Page } from '../../../data_frame_analytics/pages/analytics_creation'; import { breadcrumbOnClickFactory, getBreadcrumbWithUrlForApp } from '../../breadcrumbs'; +import { loadNewJobCapabilities } from '../../../services/new_job_capabilities_service'; export const analyticsJobsCreationRouteFactory = (navigateToPath: NavigateToPath): MlRoute => ({ path: '/data_frame_analytics/new_job', @@ -36,7 +37,10 @@ const PageWrapper: FC = ({ location, deps }) => { sort: false, }); - const { context } = useResolver(index, savedSearchId, deps.config, basicResolvers(deps)); + const { context } = useResolver(index, savedSearchId, deps.config, { + ...basicResolvers(deps), + jobCaps: () => loadNewJobCapabilities(index, savedSearchId, deps.indexPatterns), + }); return (