Skip to content

Commit

Permalink
[Search] Introduce search navigation plugin (#200314)
Browse files Browse the repository at this point in the history
(cherry picked from commit a84122c)

# Conflicts:
#	.github/CODEOWNERS
  • Loading branch information
TattdCodeMonkey committed Nov 25, 2024
1 parent 1feb364 commit c85bf81
Show file tree
Hide file tree
Showing 24 changed files with 628 additions and 23 deletions.
4 changes: 4 additions & 0 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,10 @@ It uses Chromium and Puppeteer underneath to run the browser in headless mode.
|The Inference Endpoints is a tool used to manage inference endpoints
|{kib-repo}blob/{branch}/x-pack/plugins/search_solution/search_navigation/README.mdx[searchNavigation]
|The Search Navigation plugin is used to handle navigation for search solution plugins across both stack and serverless.
|{kib-repo}blob/{branch}/x-pack/plugins/search_notebooks/README.mdx[searchNotebooks]
|This plugin contains endpoints and components for rendering search python notebooks in the persistent dev console.
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@
"@kbn/search-index-documents": "link:packages/kbn-search-index-documents",
"@kbn/search-indices": "link:x-pack/plugins/search_indices",
"@kbn/search-inference-endpoints": "link:x-pack/plugins/search_inference_endpoints",
"@kbn/search-navigation": "link:x-pack/plugins/search_solution/search_navigation",
"@kbn/search-notebooks": "link:x-pack/plugins/search_notebooks",
"@kbn/search-playground": "link:x-pack/plugins/search_playground",
"@kbn/search-response-warnings": "link:packages/kbn-search-response-warnings",
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ pageLoadAssetSize:
searchHomepage: 19831
searchIndices: 20519
searchInferenceEndpoints: 20470
searchNavigation: 19233
searchNotebooks: 18942
searchPlayground: 19325
searchprofiler: 67080
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -1562,6 +1562,8 @@
"@kbn/search-indices/*": ["x-pack/plugins/search_indices/*"],
"@kbn/search-inference-endpoints": ["x-pack/plugins/search_inference_endpoints"],
"@kbn/search-inference-endpoints/*": ["x-pack/plugins/search_inference_endpoints/*"],
"@kbn/search-navigation": ["x-pack/plugins/search_solution/search_navigation"],
"@kbn/search-navigation/*": ["x-pack/plugins/search_solution/search_navigation/*"],
"@kbn/search-notebooks": ["x-pack/plugins/search_notebooks"],
"@kbn/search-notebooks/*": ["x-pack/plugins/search_notebooks/*"],
"@kbn/search-playground": ["x-pack/plugins/search_playground"],
Expand Down
1 change: 1 addition & 0 deletions x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
"xpack.searchSharedUI": "packages/search/shared_ui",
"xpack.searchHomepage": "plugins/search_homepage",
"xpack.searchIndices": "plugins/search_indices",
"xpack.searchNavigation": "plugins/search_solution/search_navigation",
"xpack.searchNotebooks": "plugins/search_notebooks",
"xpack.searchPlayground": "plugins/search_playground",
"xpack.searchInferenceEndpoints": "plugins/search_inference_endpoints",
Expand Down
5 changes: 3 additions & 2 deletions x-pack/plugins/enterprise_search/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"logsShared",
"logsDataAccess",
"esUiShared",
"navigation"
"navigation",
],
"optionalPlugins": [
"customIntegrations",
Expand All @@ -34,8 +34,9 @@
"guidedOnboarding",
"console",
"searchConnectors",
"searchPlayground",
"searchInferenceEndpoints",
"searchNavigation",
"searchPlayground",
"embeddable",
"discover",
"charts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ import {
SEARCH_AI_SEARCH,
} from '@kbn/deeplinks-search';
import { i18n } from '@kbn/i18n';
import type { ClassicNavItem } from '@kbn/search-navigation/public';

import { GETTING_STARTED_TITLE } from '../../../../common/constants';

import { ClassicNavItem, BuildClassicNavParameters } from '../types';
import { BuildClassicNavParameters } from '../types';

