Skip to content
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] Introduce search navigation plugin #200314

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,7 @@ x-pack/plugins/search_indices @elastic/search-kibana
x-pack/plugins/search_inference_endpoints @elastic/search-kibana
x-pack/plugins/search_notebooks @elastic/search-kibana
x-pack/plugins/search_playground @elastic/search-kibana
x-pack/plugins/search_solution/search_navigation @elastic/search-kibana
x-pack/plugins/searchprofiler @elastic/kibana-management
x-pack/plugins/security @elastic/kibana-security
x-pack/plugins/security_solution @elastic/security-solution
Expand Down
4 changes: 4 additions & 0 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,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 @@ -797,6 +797,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 @@ -142,6 +142,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 @@ -1552,6 +1552,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"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we name this search instead of search_solution and keep name consistency with the one for packages? x-pack/packages/search

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so I was using observability_solution & observability_solution as the examples for this and search seemed too generic.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats fair. security is the other one. I dont mind either but would be good we keep consistency and rename the other folder in packages (whilst theres only one package)

"@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_notebooks",
TattdCodeMonkey marked this conversation as resolved.
Show resolved Hide resolved
"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 { GenerateNavLinkFromDeepLinkParameters, GenerateNavLinkParameters } from '../types';
TattdCodeMonkey marked this conversation as resolved.
Show resolved Hide resolved

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}',
],
};
19 changes: 19 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,19 @@
{
"type": "plugin",
"id": "@kbn/search-navigation",
"owner": "@elastic/search-kibana",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to define a group and visibility for the new plugin.
If it's only used from Search solution I suggest

  "group": "search",
  "visibility": "private",

Is this a follow-up of this discussion?

Copy link
Contributor Author

@TattdCodeMonkey TattdCodeMonkey Nov 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a follow-up of this discussion?

Not exactly, this is more architectural work to make it easier for Search team to develop plugins with UIs that are shared between stack and Serverless Elasticsearch.

But this PR does enable us to remove search playground from enterprise_search plugin. Once this merges I will have that PR up which will also introduce a KibanaFeature for searchPlayground that allows it to be disabled independently of the enterprise_search plugin.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gsoldevila I added the group & visibility keys.

"plugin": {
"id": "searchNavigation",
"server": false,
"browser": true,
"configPath": [
"xpack",
"searchNavigation"
],
"requiredPlugins": [],
"optionalPlugins": [
"serverless"
],
"requiredBundles": []
}
}
Loading