-
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.
[Search] Refactor: abstracting classic nav items (#196579)
## Summary Moved the base set of sidenav items from being statically defined in useEnterpriseSearchNav to using a function that can be shared with the plugin. Additionally wrapped this generation in a `useMemo` to improve performance. This will support the ability to share the classic navigation items for Search to other plugins so that they can render their own UIs without sharing components with enterprise_search just to have access to the side nav defined by enterprise_search. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed --------- Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
b9a5d6a
commit c4301d0
Showing
37 changed files
with
1,180 additions
and
358 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
71 changes: 71 additions & 0 deletions
71
...nterprise_search/public/applications/applications/components/playground/page_template.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,71 @@ | ||
/* | ||
* 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; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React, { useLayoutEffect } from 'react'; | ||
|
||
import { useValues } from 'kea'; | ||
|
||
import useObservable from 'react-use/lib/useObservable'; | ||
|
||
import { SEARCH_PRODUCT_NAME } from '../../../../../common/constants'; | ||
import { KibanaLogic } from '../../../shared/kibana'; | ||
import { SetSearchPlaygroundChrome } from '../../../shared/kibana_chrome/set_chrome'; | ||
import { EnterpriseSearchPageTemplateWrapper, PageTemplateProps } from '../../../shared/layout'; | ||
import { useEnterpriseSearchNav } from '../../../shared/layout'; | ||
import { SendEnterpriseSearchTelemetry } from '../../../shared/telemetry'; | ||
|
||
import { PlaygroundHeaderDocsAction } from './header_docs_action'; | ||
|
||
export type SearchPlaygroundPageTemplateProps = Omit< | ||
PageTemplateProps, | ||
'useEndpointHeaderActions' | ||
> & { | ||
hasSchemaConflicts?: boolean; | ||
restrictWidth?: boolean; | ||
searchApplicationName?: string; | ||
}; | ||
|
||
export const SearchPlaygroundPageTemplate: React.FC<SearchPlaygroundPageTemplateProps> = ({ | ||
children, | ||
pageChrome, | ||
pageViewTelemetry, | ||
searchApplicationName, | ||
hasSchemaConflicts, | ||
restrictWidth = true, | ||
...pageTemplateProps | ||
}) => { | ||
const navItems = useEnterpriseSearchNav(); | ||
|
||
const { renderHeaderActions, getChromeStyle$ } = useValues(KibanaLogic); | ||
const chromeStyle = useObservable(getChromeStyle$(), 'classic'); | ||
|
||
useLayoutEffect(() => { | ||
renderHeaderActions(PlaygroundHeaderDocsAction); | ||
|
||
return () => { | ||
renderHeaderActions(); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<EnterpriseSearchPageTemplateWrapper | ||
{...pageTemplateProps} | ||
solutionNav={{ | ||
items: chromeStyle === 'classic' ? navItems : undefined, | ||
name: SEARCH_PRODUCT_NAME, | ||
}} | ||
restrictWidth={restrictWidth} | ||
setPageChrome={pageChrome && <SetSearchPlaygroundChrome trail={pageChrome} />} | ||
useEndpointHeaderActions={false} | ||
> | ||
{pageViewTelemetry && ( | ||
<SendEnterpriseSearchTelemetry action="viewed" metric={pageViewTelemetry} /> | ||
)} | ||
{children} | ||
</EnterpriseSearchPageTemplateWrapper> | ||
); | ||
}; |
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
Oops, something went wrong.