-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…8369) # Backport This will backport the following commits from `main` to `8.x`: - [[Search] Refactor: abstracting classic nav items (#196579)](#196579) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Rodney Norris","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-30T14:39:42Z","message":"[Search] Refactor: abstracting classic nav items (#196579)\n\n## Summary\r\n\r\nMoved the base set of sidenav items from being statically defined in\r\nuseEnterpriseSearchNav to using a function that can be shared with the\r\nplugin. Additionally wrapped this generation in a `useMemo` to improve\r\nperformance.\r\n\r\nThis will support the ability to share the classic navigation items for\r\nSearch to other plugins so that they can render their own UIs without\r\nsharing components with enterprise_search just to have access to the\r\nside nav defined by enterprise_search.\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] [Flaky Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\r\nused on any tests changed\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"c4301d080b9fd595b6cf2313d2053256b0fae89d","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","Team:Search","backport:prev-minor","v8.17.0"],"title":"[Search] Refactor: abstracting classic nav items","number":196579,"url":"https://github.com/elastic/kibana/pull/196579","mergeCommit":{"message":"[Search] Refactor: abstracting classic nav items (#196579)\n\n## Summary\r\n\r\nMoved the base set of sidenav items from being statically defined in\r\nuseEnterpriseSearchNav to using a function that can be shared with the\r\nplugin. Additionally wrapped this generation in a `useMemo` to improve\r\nperformance.\r\n\r\nThis will support the ability to share the classic navigation items for\r\nSearch to other plugins so that they can render their own UIs without\r\nsharing components with enterprise_search just to have access to the\r\nside nav defined by enterprise_search.\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] [Flaky Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\r\nused on any tests changed\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"c4301d080b9fd595b6cf2313d2053256b0fae89d"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/196579","number":196579,"mergeCommit":{"message":"[Search] Refactor: abstracting classic nav items (#196579)\n\n## Summary\r\n\r\nMoved the base set of sidenav items from being statically defined in\r\nuseEnterpriseSearchNav to using a function that can be shared with the\r\nplugin. Additionally wrapped this generation in a `useMemo` to improve\r\nperformance.\r\n\r\nThis will support the ability to share the classic navigation items for\r\nSearch to other plugins so that they can render their own UIs without\r\nsharing components with enterprise_search just to have access to the\r\nside nav defined by enterprise_search.\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios\r\n- [x] [Flaky Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was\r\nused on any tests changed\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"c4301d080b9fd595b6cf2313d2053256b0fae89d"}},{"branch":"8.x","label":"v8.17.0","branchLabelMappingKey":"^v8.17.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Rodney Norris <[email protected]>
- Loading branch information
1 parent
b5edaf6
commit 4ba2199
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.