export const buildBaseClassicNavItems = ({
productAccess,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
import { mockKibanaValues } from '../../__mocks__/kea_logic';

import type { ChromeNavLink } from '@kbn/core-chrome-browser';
import type { ClassicNavItem } from '@kbn/search-navigation/public';

import '../../__mocks__/react_router';

jest.mock('../react_router_helpers/link_events', () => ({
letBrowserHandleEvent: jest.fn(),
}));

import { ClassicNavItem } from '../types';

import { generateSideNavItems } from './classic_nav_helpers';

describe('generateSideNavItems', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@
*/

import { ChromeNavLink, EuiSideNavItemTypeEnhanced } from '@kbn/core-chrome-browser';
import type { ClassicNavItem } from '@kbn/search-navigation/public';

import {
ClassicNavItem,
GenerateNavLinkFromDeepLinkParameters,
GenerateNavLinkParameters,
} from '../types';
import type { GenerateNavLinkFromDeepLinkParameters, GenerateNavLinkParameters } from '../types';

import { generateNavLink } from './nav_link_helpers';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* 2.0.
*/

import type { ReactNode } from 'react';

import type { AppDeepLinkId, EuiSideNavItemTypeEnhanced } from '@kbn/core-chrome-browser';

import { APP_SEARCH_PLUGIN, WORKPLACE_SEARCH_PLUGIN } from '../../../common/constants';
Expand Down Expand Up @@ -87,12 +85,3 @@ export interface GenerateNavLinkFromDeepLinkParameters {
export interface BuildClassicNavParameters {
productAccess: ProductAccess;
}

export interface ClassicNavItem {
'data-test-subj'?: string;
deepLink?: GenerateNavLinkFromDeepLinkParameters;
iconToString?: string;
id: string;
items?: ClassicNavItem[];
name?: ReactNode;
}
25 changes: 24 additions & 1 deletion x-pack/plugins/enterprise_search/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import type { NavigationPublicPluginStart } from '@kbn/navigation-plugin/public'
import { ELASTICSEARCH_URL_PLACEHOLDER } from '@kbn/search-api-panels/constants';
import { SearchConnectorsPluginStart } from '@kbn/search-connectors-plugin/public';
import { SearchInferenceEndpointsPluginStart } from '@kbn/search-inference-endpoints/public';
import type { SearchNavigationPluginStart } from '@kbn/search-navigation/public';
import { SearchPlaygroundPluginStart } from '@kbn/search-playground/public';
import { SecurityPluginSetup, SecurityPluginStart } from '@kbn/security-plugin/public';
import { SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/public';
Expand All @@ -55,7 +56,7 @@ import {
SEARCH_RELEVANCE_PLUGIN,
} from '../common/constants';
import { registerLocators } from '../common/locators';
import { ClientConfigType, InitialAppData } from '../common/types';
import { ClientConfigType, InitialAppData, ProductAccess } from '../common/types';
import { hasEnterpriseLicense } from '../common/utils/licensing';

import { ENGINES_PATH } from './applications/app_search/routes';
Expand Down Expand Up @@ -99,6 +100,7 @@ export interface PluginsStart {
navigation: NavigationPublicPluginStart;
searchConnectors?: SearchConnectorsPluginStart;
searchInferenceEndpoints?: SearchInferenceEndpointsPluginStart;
searchNavigation?: SearchNavigationPluginStart;
searchPlayground?: SearchPlaygroundPluginStart;
security?: SecurityPluginStart;
share?: SharePluginStart;
Expand Down Expand Up @@ -618,6 +620,27 @@ export class EnterpriseSearchPlugin implements Plugin {
})
);
});
if (plugins.searchNavigation !== undefined) {
// while we have ent-search apps in the side nav, we need to provide access
// to the base set of classic side nav items to the search-navigation plugin.
import('./applications/shared/layout/base_nav').then(({ buildBaseClassicNavItems }) => {
plugins.searchNavigation?.setGetBaseClassicNavItems(() => {
const productAccess: ProductAccess = this.data?.access ?? {
hasAppSearchAccess: false,
hasWorkplaceSearchAccess: false,
};

return buildBaseClassicNavItems({ productAccess });
});
});

// This is needed so that we can fetch product access for plugins
// that need to share the classic nav. This can be removed when we
// remove product access and ent-search apps.
plugins.searchNavigation.registerOnAppMountHandler(async () => {
return this.getInitialData(core.http);
});
}

plugins.licensing?.license$.subscribe((license) => {
if (hasEnterpriseLicense(license)) {
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/enterprise_search/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"@kbn/security-plugin-types-common",
"@kbn/core-security-server",
"@kbn/core-security-server-mocks",
"@kbn/unsaved-changes-prompt"
"@kbn/unsaved-changes-prompt",
"@kbn/search-navigation",
]
}
3 changes: 3 additions & 0 deletions x-pack/plugins/search_solution/search_navigation/README.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Search Navigation

The Search Navigation plugin is used to handle navigation for search solution plugins across both stack and serverless.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* 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.
*/

export const PLUGIN_ID = 'searchNavigation';
export const PLUGIN_NAME = 'searchNavigation';
18 changes: 18 additions & 0 deletions x-pack/plugins/search_solution/search_navigation/jest.config.js
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.
*/

module.exports = {
preset: '@kbn/test',
rootDir: '../../../..',
roots: ['<rootDir>/x-pack/plugins/search_solution/search_navigation'],
coverageDirectory:
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/search_solution/search_navigation',
coverageReporters: ['text', 'html'],
collectCoverageFrom: [
'<rootDir>/x-pack/plugins/search_solution/search_navigation/{public,server}/**/*.{ts,tsx}',
],
};
21 changes: 21 additions & 0 deletions x-pack/plugins/search_solution/search_navigation/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": "plugin",
"id": "@kbn/search-navigation",
"owner": "@elastic/search-kibana",
"group": "search",
"visibility": "private",
"plugin": {
"id": "searchNavigation",
"server": false,
"browser": true,
"configPath": [
"xpack",
"searchNavigation"
],
"requiredPlugins": [],
"optionalPlugins": [
"serverless"
],
"requiredBundles": []
}
}
Loading

0 comments on commit c85bf81

Please sign in to comment.