-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Search] Refactor: abstracting classic nav items #196579
Changes from all commits
47a2808
9c410a3
7d37362
305e4c4
4055acf
8d6fa57
8f375a1
cec7693
e269ff0
3dc20ba
19c8e47
e3b1f70
e05d61a
57f52bc
2876683
e909efe
fc0a455
aa5e396
e8d6344
17b3d9d
da27ded
08634d2
3b462d7
f31ca7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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> | ||
); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,7 @@ export const ElasticsearchGuide = () => { | |
}, []); | ||
|
||
return ( | ||
<EnterpriseSearchElasticsearchPageTemplate> | ||
<EnterpriseSearchElasticsearchPageTemplate pageChrome={[]}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this ensure the breadcrumbs and title component is rendered. |
||
{isFlyoutOpen && <CreateApiKeyFlyout onClose={() => setIsFlyoutOpen(false)} />} | ||
<EuiTitle size="l" data-test-subj="elasticsearchGuide"> | ||
<h1> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,13 +19,14 @@ export const EnterpriseSearchElasticsearchPageTemplate: React.FC<PageTemplatePro | |
pageViewTelemetry, | ||
...pageTemplateProps | ||
}) => { | ||
const navItems = useEnterpriseSearchNav(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may not be strictly necessary but |
||
return ( | ||
<EnterpriseSearchPageTemplateWrapper | ||
{...pageTemplateProps} | ||
restrictWidth | ||
solutionNav={{ | ||
name: SEARCH_PRODUCT_NAME, | ||
items: useEnterpriseSearchNav(), | ||
items: navItems, | ||
}} | ||
setPageChrome={pageChrome && <SetElasticsearchChrome trail={pageChrome} />} | ||
> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,8 @@ import { | |
VECTOR_SEARCH_PLUGIN, | ||
WORKPLACE_SEARCH_PLUGIN, | ||
SEMANTIC_SEARCH_PLUGIN, | ||
APPLICATIONS_PLUGIN, | ||
GETTING_STARTED_TITLE, | ||
} from '../../../../common/constants'; | ||
|
||
import { stripLeadingSlash } from '../../../../common/strip_slashes'; | ||
|
@@ -126,7 +128,11 @@ export const useEnterpriseSearchBreadcrumbs = (breadcrumbs: Breadcrumbs = []) => | |
]); | ||
|
||
export const useAnalyticsBreadcrumbs = (breadcrumbs: Breadcrumbs = []) => | ||
useSearchBreadcrumbs([{ text: ANALYTICS_PLUGIN.NAME, path: '/' }, ...breadcrumbs]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the changes in this file are essentially bug fixes I found when writing FTRs for the classic nav. Our breadcrumbs and page titles were not consistent at all. |
||
useSearchBreadcrumbs([ | ||
{ text: APPLICATIONS_PLUGIN.NAV_TITLE }, | ||
{ text: ANALYTICS_PLUGIN.NAME, path: '/' }, | ||
...breadcrumbs, | ||
]); | ||
|
||
export const useElasticsearchBreadcrumbs = (breadcrumbs: Breadcrumbs = []) => | ||
useSearchBreadcrumbs([ | ||
|
@@ -161,13 +167,25 @@ export const useSearchExperiencesBreadcrumbs = (breadcrumbs: Breadcrumbs = []) = | |
useSearchBreadcrumbs([{ text: SEARCH_EXPERIENCES_PLUGIN.NAV_TITLE, path: '/' }, ...breadcrumbs]); | ||
|
||
export const useEnterpriseSearchApplicationsBreadcrumbs = (breadcrumbs: Breadcrumbs = []) => | ||
useSearchBreadcrumbs(breadcrumbs); | ||
useSearchBreadcrumbs([{ text: APPLICATIONS_PLUGIN.NAV_TITLE }, ...breadcrumbs]); | ||
|
||
export const useAiSearchBreadcrumbs = (breadcrumbs: Breadcrumbs = []) => | ||
useSearchBreadcrumbs([{ text: AI_SEARCH_PLUGIN.NAME, path: '/' }, ...breadcrumbs]); | ||
useSearchBreadcrumbs([ | ||
{ text: GETTING_STARTED_TITLE }, | ||
{ text: AI_SEARCH_PLUGIN.NAME, path: '/' }, | ||
...breadcrumbs, | ||
]); | ||
|
||
export const useVectorSearchBreadcrumbs = (breadcrumbs: Breadcrumbs = []) => | ||
useSearchBreadcrumbs([{ text: VECTOR_SEARCH_PLUGIN.NAV_TITLE, path: '/' }, ...breadcrumbs]); | ||
useSearchBreadcrumbs([ | ||
{ text: GETTING_STARTED_TITLE }, | ||
{ text: VECTOR_SEARCH_PLUGIN.NAV_TITLE, path: '/' }, | ||
...breadcrumbs, | ||
]); | ||
|
||
export const useSemanticSearchBreadcrumbs = (breadcrumbs: Breadcrumbs = []) => | ||
useSearchBreadcrumbs([{ text: SEMANTIC_SEARCH_PLUGIN.NAME, path: '/' }, ...breadcrumbs]); | ||
useSearchBreadcrumbs([ | ||
{ text: GETTING_STARTED_TITLE }, | ||
{ text: SEMANTIC_SEARCH_PLUGIN.NAME, path: '/' }, | ||
...breadcrumbs, | ||
]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
adding this so that playground and search applications can have different breadcrumbs.