diff --git a/src/platform/packages/shared/kbn-doc-links/src/get_doc_links.ts b/src/platform/packages/shared/kbn-doc-links/src/get_doc_links.ts index e4cf769069e9b..7558f405b30bf 100644 --- a/src/platform/packages/shared/kbn-doc-links/src/get_doc_links.ts +++ b/src/platform/packages/shared/kbn-doc-links/src/get_doc_links.ts @@ -1020,5 +1020,8 @@ export const getDocLinks = ({ kibanaBranch, buildFlavor }: GetDocLinkOptions): D cases: { legacyApiDeprecations: `${KIBANA_DOCS}breaking-changes-summary.html#breaking-201004`, }, + synonyms: { + synonymsAPIDocumentation: `${ELASTIC_WEBSITE_URL}guide/en/elasticsearch/reference/current/synonyms-apis.html`, + }, }); }; diff --git a/src/platform/packages/shared/kbn-doc-links/src/types.ts b/src/platform/packages/shared/kbn-doc-links/src/types.ts index d561c8b214fb1..460f9be2e5f0d 100644 --- a/src/platform/packages/shared/kbn-doc-links/src/types.ts +++ b/src/platform/packages/shared/kbn-doc-links/src/types.ts @@ -688,6 +688,9 @@ export interface DocLinks { readonly cases: { readonly legacyApiDeprecations: string; }; + readonly synonyms: { + readonly synonymsAPIDocumentation: string; + }; } export type BuildFlavor = 'serverless' | 'traditional'; diff --git a/x-pack/solutions/search/plugins/search_synonyms/common/doc_links.ts b/x-pack/solutions/search/plugins/search_synonyms/common/doc_links.ts new file mode 100644 index 0000000000000..04f36beb245fe --- /dev/null +++ b/x-pack/solutions/search/plugins/search_synonyms/common/doc_links.ts @@ -0,0 +1,20 @@ +/* + * 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 { DocLinks } from '@kbn/doc-links'; + +class SynonymsDocLinks { + public synonymsApi: string = ''; + + constructor() {} + + setDocLinks(newDocLinks: DocLinks) { + this.synonymsApi = newDocLinks.synonyms.synonymsAPIDocumentation; + } +} + +export const docLinks = new SynonymsDocLinks(); diff --git a/x-pack/solutions/search/plugins/search_synonyms/public/application.tsx b/x-pack/solutions/search/plugins/search_synonyms/public/application.tsx index d62f8196e7282..fb724a91a22ab 100644 --- a/x-pack/solutions/search/plugins/search_synonyms/public/application.tsx +++ b/x-pack/solutions/search/plugins/search_synonyms/public/application.tsx @@ -11,8 +11,9 @@ 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 { Route, Router, Routes } from '@kbn/shared-ux-router'; import { AppPluginStartDependencies } from './types'; +import { SearchSynonymsOverview } from './components/overview/overview'; export const renderApp = async ( core: CoreStart, @@ -24,7 +25,11 @@ export const renderApp = async ( -
Synonyms
+ + + + +
diff --git a/x-pack/solutions/search/plugins/search_synonyms/public/components/empty_prompt/empty_prompt.test.tsx b/x-pack/solutions/search/plugins/search_synonyms/public/components/empty_prompt/empty_prompt.test.tsx new file mode 100644 index 0000000000000..76f8a216bf9bc --- /dev/null +++ b/x-pack/solutions/search/plugins/search_synonyms/public/components/empty_prompt/empty_prompt.test.tsx @@ -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 { EmptyPrompt } from './empty_prompt'; +import { render, screen } from '@testing-library/react'; +import { I18nProvider } from '@kbn/i18n-react'; + +jest.mock('../../../common/doc_links', () => ({ + docLinks: { + synonymsApi: 'documentation-url', + }, +})); +const Wrapper = ({ children }: { children?: React.ReactNode }) => ( + {children} +); + +describe('Synonyms Overview Empty Prompt', () => { + it('renders', () => { + render( + + + + ); + expect(screen.getByTestId('searchSynonymsEmptyPromptGetStartedButton')).toBeInTheDocument(); + expect(screen.getByTestId('searchSynonymsEmptyPromptFooterLink').getAttribute('href')).toBe( + 'documentation-url' + ); + }); +}); diff --git a/x-pack/solutions/search/plugins/search_synonyms/public/components/empty_prompt/empty_prompt.tsx b/x-pack/solutions/search/plugins/search_synonyms/public/components/empty_prompt/empty_prompt.tsx new file mode 100644 index 0000000000000..2948cea833f1c --- /dev/null +++ b/x-pack/solutions/search/plugins/search_synonyms/public/components/empty_prompt/empty_prompt.tsx @@ -0,0 +1,206 @@ +/* + * 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 { + EuiButton, + EuiFlexGrid, + EuiFlexGroup, + EuiFlexItem, + EuiHorizontalRule, + EuiIcon, + EuiLink, + EuiSpacer, + EuiSplitPanel, + EuiText, + EuiTitle, + useEuiTheme, +} from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n-react'; +import { css } from '@emotion/react'; +import { docLinks } from '../../../common/doc_links'; + +export const EmptyPrompt: React.FC = () => { + const { euiTheme } = useEuiTheme(); + return ( + + +
+ + + + +

+ +

+
+ + + + +

+ +

+
+
+ +
+ + + +
+
+ + + + + + + + + + + + +
+ +
+
+
+
+
+ + +

+ +

+
+
+
+
+ + + + + + + + + + +
+ +
+
+
+
+
+ + +

+ +

+
+
+
+
+ + + + + + + + + + +
+ +
+
+
+
+
+ + +

+ +

+
+
+
+
+
+
+
+
+ + <> + + + + + +   + + + + + +
+
+
+
+ ); +}; diff --git a/x-pack/solutions/search/plugins/search_synonyms/public/components/overview/overview.tsx b/x-pack/solutions/search/plugins/search_synonyms/public/components/overview/overview.tsx new file mode 100644 index 0000000000000..54d20246e7f92 --- /dev/null +++ b/x-pack/solutions/search/plugins/search_synonyms/public/components/overview/overview.tsx @@ -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, { useMemo } from 'react'; + +import { KibanaPageTemplate } from '@kbn/shared-ux-page-kibana-template'; +import { useKibana } from '../../hooks/use_kibana'; +import { EmptyPrompt } from '../empty_prompt/empty_prompt'; + +export const SearchSynonymsOverview = () => { + const { + services: { console: consolePlugin, history, searchNavigation }, + } = useKibana(); + + const embeddableConsole = useMemo( + () => (consolePlugin?.EmbeddableConsole ? : null), + [consolePlugin] + ); + return ( + + + {embeddableConsole} + + ); +}; diff --git a/x-pack/solutions/search/plugins/search_synonyms/public/hooks/use_kibana.ts b/x-pack/solutions/search/plugins/search_synonyms/public/hooks/use_kibana.ts new file mode 100644 index 0000000000000..90fa7597e17dc --- /dev/null +++ b/x-pack/solutions/search/plugins/search_synonyms/public/hooks/use_kibana.ts @@ -0,0 +1,11 @@ +/* + * 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 { useKibana as _useKibana } from '@kbn/kibana-react-plugin/public'; +import { AppServicesContext } from '../types'; + +export const useKibana = () => _useKibana(); diff --git a/x-pack/solutions/search/plugins/search_synonyms/public/plugin.ts b/x-pack/solutions/search/plugins/search_synonyms/public/plugin.ts index c6762d8b545c3..033d633ed6892 100644 --- a/x-pack/solutions/search/plugins/search_synonyms/public/plugin.ts +++ b/x-pack/solutions/search/plugins/search_synonyms/public/plugin.ts @@ -5,7 +5,7 @@ * 2.0. */ -import type { CoreSetup, Plugin, AppMountParameters } from '@kbn/core/public'; +import type { CoreSetup, Plugin, AppMountParameters, CoreStart } from '@kbn/core/public'; import { PLUGIN_ID, PLUGIN_NAME, PLUGIN_TITLE } from '../common'; import { AppPluginSetupDependencies, @@ -14,6 +14,7 @@ import { SearchSynonymsPluginStart, } from './types'; import { SYNONYMS_UI_FLAG } from '../common/ui_flags'; +import { docLinks } from '../common/doc_links'; export class SearchSynonymsPlugin implements Plugin @@ -60,7 +61,8 @@ export class SearchSynonymsPlugin return {}; } - public start(): SearchSynonymsPluginStart { + public start(core: CoreStart): SearchSynonymsPluginStart { + docLinks.setDocLinks(core.docLinks.links); return {}; } diff --git a/x-pack/solutions/search/plugins/search_synonyms/public/types.ts b/x-pack/solutions/search/plugins/search_synonyms/public/types.ts index eec1ad13ade6c..80f4109e76221 100644 --- a/x-pack/solutions/search/plugins/search_synonyms/public/types.ts +++ b/x-pack/solutions/search/plugins/search_synonyms/public/types.ts @@ -6,7 +6,7 @@ */ import { SearchNavigationPluginStart } from '@kbn/search-navigation/public'; -import { AppMountParameters } from '@kbn/core/public'; +import { AppMountParameters, CoreStart } from '@kbn/core/public'; import type { ConsolePluginStart } from '@kbn/console-plugin/public'; export * from '../common/types'; @@ -15,3 +15,5 @@ export interface AppPluginStartDependencies { console?: ConsolePluginStart; searchNavigation?: SearchNavigationPluginStart; } + +export type AppServicesContext = CoreStart & AppPluginStartDependencies; diff --git a/x-pack/solutions/search/plugins/search_synonyms/tsconfig.json b/x-pack/solutions/search/plugins/search_synonyms/tsconfig.json index f8af8bac5e3d3..027f552896e68 100644 --- a/x-pack/solutions/search/plugins/search_synonyms/tsconfig.json +++ b/x-pack/solutions/search/plugins/search_synonyms/tsconfig.json @@ -20,6 +20,8 @@ "@kbn/console-plugin", "@kbn/features-plugin", "@kbn/search-navigation", + "@kbn/doc-links", + "@kbn/shared-ux-page-kibana-template", ], "exclude": [ "target/**/*",