-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Enterprise Search] Update the browser/document title on plugin navigation #74392
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3d92c64
Rename kibana_breadcrumbs to kibana_chrome
cee-chen d2ed181
Add generate_title helpers
cee-chen ed93556
Add setDocTitle context + behavior to set_chrome
cee-chen ac26757
Update plugins to set product titles
cee-chen 5d75916
Copy feedback - change pipe separator to hyphen
cee-chen 2b7bba5
Add functional tests confirming that document titles updated
cee-chen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
63 changes: 0 additions & 63 deletions
63
.../enterprise_search/public/applications/shared/kibana_breadcrumbs/set_breadcrumbs.test.tsx
This file was deleted.
Oops, something went wrong.
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
File renamed without changes.
60 changes: 60 additions & 0 deletions
60
...plugins/enterprise_search/public/applications/shared/kibana_chrome/generate_title.test.ts
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,60 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { | ||
generateTitle, | ||
enterpriseSearchTitle, | ||
appSearchTitle, | ||
workplaceSearchTitle, | ||
} from './generate_title'; | ||
|
||
describe('generateTitle', () => { | ||
it('creates a hyphen separated string from an array of page titles', () => { | ||
const title = generateTitle(['Curations', 'some Engine', 'App Search']); | ||
expect(title).toEqual('Curations - some Engine - App Search'); | ||
}); | ||
}); | ||
|
||
describe('enterpriseSearchTitle', () => { | ||
it('automatically appends the Enterprise Search product onto the pages array', () => { | ||
const title = enterpriseSearchTitle(['Setup Guide']); | ||
expect(title).toEqual('Setup Guide - Enterprise Search'); | ||
}); | ||
|
||
it('can be mixed and matched', () => { | ||
const title = enterpriseSearchTitle([appSearchTitle(['Some Page'])]); | ||
expect(title).toEqual('Some Page - App Search - Enterprise Search'); | ||
}); | ||
|
||
it('falls back to product name', () => { | ||
const title = enterpriseSearchTitle(); | ||
expect(title).toEqual('Enterprise Search'); | ||
}); | ||
}); | ||
|
||
describe('appSearchTitle', () => { | ||
it('automatically appends the App Search product onto the pages array', () => { | ||
const title = appSearchTitle(['Engines']); | ||
expect(title).toEqual('Engines - App Search'); | ||
}); | ||
|
||
it('falls back to product name', () => { | ||
const title = appSearchTitle(); | ||
expect(title).toEqual('App Search'); | ||
}); | ||
}); | ||
|
||
describe('workplaceSearchTitle', () => { | ||
it('automatically appends the Workplace Search product onto the pages array', () => { | ||
const title = workplaceSearchTitle(['Sources']); | ||
expect(title).toEqual('Sources - Workplace Search'); | ||
}); | ||
|
||
it('falls back to product name', () => { | ||
const title = workplaceSearchTitle(); | ||
expect(title).toEqual('Workplace Search'); | ||
}); | ||
}); |
38 changes: 38 additions & 0 deletions
38
x-pack/plugins/enterprise_search/public/applications/shared/kibana_chrome/generate_title.ts
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,38 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { | ||
ENTERPRISE_SEARCH_PLUGIN, | ||
APP_SEARCH_PLUGIN, | ||
WORKPLACE_SEARCH_PLUGIN, | ||
} from '../../../../common/constants'; | ||
|
||
/** | ||
* Generate a document title that generally follows our breadcrumb trails | ||
* https://github.com/elastic/kibana/blob/master/docs/development/core/public/kibana-plugin-core-public.chromedoctitle.md | ||
*/ | ||
|
||
export type TTitle = string[]; | ||
|
||
/** | ||
* Given an array of page titles, return a final formatted document title | ||
* @param pages - e.g., ['Curations', 'some Engine', 'App Search'] | ||
* @returns - e.g., 'Curations | some Engine | App Search' | ||
*/ | ||
export const generateTitle = (pages: TTitle) => pages.join(' - '); | ||
|
||
/** | ||
* Product-specific helpers | ||
*/ | ||
|
||
export const enterpriseSearchTitle = (page: TTitle = []) => | ||
generateTitle([...page, ENTERPRISE_SEARCH_PLUGIN.NAME]); | ||
|
||
export const appSearchTitle = (page: TTitle = []) => | ||
generateTitle([...page, APP_SEARCH_PLUGIN.NAME]); | ||
|
||
export const workplaceSearchTitle = (page: TTitle = []) => | ||
generateTitle([...page, WORKPLACE_SEARCH_PLUGIN.NAME]); |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added courtesy of @dmlemeshko in Slack.
Dzmitry - it looks like we need a required approval from kibana-qa due to touching this file - would super appreciate it if you wouldn't mind doing so! 🙇♀️