import React , { FC } from 'react' ; import { parse } from 'query-string' ; import { i18n } from '@kbn/i18n' ; import { NavigateToPath } from '../../../contexts/kibana' ; import { MlRoute , PageLoader , PageProps } from '../../router' ; import { useResolver } from '../../use_resolver' ; import { basicResolvers } from '../../resolvers' ; import { Page } from '../../../jobs/new_job/pages/job_type' ; import { getBreadcrumbWithUrlForApp } from '../../breadcrumbs' ; export const jobTypeRouteFactory = ( navigateToPath , basePath ) : MlRoute => ( { path : '/jobs/new_job/step/job_type' , render : ( props , deps ) => < PageWrapper { ... props } deps = { deps } / > , breadcrumbs : [ getBreadcrumbWithUrlForApp ( 'ML_BREADCRUMB' , navigateToPath , basePath ) , getBreadcrumbWithUrlForApp ( 'ANOMALY_DETECTION_BREADCRUMB' , navigateToPath , basePath ) , { text : i18n . translate ( 'xpack.ml.jobsBreadcrumbs.selectJobType' , { defaultMessage : 'Create job' , } ) , href : '' , } , ] , } ) ; const PageWrapper = ( { location , deps } ) => { const { index , savedSearchId } = parse ( location . search , { sort : false } ) ; const { context } = useResolver ( index , savedSearchId , deps . config , deps . dataViewsContract , basicResolvers ( deps ) ) ; return ( < PageLoader context = { context } > < Page /> < /PageLoader>); } ;