-
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.
[Search] Homepage Plugin setup (#186224)
## Summary Introducing the `search_homepage` plugin along with integration into `enterprise_search` and `serverless_search` behind a feature flag. This will allow implementing the feature gated behind the feature flag. To test these changes you can enable the feature flag with the Kibana Dev Console using the following command: ``` POST kbn:/internal/kibana/settings/searchHomepage:homepageEnabled {"value": true} ``` You can then disable the feature flag with the following command: ``` DELETE kbn:/internal/kibana/settings/searchHomepage:homepageEnabled ``` ### Checklist - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [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 --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
e2b772a
commit 74c4d3a
Showing
59 changed files
with
1,025 additions
and
56 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
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
28 changes: 28 additions & 0 deletions
28
...prise_search/public/applications/search_homepage/components/layout/page_template.test.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,28 @@ | ||
/* | ||
* 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 from 'react'; | ||
|
||
import { TestHelper } from '../../../test_helpers/test_utils.test_helper'; | ||
|
||
import { SearchHomepagePageTemplate } from './page_template'; | ||
|
||
describe('SearchHomepagePageTemplate', () => { | ||
beforeAll(() => { | ||
TestHelper.prepare(); | ||
}); | ||
|
||
it('renders as expected', async () => { | ||
const { container } = TestHelper.render( | ||
<SearchHomepagePageTemplate> | ||
<div>Test</div> | ||
</SearchHomepagePageTemplate> | ||
); | ||
|
||
expect(container.querySelector('.kbnSolutionNav__title')).toHaveTextContent('Search'); | ||
}); | ||
}); |
37 changes: 37 additions & 0 deletions
37
...enterprise_search/public/applications/search_homepage/components/layout/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,37 @@ | ||
/* | ||
* 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 from 'react'; | ||
|
||
import { SEARCH_PRODUCT_NAME } from '../../../../../common/constants'; | ||
import { SetSearchChrome } from '../../../shared/kibana_chrome'; | ||
import { EnterpriseSearchPageTemplateWrapper, PageTemplateProps } from '../../../shared/layout'; | ||
import { useEnterpriseSearchNav } from '../../../shared/layout'; | ||
import { SendEnterpriseSearchTelemetry } from '../../../shared/telemetry'; | ||
|
||
export const SearchHomepagePageTemplate: React.FC<PageTemplateProps> = ({ | ||
children, | ||
pageChrome, | ||
pageViewTelemetry, | ||
...pageTemplateProps | ||
}) => { | ||
return ( | ||
<EnterpriseSearchPageTemplateWrapper | ||
{...pageTemplateProps} | ||
solutionNav={{ | ||
name: SEARCH_PRODUCT_NAME, | ||
items: useEnterpriseSearchNav(), | ||
}} | ||
setPageChrome={pageChrome && <SetSearchChrome trail={pageChrome} />} | ||
> | ||
{pageViewTelemetry && ( | ||
<SendEnterpriseSearchTelemetry action="viewed" metric={pageViewTelemetry} /> | ||
)} | ||
{children} | ||
</EnterpriseSearchPageTemplateWrapper> | ||
); | ||
}; |
35 changes: 35 additions & 0 deletions
35
...gins/enterprise_search/public/applications/search_homepage/components/search_homepage.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,35 @@ | ||
/* | ||
* 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 from 'react'; | ||
|
||
import { useValues } from 'kea'; | ||
|
||
import { KibanaLogic } from '../../shared/kibana'; | ||
import { SetSearchChrome } from '../../shared/kibana_chrome'; | ||
|
||
import { SearchHomepagePageTemplate } from './layout/page_template'; | ||
|
||
export const SearchHomepagePage = () => { | ||
const { isSearchHomepageEnabled, searchHomepage } = useValues(KibanaLogic); | ||
|
||
if (!isSearchHomepageEnabled || !searchHomepage) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<SearchHomepagePageTemplate | ||
restrictWidth={false} | ||
grow={false} | ||
offset={0} | ||
pageViewTelemetry="searchHomepage" | ||
> | ||
<SetSearchChrome /> | ||
<searchHomepage.SearchHomepage /> | ||
</SearchHomepagePageTemplate> | ||
); | ||
}; |
42 changes: 42 additions & 0 deletions
42
x-pack/plugins/enterprise_search/public/applications/search_homepage/index.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,42 @@ | ||
/* | ||
* 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 from 'react'; | ||
|
||
import { Routes, Route } from '@kbn/shared-ux-router'; | ||
|
||
import { isVersionMismatch } from '../../../common/is_version_mismatch'; | ||
import type { InitialAppData } from '../../../common/types'; | ||
import { VersionMismatchPage } from '../shared/version_mismatch'; | ||
|
||
import { SearchHomepagePage } from './components/search_homepage'; | ||
|
||
export const SearchHomepage: React.FC<InitialAppData> = (props) => { | ||
const { enterpriseSearchVersion, kibanaVersion } = props; | ||
const incompatibleVersions = isVersionMismatch(enterpriseSearchVersion, kibanaVersion); | ||
|
||
const showView = () => { | ||
if (incompatibleVersions) { | ||
return ( | ||
<VersionMismatchPage | ||
enterpriseSearchVersion={enterpriseSearchVersion} | ||
kibanaVersion={kibanaVersion} | ||
/> | ||
); | ||
} | ||
|
||
return <SearchHomepagePage />; | ||
}; | ||
|
||
return ( | ||
<Routes> | ||
<Route exact path="/"> | ||
{showView()} | ||
</Route> | ||
</Routes> | ||
); | ||
}; |
26 changes: 26 additions & 0 deletions
26
x-pack/plugins/enterprise_search/public/applications/search_homepage/jest.config.js
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,26 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
module.exports = { | ||
preset: '@kbn/test', | ||
rootDir: '../../../../../..', | ||
roots: ['<rootDir>/x-pack/plugins/enterprise_search/public/applications/search_homepage'], | ||
collectCoverage: true, | ||
coverageReporters: ['text', 'html'], | ||
collectCoverageFrom: [ | ||
'<rootDir>/x-pack/plugins/enterprise_search/public/applications/**/*.{ts,tsx}', | ||
'!<rootDir>/x-pack/plugins/enterprise_search/public/*.ts', | ||
'!<rootDir>/x-pack/plugins/enterprise_search/server/*.ts', | ||
'!<rootDir>/x-pack/plugins/enterprise_search/public/applications/test_helpers/**/*.{ts,tsx}', | ||
], | ||
coverageDirectory: | ||
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/enterprise_search/public/applications/search_homepage', | ||
modulePathIgnorePatterns: [ | ||
'<rootDir>/x-pack/plugins/enterprise_search/public/applications/app_search/cypress', | ||
'<rootDir>/x-pack/plugins/enterprise_search/public/applications/workplace_search/cypress', | ||
], | ||
}; |
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
18 changes: 18 additions & 0 deletions
18
...ck/plugins/enterprise_search/public/applications/shared/kibana_chrome/breadcrumbs_home.ts
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,18 @@ | ||
/* | ||
* 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 { ENTERPRISE_SEARCH_OVERVIEW_PLUGIN } from '../../../../common/constants'; | ||
|
||
/** | ||
* HACK for base homepage URL, this can be removed and updated to a static | ||
* URL when Search Homepage is no longer feature flagged. | ||
*/ | ||
const breadCrumbHome = { url: ENTERPRISE_SEARCH_OVERVIEW_PLUGIN.URL }; | ||
export const getHomeURL = () => breadCrumbHome.url; | ||
export const setBreadcrumbHomeUrl = (url: string) => { | ||
breadCrumbHome.url = url; | ||
}; |
Oops, something went wrong.