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 { IndexDataVisualizerPage as Page } from '../../../datavisualizer/index_based/index_data_visualizer' ; import { checkBasicLicense } from '../../../license' ; import { checkGetJobsCapabilitiesResolver } from '../../../capabilities/check_capabilities' ; import { cacheDataViewsContract } from '../../../util/index_utils' ; import { getBreadcrumbWithUrlForApp } from '../../breadcrumbs' ; export const indexBasedRouteFactory = ( navigateToPath , basePath ) : MlRoute => ( { id : 'datavisualizer' , path : '/jobs/new_job/datavisualizer' , render : ( props , deps ) => < PageWrapper { ... props } deps = { deps } / > , breadcrumbs : [ getBreadcrumbWithUrlForApp ( 'ML_BREADCRUMB' , navigateToPath , basePath ) , getBreadcrumbWithUrlForApp ( 'DATA_VISUALIZER_BREADCRUMB' , navigateToPath , basePath ) , { text : i18n . translate ( 'xpack.ml.dataFrameAnalyticsBreadcrumbs.indexLabel' , { defaultMessage : 'Index' , } ) , href : '' , } , ] , } ) ; const PageWrapper = ( { location , deps } ) => { const { redirectToMlAccessDeniedPage } = deps ; const { index , savedSearchId } = parse ( location . search , { sort : false } ) ; const { context } = useResolver ( index , savedSearchId , deps . config , deps . dataViewsContract , { checkBasicLicense , cacheDataViewsContract : ( ) => cacheDataViewsContract ( deps . dataViewsContract ) , checkGetJobsCapabilities : ( ) => checkGetJobsCapabilitiesResolver ( redirectToMlAccessDeniedPage ) , } ) ; return ( < PageLoader context = { context } > < Page /> < /PageLoader>); } ;