import React , { FC } from 'react' ; import { i18n } from '@kbn/i18n' ; import { NavigateToPath } from '../../../contexts/kibana' ; import { MlRoute , PageLoader , PageProps } from '../../router' ; import { useResolver } from '../../use_resolver' ; import { FileDataVisualizerPage } from '../../../datavisualizer/file_based' ; import { checkBasicLicense } from '../../../license' ; import { checkFindFileStructurePrivilegeResolver } from '../../../capabilities/check_capabilities' ; import { cacheDataViewsContract } from '../../../util/index_utils' ; import { getBreadcrumbWithUrlForApp } from '../../breadcrumbs' ; export const fileBasedRouteFactory = ( navigateToPath , basePath ) : MlRoute => ( { id : 'filedatavisualizer' , path : '/filedatavisualizer' , render : ( props , deps ) => < PageWrapper { ... props } deps = { deps } / > , breadcrumbs : [ getBreadcrumbWithUrlForApp ( 'ML_BREADCRUMB' , navigateToPath , basePath ) , getBreadcrumbWithUrlForApp ( 'DATA_VISUALIZER_BREADCRUMB' , navigateToPath , basePath ) , { text : i18n . translate ( 'xpack.ml.dataVisualizer.fileBasedLabel' , { defaultMessage : 'File' , } ) , href : '' , } , ] , } ) ; const PageWrapper = ( { deps } ) => { const { redirectToMlAccessDeniedPage } = deps ; const { context } = useResolver ( undefined , undefined , deps . config , deps . dataViewsContract , { checkBasicLicense , cacheDataViewsContract : ( ) => cacheDataViewsContract ( deps . dataViewsContract ) , checkFindFileStructurePrivilege : ( ) => checkFindFileStructurePrivilegeResolver ( redirectToMlAccessDeniedPage ) , } ) ; return ( < PageLoader context = { context } > < FileDataVisualizerPage /> < /PageLoader>); } ;