-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Dev Tools] Change breadcrumbs and docTitle when toggling between apps (
- Loading branch information
1 parent
4d3d95a
commit 617be51
Showing
15 changed files
with
228 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
|
||
export const i18Texts = { | ||
breadcrumbs: { | ||
home: i18n.translate('devTools.breadcrumb.homeLabel', { | ||
defaultMessage: 'Dev Tools', | ||
}), | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,7 @@ | |
flex-direction: column; | ||
flex-grow: 1; | ||
} | ||
|
||
.devApp__tabBeta { | ||
vertical-align: middle; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { ManagementAppMountParams } from '../../../management/public'; | ||
import { i18Texts } from '../constants/texts'; | ||
|
||
export type SetBreadcrumbs = ManagementAppMountParams['setBreadcrumbs']; | ||
|
||
export class BreadcrumbService { | ||
private setBreadcrumbsHandler?: SetBreadcrumbs; | ||
|
||
public setup(setBreadcrumbsHandler: SetBreadcrumbs): void { | ||
this.setBreadcrumbsHandler = setBreadcrumbsHandler; | ||
} | ||
|
||
public setBreadcrumbs(page: string): void { | ||
if (!this.setBreadcrumbsHandler) { | ||
throw new Error('Breadcrumb service has not been initialized'); | ||
} | ||
|
||
if (!page || page === 'home') { | ||
this.setBreadcrumbsHandler([{ text: i18Texts.breadcrumbs.home }]); | ||
} else { | ||
this.setBreadcrumbsHandler([{ text: i18Texts.breadcrumbs.home, href: '#/' }, { text: page }]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { i18Texts } from '../constants/texts'; | ||
|
||
type ChangeDocTitleHandler = (newTitle: string | string[]) => void; | ||
|
||
export class DocTitleService { | ||
private changeDocTitleHandler: ChangeDocTitleHandler = () => {}; | ||
|
||
public setup(_changeDocTitleHandler: ChangeDocTitleHandler): void { | ||
this.changeDocTitleHandler = _changeDocTitleHandler; | ||
} | ||
|
||
public setTitle(page: string): void { | ||
if (!this.changeDocTitleHandler) { | ||
throw new Error('DocTitle service has not been initialized'); | ||
} | ||
|
||
if (!page || page === 'home') { | ||
this.changeDocTitleHandler(i18Texts.breadcrumbs.home); | ||
} else { | ||
this.changeDocTitleHandler(`${page} - ${i18Texts.breadcrumbs.home}`); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
export { DocTitleService } from './doc_title'; | ||
export { BreadcrumbService } from './breadcrumb'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.