forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chrome] Improve breadcrumb extension (elastic#209765)
## Summary fix elastic#208728 This PR improves breadcrumb extension point for adding starring next to a dashboard breadcrumb elastic#200315: - Fix breadcrumb extension didn't render in solution nav - Support multiple extensions (search sessions are deprecated and need to be enabled with kibana.yml flag, but we still need to support both UI elements) - Improve DX to unmount the extension To test: - Add `data.search.sessions.enabled: true` and see that search session UI appears in solution nav. - To test multiple, add more extensions by using `chrome.setBreadcrumbsAppendExtension`, e.g. in `src/platform/plugins/shared/data/public/search/search_service.ts` . This actually gonna be used in elastic#200315 ![Screenshot 2025-02-05 at 14 41 21](https://github.com/user-attachments/assets/f4bece3e-6b09-4afb-94b5-291a7387118c)
- Loading branch information
Showing
14 changed files
with
189 additions
and
75 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
53 changes: 53 additions & 0 deletions
53
src/core/packages/chrome/browser-internal/src/ui/header/breadcrumbs_with_extensions.tsx
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,53 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import React, { PropsWithChildren } from 'react'; | ||
import { Observable } from 'rxjs'; | ||
import type { ChromeBreadcrumbsAppendExtension } from '@kbn/core-chrome-browser'; | ||
import useObservable from 'react-use/lib/useObservable'; | ||
import { EuiFlexGroup } from '@elastic/eui'; | ||
import classnames from 'classnames'; | ||
import { HeaderExtension } from './header_extension'; | ||
|
||
export interface Props { | ||
breadcrumbsAppendExtensions$: Observable<ChromeBreadcrumbsAppendExtension[]>; | ||
} | ||
|
||
export const BreadcrumbsWithExtensionsWrapper = ({ | ||
breadcrumbsAppendExtensions$, | ||
children, | ||
}: PropsWithChildren<Props>) => { | ||
const breadcrumbsAppendExtensions = useObservable(breadcrumbsAppendExtensions$, []); | ||
|
||
return breadcrumbsAppendExtensions.length === 0 ? ( | ||
<>{children}</> | ||
) : ( | ||
<EuiFlexGroup | ||
responsive={false} | ||
wrap={false} | ||
alignItems={'center'} | ||
className={'header__breadcrumbsWithExtensionContainer'} | ||
gutterSize={'none'} | ||
> | ||
{children} | ||
{breadcrumbsAppendExtensions.map((breadcrumbsAppendExtension, index) => { | ||
const isLast = breadcrumbsAppendExtensions.length - 1 === index; | ||
return ( | ||
<HeaderExtension | ||
key={index} | ||
extension={breadcrumbsAppendExtension.content} | ||
containerClassName={classnames({ | ||
'header__breadcrumbsAppendExtension--last': isLast, | ||
})} | ||
/> | ||
); | ||
})} | ||
</EuiFlexGroup> | ||
); | ||
}; |
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
Oops, something went wrong.