mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Dashboard First] Lens Originating App Breadcrumb (#75470)
Changed lens breadcrumbs to reflect the Originating App
This commit is contained in:
parent
c68363995b
commit
6b3ce3f91e
2 changed files with 54 additions and 1 deletions
|
@ -136,6 +136,7 @@ describe('Lens App', () => {
|
|||
originatingApp: string | undefined;
|
||||
onAppLeave: AppMountParameters['onAppLeave'];
|
||||
history: History;
|
||||
getAppNameFromId?: (appId: string) => string | undefined;
|
||||
}> {
|
||||
return ({
|
||||
navigation: navigationStartMock,
|
||||
|
@ -187,6 +188,7 @@ describe('Lens App', () => {
|
|||
originatingApp: string | undefined;
|
||||
onAppLeave: AppMountParameters['onAppLeave'];
|
||||
history: History;
|
||||
getAppNameFromId?: (appId: string) => string | undefined;
|
||||
}>;
|
||||
}
|
||||
|
||||
|
@ -298,6 +300,38 @@ describe('Lens App', () => {
|
|||
]);
|
||||
});
|
||||
|
||||
it('sets originatingApp breadcrumb when the document title changes', async () => {
|
||||
const defaultArgs = makeDefaultArgs();
|
||||
defaultArgs.originatingApp = 'ultraCoolDashboard';
|
||||
defaultArgs.getAppNameFromId = () => 'The Coolest Container Ever Made';
|
||||
instance = mount(<App {...defaultArgs} />);
|
||||
|
||||
expect(core.chrome.setBreadcrumbs).toHaveBeenCalledWith([
|
||||
{ text: 'The Coolest Container Ever Made', onClick: expect.anything() },
|
||||
{ text: 'Visualize', href: '/testbasepath/app/visualize#/', onClick: expect.anything() },
|
||||
{ text: 'Create' },
|
||||
]);
|
||||
|
||||
(defaultArgs.docStorage.load as jest.Mock).mockResolvedValue({
|
||||
id: '1234',
|
||||
title: 'Daaaaaaadaumching!',
|
||||
expression: 'valid expression',
|
||||
state: {
|
||||
query: 'fake query',
|
||||
datasourceMetaData: { filterableIndexPatterns: [{ id: '1', title: 'saved' }] },
|
||||
},
|
||||
});
|
||||
await act(async () => {
|
||||
instance.setProps({ docId: '1234' });
|
||||
});
|
||||
|
||||
expect(defaultArgs.core.chrome.setBreadcrumbs).toHaveBeenCalledWith([
|
||||
{ text: 'The Coolest Container Ever Made', onClick: expect.anything() },
|
||||
{ text: 'Visualize', href: '/testbasepath/app/visualize#/', onClick: expect.anything() },
|
||||
{ text: 'Daaaaaaadaumching!' },
|
||||
]);
|
||||
});
|
||||
|
||||
describe('persistence', () => {
|
||||
it('does not load a document if there is no document id', () => {
|
||||
const args = makeDefaultArgs();
|
||||
|
|
|
@ -11,6 +11,7 @@ import { i18n } from '@kbn/i18n';
|
|||
import { NavigationPublicPluginStart } from 'src/plugins/navigation/public';
|
||||
import { AppMountContext, AppMountParameters, NotificationsStart } from 'kibana/public';
|
||||
import { History } from 'history';
|
||||
import { EuiBreadcrumb } from '@elastic/eui';
|
||||
import {
|
||||
Query,
|
||||
DataPublicPluginStart,
|
||||
|
@ -203,6 +204,16 @@ export function App({
|
|||
// Sync Kibana breadcrumbs any time the saved document's title changes
|
||||
useEffect(() => {
|
||||
core.chrome.setBreadcrumbs([
|
||||
...(originatingApp && getAppNameFromId
|
||||
? [
|
||||
{
|
||||
onClick: (e) => {
|
||||
core.application.navigateToApp(originatingApp);
|
||||
},
|
||||
text: getAppNameFromId(originatingApp),
|
||||
} as EuiBreadcrumb,
|
||||
]
|
||||
: []),
|
||||
{
|
||||
href: core.http.basePath.prepend(`/app/visualize#/`),
|
||||
onClick: (e) => {
|
||||
|
@ -219,7 +230,15 @@ export function App({
|
|||
: i18n.translate('xpack.lens.breadcrumbsCreate', { defaultMessage: 'Create' }),
|
||||
},
|
||||
]);
|
||||
}, [core.application, core.chrome, core.http.basePath, state.persistedDoc]);
|
||||
}, [
|
||||
core.application,
|
||||
core.chrome,
|
||||
core.http.basePath,
|
||||
state.persistedDoc,
|
||||
originatingApp,
|
||||
redirectTo,
|
||||
getAppNameFromId,
|
||||
]);
|
||||
|
||||
useEffect(
|
||||
() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue