-
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.
[Synonyms UI] Synonyms UI base plugin (#203284)
## Summary Creates a plugin for Synonyms UI implementation. It is hidden under the UI flag and config option which is off by default. ``` POST kbn:/internal/kibana/settings/searchSynonyms:synonymsEnabled {"value": true} ``` Serverless Search: <img width="379" alt="Screenshot 2024-12-17 at 13 18 02" src="https://github.com/user-attachments/assets/8c2cb6f0-ce2a-4be6-8605-4f994adeefd7" /> Stack Search <img width="293" alt="Screenshot 2024-12-17 at 13 21 43" src="https://github.com/user-attachments/assets/0d61de0e-2cd3-46a6-990f-1f1a70843324" /> ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [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) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [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 - [x] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: kibanamachine <[email protected]> (cherry picked from commit e542fd2) # Conflicts: # .github/CODEOWNERS
- Loading branch information
Showing
32 changed files
with
2,809 additions
and
1,048 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Search Synonyms | ||
|
||
A plugin to manage synonyms in Elasticsearch through Synonyms APIs through Kibana. |
15 changes: 15 additions & 0 deletions
15
x-pack/solutions/search/plugins/search_synonyms/common/index.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,15 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
|
||
export const PLUGIN_ID = 'searchSynonyms'; | ||
export const PLUGIN_NAME = 'Synonyms'; | ||
|
||
export const PLUGIN_TITLE = i18n.translate('xpack.searchSynonyms.pluginTitle', { | ||
defaultMessage: 'Synonyms', | ||
}); |
19 changes: 19 additions & 0 deletions
19
x-pack/solutions/search/plugins/search_synonyms/common/types.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,19 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface SearchSynonymsPluginSetup {} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface SearchSynonymsPluginStart {} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-empty-interface | ||
export interface AppPluginSetupDependencies {} | ||
|
||
export interface SearchSynonymsConfigType { | ||
enabled: boolean; | ||
} |
8 changes: 8 additions & 0 deletions
8
x-pack/solutions/search/plugins/search_synonyms/common/ui_flags.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,8 @@ | ||
/* | ||
* 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 SYNONYMS_UI_FLAG = 'searchSynonyms:synonymsEnabled'; |
17 changes: 17 additions & 0 deletions
17
x-pack/solutions/search/plugins/search_synonyms/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,17 @@ | ||
/* | ||
* 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/solutions/search/plugins/search_synonyms'], | ||
coverageDirectory: '<rootDir>/target/kibana-coverage/jest/x-pack/plugins/search_synonyms', | ||
coverageReporters: ['text', 'html'], | ||
collectCoverageFrom: [ | ||
'<rootDir>/x-pack/solutions/search/plugins/search_synonyms/{public,server}/**/*.{ts,tsx}', | ||
], | ||
}; |
26 changes: 26 additions & 0 deletions
26
x-pack/solutions/search/plugins/search_synonyms/kibana.jsonc
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 @@ | ||
{ | ||
"type": "plugin", | ||
"id": "@kbn/search-synonyms", | ||
"owner": "@elastic/search-kibana", | ||
"group": "search", | ||
"visibility": "private", | ||
"plugin": { | ||
"id": "searchSynonyms", | ||
"server": true, | ||
"browser": true, | ||
"configPath": [ | ||
"xpack", | ||
"searchSynonyms" | ||
], | ||
"requiredPlugins": [ | ||
"features", | ||
], | ||
"optionalPlugins": [ | ||
"console", | ||
"searchNavigation", | ||
], | ||
"requiredBundles": [ | ||
"kibanaReact", | ||
] | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
x-pack/solutions/search/plugins/search_synonyms/public/application.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 ReactDOM from 'react-dom'; | ||
import { CoreStart } from '@kbn/core/public'; | ||
import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; | ||
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; | ||
import { I18nProvider } from '@kbn/i18n-react'; | ||
import { Router } from '@kbn/shared-ux-router'; | ||
import { AppPluginStartDependencies } from './types'; | ||
|
||
export const renderApp = async ( | ||
core: CoreStart, | ||
services: AppPluginStartDependencies, | ||
element: HTMLElement | ||
) => { | ||
ReactDOM.render( | ||
<KibanaRenderContextProvider {...core}> | ||
<KibanaContextProvider services={{ ...core, ...services }}> | ||
<I18nProvider> | ||
<Router history={services.history}> | ||
<div>Synonyms</div> | ||
</Router> | ||
</I18nProvider> | ||
</KibanaContextProvider> | ||
</KibanaRenderContextProvider>, | ||
element | ||
); | ||
return () => ReactDOM.unmountComponentAtNode(element); | ||
}; |
12 changes: 12 additions & 0 deletions
12
x-pack/solutions/search/plugins/search_synonyms/public/index.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,12 @@ | ||
/* | ||
* 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 { SearchSynonymsPlugin } from './plugin'; | ||
|
||
export function plugin() { | ||
return new SearchSynonymsPlugin(); | ||
} |
68 changes: 68 additions & 0 deletions
68
x-pack/solutions/search/plugins/search_synonyms/public/plugin.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,68 @@ | ||
/* | ||
* 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 type { CoreSetup, Plugin, AppMountParameters } from '@kbn/core/public'; | ||
import { PLUGIN_ID, PLUGIN_NAME, PLUGIN_TITLE } from '../common'; | ||
import { | ||
AppPluginSetupDependencies, | ||
AppPluginStartDependencies, | ||
SearchSynonymsPluginSetup, | ||
SearchSynonymsPluginStart, | ||
} from './types'; | ||
import { SYNONYMS_UI_FLAG } from '../common/ui_flags'; | ||
|
||
export class SearchSynonymsPlugin | ||
implements Plugin<SearchSynonymsPluginSetup, SearchSynonymsPluginStart> | ||
{ | ||
constructor() {} | ||
|
||
public setup( | ||
core: CoreSetup<AppPluginStartDependencies, SearchSynonymsPluginStart>, | ||
_: AppPluginSetupDependencies | ||
): SearchSynonymsPluginSetup { | ||
if (!core.settings.client.get<boolean>(SYNONYMS_UI_FLAG, false)) { | ||
return {}; | ||
} | ||
core.application.register({ | ||
id: PLUGIN_ID, | ||
appRoute: '/app/elasticsearch/synonyms', | ||
title: PLUGIN_TITLE, | ||
deepLinks: [ | ||
{ | ||
id: 'synonyms', | ||
path: '/', | ||
title: PLUGIN_TITLE, | ||
visibleIn: ['globalSearch'], | ||
}, | ||
], | ||
async mount({ element, history }: AppMountParameters) { | ||
const { renderApp } = await import('./application'); | ||
const [coreStart, depsStart] = await core.getStartServices(); | ||
|
||
coreStart.chrome.docTitle.change(PLUGIN_NAME); | ||
|
||
const startDeps: AppPluginStartDependencies = { | ||
...depsStart, | ||
history, | ||
}; | ||
|
||
depsStart.searchNavigation?.handleOnAppMount(); | ||
|
||
return renderApp(coreStart, startDeps, element); | ||
}, | ||
visibleIn: [], | ||
}); | ||
|
||
return {}; | ||
} | ||
|
||
public start(): SearchSynonymsPluginStart { | ||
return {}; | ||
} | ||
|
||
public stop() {} | ||
} |
17 changes: 17 additions & 0 deletions
17
x-pack/solutions/search/plugins/search_synonyms/public/types.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,17 @@ | ||
/* | ||
* 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 { SearchNavigationPluginStart } from '@kbn/search-navigation/public'; | ||
import { AppMountParameters } from '@kbn/core/public'; | ||
import type { ConsolePluginStart } from '@kbn/console-plugin/public'; | ||
|
||
export * from '../common/types'; | ||
export interface AppPluginStartDependencies { | ||
history: AppMountParameters['history']; | ||
console?: ConsolePluginStart; | ||
searchNavigation?: SearchNavigationPluginStart; | ||
} |
19 changes: 19 additions & 0 deletions
19
x-pack/solutions/search/plugins/search_synonyms/server/config.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,19 @@ | ||
/* | ||
* 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 { schema, TypeOf } from '@kbn/config-schema'; | ||
import { PluginConfigDescriptor } from '@kbn/core/server'; | ||
|
||
const configSchema = schema.object({ | ||
enabled: schema.boolean({ defaultValue: false }), | ||
}); | ||
|
||
export type SearchPlaygroundConfig = TypeOf<typeof configSchema>; | ||
|
||
export const config: PluginConfigDescriptor<SearchPlaygroundConfig> = { | ||
schema: configSchema, | ||
}; |
17 changes: 17 additions & 0 deletions
17
x-pack/solutions/search/plugins/search_synonyms/server/index.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,17 @@ | ||
/* | ||
* 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 { PluginInitializerContext } from '@kbn/core/server'; | ||
|
||
export { config } from './config'; | ||
|
||
export async function plugin(initializerContext: PluginInitializerContext) { | ||
const { SearchSynonymsPlugin } = await import('./plugin'); | ||
return new SearchSynonymsPlugin(initializerContext); | ||
} | ||
|
||
export type { SearchSynonymsPluginSetup, SearchSynonymsPluginStart } from './types'; |
Oops, something went wrong.