import { i18n } from '@kbn/i18n' ; import { ChromeBreadcrumb } from 'kibana/public' ; import { ManagementAppMountParams } from '../../../../../../src/plugins/management/public' ; type SetBreadcrumbs = ManagementAppMountParams [ 'setBreadcrumbs' ] ; const breadcrumbs = ( function ( ) { const policies = [ { text : i18n . translate ( 'xpack.indexLifecycleMgmt.breadcrumb.homeLabel' , { defaultMessage : 'Index Lifecycle Management' , } ) , href : `/policies` , } , ] ; const editPolicy = [ ... policies , { text : i18n . translate ( 'xpack.indexLifecycleMgmt.breadcrumb.editPolicyLabel' , { defaultMessage : 'Edit policy' , } ) , href : undefined , } , ] ; return { policies , editPolicy , } ; } ) ( ) ; export class BreadcrumbService { private setBreadcrumbsHandler ? : SetBreadcrumbs ; public setup ( setBreadcrumbsHandler ) { this . setBreadcrumbsHandler = setBreadcrumbsHandler ; } public setBreadcrumbs ( type ) { if ( ! this . setBreadcrumbsHandler ) { throw new Error ( `BreadcrumbService#setup() must be called first!` ) ; } const newBreadcrumbs = breadcrumbs [ type ] ? [ ... breadcrumbs [ type ] ] : [ ... breadcrumbs . policies ] ; const lastBreadcrumb = newBreadcrumbs . pop ( ) as { text : string ; href ? : string ; } ; newBreadcrumbs . push ( { ... lastBreadcrumb , href : undefined , } ) ; this . setBreadcrumbsHandler ( newBreadcrumbs ) ; } }