import { EuiBreadcrumb } from '@elastic/eui' ; import { i18n } from '@kbn/i18n' ; import { ChromeBreadcrumb } from 'kibana/public' ; import { NavigateToPath } from '../contexts/kibana' ; export const ML_BREADCRUMB = Object . freeze ( { text : i18n . translate ( 'xpack.ml.machineLearningBreadcrumbLabel' , { defaultMessage : 'Machine Learning' , } ) , href : '/' , } ) ; export const SETTINGS_BREADCRUMB = Object . freeze ( { text : i18n . translate ( 'xpack.ml.settingsBreadcrumbLabel' , { defaultMessage : 'Settings' , } ) , href : '/settings' , } ) ; export const ANOMALY_DETECTION_BREADCRUMB = Object . freeze ( { text : i18n . translate ( 'xpack.ml.anomalyDetectionBreadcrumbLabel' , { defaultMessage : 'Anomaly Detection' , } ) , href : '/jobs' , } ) ; export const DATA_FRAME_ANALYTICS_BREADCRUMB = Object . freeze ( { text : i18n . translate ( 'xpack.ml.dataFrameAnalyticsLabel' , { defaultMessage : 'Data Frame Analytics' , } ) , href : '/data_frame_analytics' , } ) ; export const TRAINED_MODELS = Object . freeze ( { text : i18n . translate ( 'xpack.ml.trainedModelsLabel' , { defaultMessage : 'Trained Models' , } ) , href : '/trained_models' , } ) ; export const DATA_VISUALIZER_BREADCRUMB = Object . freeze ( { text : i18n . translate ( 'xpack.ml.datavisualizerBreadcrumbLabel' , { defaultMessage : 'Data Visualizer' , } ) , href : '/datavisualizer' , } ) ; export const CREATE_JOB_BREADCRUMB = Object . freeze ( { text : i18n . translate ( 'xpack.ml.createJobsBreadcrumbLabel' , { defaultMessage : 'Create job' , } ) , href : '/jobs/new_job' , } ) ; export const CALENDAR_MANAGEMENT_BREADCRUMB = Object . freeze ( { text : i18n . translate ( 'xpack.ml.settings.breadcrumbs.calendarManagementLabel' , { defaultMessage : 'Calendar management' , } ) , href : '/settings/calendars_list' , } ) ; export const FILTER_LISTS_BREADCRUMB = Object . freeze ( { text : i18n . translate ( 'xpack.ml.settings.breadcrumbs.filterListsLabel' , { defaultMessage : 'Filter lists' , } ) , href : '/settings/filter_lists' , } ) ; const breadcrumbs = { ML_BREADCRUMB , SETTINGS_BREADCRUMB , ANOMALY_DETECTION_BREADCRUMB , DATA_FRAME_ANALYTICS_BREADCRUMB , TRAINED_MODELS , DATA_VISUALIZER_BREADCRUMB , CREATE_JOB_BREADCRUMB , CALENDAR_MANAGEMENT_BREADCRUMB , FILTER_LISTS_BREADCRUMB , } ; type Breadcrumb = keyof typeof breadcrumbs ; export const breadcrumbOnClickFactory = ( path , navigateToPath ) : EuiBreadcrumb [ 'onClick' ] => { return ( e ) => { e . preventDefault ( ) ; navigateToPath ( path ) ; } ; } ; export const getBreadcrumbWithUrlForApp = ( breadcrumbName , navigateToPath , basePath ) : EuiBreadcrumb => { return { text : breadcrumbs [ breadcrumbName ] . text , href : `${ basePath }/app/ml${ breadcrumbs [ breadcrumbName ] . href }` , onClick : breadcrumbOnClickFactory ( breadcrumbs [ breadcrumbName ] . href , navigateToPath ) , } ; } ;