fix: [Elasticsearch][COGNITION]: Page titles must be unique for each view (#192268)

Closes: https://github.com/elastic/search-team/issues/8215

## Description
Three views (Home, Connectors, and Playground) have page titles that are
just "Elastic". These page titles must be unique for each view so users
who rely on browser tab names/ICO files, screen readers, etc. understand
what page they are currently viewing.

## What was changed: 

1. `coreStart.chrome.docTitle.change` method was called for mentioned
places.

## Screen: 

### Home

<img width="1092" alt="image"
src="https://github.com/user-attachments/assets/49ba0ba3-3d01-4db1-b04c-f5db6a1eb359">

### Connectors

<img width="882" alt="image"
src="https://github.com/user-attachments/assets/a2baa0ae-245a-4f3d-9470-c114cdd4323f">

### Playground

<img width="882" alt="image"
src="https://github.com/user-attachments/assets/d91ac1dc-429b-44ac-91bc-c61fc4945ff6">
This commit is contained in:
Alexey Antonov 2024-10-01 16:04:54 +03:00 committed by GitHub
parent 1ba78275f4
commit a9455e1794
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 7 deletions

View file

@ -47,6 +47,9 @@ export class SearchPlaygroundPlugin
async mount({ element, history }: AppMountParameters) {
const { renderApp } = await import('./application');
const [coreStart, depsStart] = await core.getStartServices();
coreStart.chrome.docTitle.change(PLUGIN_NAME);
const startDeps: AppPluginStartDependencies = {
...depsStart,
history,

View file

@ -72,18 +72,22 @@ export class ServerlessSearchPlugin
},
}),
});
const homeTitle = i18n.translate('xpack.serverlessSearch.app.home.title', {
defaultMessage: 'Home',
});
if (useSearchHomepage) {
core.application.register({
id: 'serverlessHomeRedirect',
title: i18n.translate('xpack.serverlessSearch.app.home.title', {
defaultMessage: 'Home',
}),
title: homeTitle,
appRoute: '/app/elasticsearch',
euiIconType: 'logoElastic',
category: DEFAULT_APP_CATEGORIES.enterpriseSearch,
visibleIn: [],
async mount({}: AppMountParameters) {
const [coreStart] = await core.getStartServices();
coreStart.chrome.docTitle.change(homeTitle);
coreStart.application.navigateToApp('searchHomepage');
return () => {};
},
@ -102,6 +106,7 @@ export class ServerlessSearchPlugin
const { renderApp } = await import('./application/elasticsearch');
const [coreStart, services] = await core.getStartServices();
docLinks.setDocLinks(coreStart.docLinks.links);
coreStart.chrome.docTitle.change(homeTitle);
let user: AuthenticatedUser | undefined;
try {
const response = await coreStart.security.authc.getCurrentUser();
@ -114,11 +119,13 @@ export class ServerlessSearchPlugin
},
});
const connectorsTitle = i18n.translate('xpack.serverlessSearch.app.connectors.title', {
defaultMessage: 'Connectors',
});
core.application.register({
id: 'serverlessConnectors',
title: i18n.translate('xpack.serverlessSearch.app.connectors.title', {
defaultMessage: 'Connectors',
}),
title: connectorsTitle,
appRoute: '/app/connectors',
euiIconType: 'logoElastic',
category: DEFAULT_APP_CATEGORIES.enterpriseSearch,
@ -126,8 +133,9 @@ export class ServerlessSearchPlugin
async mount({ element, history }: AppMountParameters) {
const { renderApp } = await import('./application/connectors');
const [coreStart, services] = await core.getStartServices();
coreStart.chrome.docTitle.change(connectorsTitle);
docLinks.setDocLinks(coreStart.docLinks.links);
return await renderApp(element, coreStart, { history, ...services }, queryClient);
},
});