Skip to content

Commit

Permalink
[Data Explorer] Fix breadcrumb for data explorer (#4856)
Browse files Browse the repository at this point in the history
* add breadcrumb

---------

Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com>
  • Loading branch information
abbyhu2000 authored Aug 30, 2023
1 parent 58ee450 commit 7faa088
Showing 1 changed file with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { i18n } from '@osd/i18n';
import React, { useEffect, useState } from 'react';
import { AppMountParameters } from '../../../../../../core/public';
import { NEW_DISCOVER_APP, PLUGIN_ID } from '../../../../common';
Expand Down Expand Up @@ -32,6 +33,7 @@ export const TopNav = ({ opts }: TopNavProps) => {
application: { navigateToApp },
},
data,
chrome,
} = services;

const topNavLinks = savedSearch ? getTopNavLinks(services, inspectorAdapters, savedSearch) : [];
Expand Down Expand Up @@ -66,6 +68,32 @@ export const TopNav = ({ opts }: TopNavProps) => {
};
}, [data.indexPatterns]);

useEffect(() => {
const pageTitleSuffix = savedSearch?.id && savedSearch.title ? `: ${savedSearch.title}` : '';
chrome.docTitle.change(`Discover${pageTitleSuffix}`);

if (savedSearch?.id) {
chrome.setBreadcrumbs([
{
text: i18n.translate('discover.discoverBreadcrumbTitle', {
defaultMessage: 'Discover',
}),
href: '#/',
},
{ text: savedSearch.title },
]);
} else {
chrome.setBreadcrumbs([
{
text: i18n.translate('discover.discoverBreadcrumbTitle', {
defaultMessage: 'Discover',
}),
href: '#/',
},
]);
}
}, [chrome, savedSearch?.id, savedSearch?.title]);

return (
<TopNavMenu
appName={PLUGIN_ID}
Expand Down

0 comments on commit 7faa088

Please sign in to comment.