-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Enterprise Search] Update the browser/document title on plugin navig…
…ation (#74392) * Rename kibana_breadcrumbs to kibana_chrome - in anticipation of upcoming refactor where SetPageChrome now handles document title as well as Kibana breadcrumbs + cleanup exports * Add generate_title helpers - will be used by new set_chrome helper * Add setDocTitle context + behavior to set_chrome + refactor set_chrome.test.tsx: - add title tests - add SetWorkplaceSearchChrome test to increase coverage - clean up inner/outer call in favor of simpler mocks/imports - simplify isRoot tests * Update plugins to set product titles - on mount but before render * Copy feedback - change pipe separator to hyphen - to match ' - Elastic' * Add functional tests confirming that document titles updated
- Loading branch information
Constance
authored
Aug 10, 2020
1 parent
7e55da5
commit 697cd64
Showing
25 changed files
with
243 additions
and
96 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
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.