33 * or more contributor license agreements. Licensed under the Elastic License;
44 * you may not use this file except in compliance with the Elastic License.
55 */
6+ import { i18n } from '@kbn/i18n' ;
67import { createHashHistory } from 'history' ;
78import React , { useEffect } from 'react' ;
89import ReactDOM from 'react-dom' ;
910import { Route , Router , Switch } from 'react-router-dom' ;
10- import { i18n } from '@kbn/i18n' ;
11- import { RedirectAppLinks } from '../../../../../src/plugins/kibana_react/public' ;
1211import { AppMountParameters , CoreStart } from '../../../../../src/core/public' ;
12+ import { RedirectAppLinks } from '../../../../../src/plugins/kibana_react/public' ;
1313import { EuiThemeProvider } from '../../../../legacy/common/eui_styled_components' ;
1414import { PluginContext } from '../context/plugin_context' ;
15- import { useRouteParams } from '../hooks/use_route_params' ;
16- import { routes } from '../routes' ;
1715import { usePluginContext } from '../hooks/use_plugin_context' ;
16+ import { useRouteParams } from '../hooks/use_route_params' ;
17+ import { Breadcrumbs , routes } from '../routes' ;
18+
19+ const observabilityLabelBreadcrumb = {
20+ text : i18n . translate ( 'xpack.observability.observability.breadcrumb.' , {
21+ defaultMessage : 'Observability' ,
22+ } ) ,
23+ } ;
24+
25+ function getTitleFromBreadCrumbs ( breadcrumbs : Breadcrumbs ) {
26+ return breadcrumbs
27+ . map ( ( { text } ) => text )
28+ . reverse ( )
29+ . join ( ' | ' ) ;
30+ }
1831
1932const App = ( ) => {
2033 return (
@@ -25,16 +38,12 @@ const App = () => {
2538 const route = routes [ path ] ;
2639 const Wrapper = ( ) => {
2740 const { core } = usePluginContext ( ) ;
41+
42+ const breadcrumb = [ observabilityLabelBreadcrumb , ...route . breadcrumb ] ;
2843 useEffect ( ( ) => {
29- core . chrome . setBreadcrumbs ( [
30- {
31- text : i18n . translate ( 'xpack.observability.observability.breadcrumb.' , {
32- defaultMessage : 'Observability' ,
33- } ) ,
34- } ,
35- ...route . breadcrumb ,
36- ] ) ;
37- } , [ core ] ) ;
44+ core . chrome . setBreadcrumbs ( breadcrumb ) ;
45+ document . title = getTitleFromBreadCrumbs ( breadcrumb ) ;
46+ } , [ core , breadcrumb ] ) ;
3847
3948 const { query, path : pathParams } = useRouteParams ( route . params ) ;
4049 return route . handler ( { query, path : pathParams } ) ;
0 commit comments