import { i18n } from '@kbn/i18n' ; import { ChromeStart } from 'kibana/public' ; import { GraphWorkspaceSavedObject } from '../types' ; import { MetaDataState } from '../state_management' ; export function getHomePath ( ) { return '/home' ; } export function getNewPath ( ) { return '/workspace' ; } export function getEditPath ( { id } ) { return `/workspace/${ id }` ; } export function getEditUrl ( addBasePath , workspace ) { return addBasePath ( `#${ getEditPath ( workspace ) }` ) ; } export type SetBreadcrumbOptions = { chrome : ChromeStart ; } | { chrome : ChromeStart ; metaData : MetaDataState ; navigateTo : ( path : string ) => void ; } ; export function setBreadcrumbs ( options ) { if ( 'metaData' in options ) { options . chrome . setBreadcrumbs ( [ { text : i18n . translate ( 'xpack.graph.home.breadcrumb' , { defaultMessage : 'Graph' , } ) , onClick : ( ) => { options . navigateTo ( getHomePath ( ) ) ; } , 'data-test-subj' : 'graphHomeBreadcrumb' , } , { text : options . metaData . title , 'data-test-subj' : 'graphCurrentGraphBreadcrumb' , } , ] ) ; } else { options . chrome . setBreadcrumbs ( [ { text : i18n . translate ( 'xpack.graph.home.breadcrumb' , { defaultMessage : 'Graph' , } ) , href : `#${ getHomePath ( ) }` , 'data-test-subj' : 'graphHomeBreadcrumb' , } , ] ) ; } }