Skip to content

Commit

Permalink
[Search] Homepage Plugin setup (#186224)
Browse files Browse the repository at this point in the history
## 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
TattdCodeMonkey and kibanamachine authored Jun 19, 2024
1 parent e2b772a commit 74c4d3a
Show file tree
Hide file tree
Showing 59 changed files with 1,025 additions and 56 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,7 @@ packages/kbn-search-connectors @elastic/search-kibana
x-pack/plugins/search_connectors @elastic/search-kibana
packages/kbn-search-errors @elastic/kibana-data-discovery
examples/search_examples @elastic/kibana-data-discovery
x-pack/plugins/search_homepage @elastic/search-kibana
packages/kbn-search-index-documents @elastic/search-kibana
x-pack/plugins/search_inference_endpoints @elastic/search-kibana
x-pack/plugins/search_notebooks @elastic/search-kibana
Expand Down
3 changes: 3 additions & 0 deletions config/serverless.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ xpack.searchInferenceEndpoints.ui.enabled: false

# Search Notebooks
xpack.search.notebooks.catalog.url: https://elastic-enterprise-search.s3.us-east-2.amazonaws.com/serverless/catalog.json

# Search Homepage
xpack.search.homepage.ui.enabled: true
4 changes: 4 additions & 0 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,10 @@ It uses Chromium and Puppeteer underneath to run the browser in headless mode.
|This plugin contains common assets and endpoints for the use of connectors in Kibana. Primarily used by the enterprise_search and serverless_search plugins.
|{kib-repo}blob/{branch}/x-pack/plugins/search_homepage/README.mdx[searchHomepage]
|The Search Homepage is a shared homepage for elasticsearch users.
|{kib-repo}blob/{branch}/x-pack/plugins/search_inference_endpoints/README.md[searchInferenceEndpoints]
|The Inference Endpoints is a tool used to manage inference endpoints
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@
"@kbn/search-connectors-plugin": "link:x-pack/plugins/search_connectors",
"@kbn/search-errors": "link:packages/kbn-search-errors",
"@kbn/search-examples-plugin": "link:examples/search_examples",
"@kbn/search-homepage": "link:x-pack/plugins/search_homepage",
"@kbn/search-index-documents": "link:packages/kbn-search-index-documents",
"@kbn/search-inference-endpoints": "link:x-pack/plugins/search_inference_endpoints",
"@kbn/search-notebooks": "link:x-pack/plugins/search_notebooks",
Expand Down
1 change: 1 addition & 0 deletions packages/deeplinks/search/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ export const SERVERLESS_ES_APP_ID = 'serverlessElasticsearch';
export const SERVERLESS_ES_CONNECTORS_ID = 'serverlessConnectors';
export const SERVERLESS_ES_SEARCH_PLAYGROUND_ID = 'searchPlayground';
export const SERVERLESS_ES_SEARCH_INFERENCE_ENDPOINTS_ID = 'searchInferenceEndpoints';
export const SEARCH_HOMEPAGE = 'searchHomepage';
3 changes: 3 additions & 0 deletions packages/deeplinks/search/deep_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
ENTERPRISE_SEARCH_WORKPLACESEARCH_APP_ID,
SERVERLESS_ES_SEARCH_PLAYGROUND_ID,
SERVERLESS_ES_SEARCH_INFERENCE_ENDPOINTS_ID,
SEARCH_HOMEPAGE,
} from './constants';

export type EnterpriseSearchApp = typeof ENTERPRISE_SEARCH_APP_ID;
Expand All @@ -29,6 +30,7 @@ export type ServerlessSearchApp = typeof SERVERLESS_ES_APP_ID;
export type ConnectorsId = typeof SERVERLESS_ES_CONNECTORS_ID;
export type SearchPlaygroundId = typeof SERVERLESS_ES_SEARCH_PLAYGROUND_ID;
export type SearchInferenceEndpointsId = typeof SERVERLESS_ES_SEARCH_INFERENCE_ENDPOINTS_ID;
export type SearchHomepage = typeof SEARCH_HOMEPAGE;

export type ContentLinkId = 'searchIndices' | 'connectors' | 'webCrawlers';

Expand All @@ -47,6 +49,7 @@ export type DeepLinkId =
| ConnectorsId
| SearchPlaygroundId
| SearchInferenceEndpointsId
| SearchHomepage
| `${EnterpriseSearchContentApp}:${ContentLinkId}`
| `${EnterpriseSearchApplicationsApp}:${ApplicationsLinkId}`
| `${EnterpriseSearchAppsearchApp}:${AppsearchLinkId}`;
1 change: 1 addition & 0 deletions packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ pageLoadAssetSize:
screenshotMode: 17856
screenshotting: 22870
searchConnectors: 30000
searchHomepage: 19831
searchInferenceEndpoints: 20470
searchNotebooks: 18942
searchPlayground: 19325
Expand Down
3 changes: 2 additions & 1 deletion test/plugin_functional/test_suites/core_plugins/rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,9 @@ export default function ({ getService }: PluginFunctionalProviderContext) {
// 'xpack.reporting.poll.jobsRefresh.intervalErrorMultiplier (number)',
'xpack.rollup.ui.enabled (boolean)',
'xpack.saved_object_tagging.cache_refresh_interval (duration)',
'xpack.searchPlayground.ui.enabled (boolean)',
'xpack.search.homepage.ui.enabled (boolean)',
'xpack.searchInferenceEndpoints.ui.enabled (boolean)',
'xpack.searchPlayground.ui.enabled (boolean)',
'xpack.security.loginAssistanceMessage (string)',
'xpack.security.sameSiteCookies (alternatives)',
'xpack.security.showInsecureClusterWarning (boolean)',
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -1426,6 +1426,8 @@
"@kbn/search-errors/*": ["packages/kbn-search-errors/*"],
"@kbn/search-examples-plugin": ["examples/search_examples"],
"@kbn/search-examples-plugin/*": ["examples/search_examples/*"],
"@kbn/search-homepage": ["x-pack/plugins/search_homepage"],
"@kbn/search-homepage/*": ["x-pack/plugins/search_homepage/*"],
"@kbn/search-index-documents": ["packages/kbn-search-index-documents"],
"@kbn/search-index-documents/*": ["packages/kbn-search-index-documents/*"],
"@kbn/search-inference-endpoints": ["x-pack/plugins/search_inference_endpoints"],
Expand Down
1 change: 1 addition & 0 deletions x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
"xpack.rollupJobs": ["plugins/rollup"],
"xpack.runtimeFields": "plugins/runtime_fields",
"xpack.screenshotting": "plugins/screenshotting",
"xpack.searchHomepage": "plugins/search_homepage",
"xpack.searchNotebooks": "plugins/search_notebooks",
"xpack.searchPlayground": "plugins/search_playground",
"xpack.searchInferenceEndpoints": "plugins/search_inference_endpoints",
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/enterprise_search/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"guidedOnboarding",
"console",
"searchConnectors",
"searchHomepage",
"searchPlayground",
"searchInferenceEndpoints",
"embeddable",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const mockKibanaValues = {
history: mockHistory,
indexMappingComponent: null,
isCloud: false,
isSearchHomepageEnabled: false,
isSidebarEnabled: true,
lens: {
EmbeddableComponent: jest.fn(),
Expand All @@ -64,6 +65,7 @@ export const mockKibanaValues = {
hasWebCrawler: true,
},
renderHeaderActions: jest.fn(),
searchHomepage: null,
searchInferenceEndpoints: null,
searchPlayground: searchPlaygroundMock.createStart(),
security: securityMock.createStart(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export const renderApp = (
guidedOnboarding,
history,
indexMappingComponent,
isSearchHomepageEnabled: plugins.searchHomepage?.isHomepageFeatureEnabled() ?? false,
isSidebarEnabled,
lens,
ml,
Expand All @@ -127,6 +128,7 @@ export const renderApp = (
params.setHeaderActionMenu(
HeaderActions ? renderHeaderActions.bind(null, HeaderActions, store, params) : undefined
),
searchHomepage: plugins.searchHomepage,
searchPlayground: plugins.searchPlayground,
searchInferenceEndpoints: plugins.searchInferenceEndpoints,
security,
Expand Down
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');
});
});
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>
);
};
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>
);
};
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>
);
};
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',
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { LensPublicStart } from '@kbn/lens-plugin/public';
import { MlPluginStart } from '@kbn/ml-plugin/public';
import { ELASTICSEARCH_URL_PLACEHOLDER } from '@kbn/search-api-panels/constants';
import { ConnectorDefinition } from '@kbn/search-connectors-plugin/public';
import type { SearchHomepagePluginStart } from '@kbn/search-homepage/public';
import { SearchInferenceEndpointsPluginStart } from '@kbn/search-inference-endpoints/public';
import { SearchPlaygroundPluginStart } from '@kbn/search-playground/public';
import { AuthenticatedUser, SecurityPluginStart } from '@kbn/security-plugin/public';
Expand Down Expand Up @@ -58,13 +59,15 @@ export interface KibanaLogicProps {
guidedOnboarding?: GuidedOnboardingPluginStart;
history: ScopedHistory;
indexMappingComponent?: React.FC<IndexMappingProps>;
isSearchHomepageEnabled: boolean;
isSidebarEnabled: boolean;
lens?: LensPublicStart;
ml?: MlPluginStart;
navigateToUrl: RequiredFieldsOnly<ApplicationStart['navigateToUrl']>;
productAccess: ProductAccess;
productFeatures: ProductFeatures;
renderHeaderActions(HeaderActions?: FC): void;
searchHomepage?: SearchHomepagePluginStart;
searchPlayground?: SearchPlaygroundPluginStart;
searchInferenceEndpoints?: SearchInferenceEndpointsPluginStart;
security?: SecurityPluginStart;
Expand All @@ -91,13 +94,15 @@ export interface KibanaValues {
history: ScopedHistory;
indexMappingComponent: React.FC<IndexMappingProps> | null;
isCloud: boolean;
isSearchHomepageEnabled: boolean;
isSidebarEnabled: boolean;
lens: LensPublicStart | null;
ml: MlPluginStart | null;
navigateToUrl(path: string, options?: CreateHrefOptions): Promise<void>;
productAccess: ProductAccess;
productFeatures: ProductFeatures;
renderHeaderActions(HeaderActions?: FC): void;
searchHomepage: SearchHomepagePluginStart | null;
searchPlayground: SearchPlaygroundPluginStart | null;
searchInferenceEndpoints: SearchInferenceEndpointsPluginStart | null;
security: SecurityPluginStart | null;
Expand Down Expand Up @@ -129,6 +134,7 @@ export const KibanaLogic = kea<MakeLogicType<KibanaValues>>({
guidedOnboarding: [props.guidedOnboarding || null, {}],
history: [props.history, {}],
indexMappingComponent: [props.indexMappingComponent || null, {}],
isSearchHomepageEnabled: [props.isSearchHomepageEnabled, {}],
isSidebarEnabled: [props.isSidebarEnabled, {}],
lens: [props.lens || null, {}],
ml: [props.ml || null, {}],
Expand All @@ -143,6 +149,7 @@ export const KibanaLogic = kea<MakeLogicType<KibanaValues>>({
productAccess: [props.productAccess, {}],
productFeatures: [props.productFeatures, {}],
renderHeaderActions: [props.renderHeaderActions, {}],
searchHomepage: [props.searchHomepage || null, {}],
searchPlayground: [props.searchPlayground || null, {}],
searchInferenceEndpoints: [props.searchInferenceEndpoints || null, {}],
security: [props.security || null, {}],
Expand Down
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;
};
Loading

0 comments on commit 74c4d3a

Please sign in to comment.