From eb1f38b8692a0ab12e52da9e7ae24886f0f3cb16 Mon Sep 17 00:00:00 2001 From: Clint Andrew Hall Date: Mon, 31 Jan 2022 14:33:34 -0600 Subject: [PATCH] [cloud] Add Chat to Enterprise Search Empty State --- x-pack/plugins/enterprise_search/kibana.json | 2 +- .../product_selector/product_selector.tsx | 4 ++-- .../public/applications/index.tsx | 19 ++++++++++++------- .../enterprise_search/public/plugin.ts | 14 +++++++++++--- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/x-pack/plugins/enterprise_search/kibana.json b/x-pack/plugins/enterprise_search/kibana.json index 76b53766b1f0e..c09f40ba8d303 100644 --- a/x-pack/plugins/enterprise_search/kibana.json +++ b/x-pack/plugins/enterprise_search/kibana.json @@ -2,7 +2,7 @@ "id": "enterpriseSearch", "version": "kibana", "kibanaVersion": "kibana", - "requiredPlugins": ["features", "spaces", "security", "licensing", "data", "charts", "infra"], + "requiredPlugins": ["features", "spaces", "security", "licensing", "data", "charts", "infra", "cloud"], "configPath": ["enterpriseSearch"], "optionalPlugins": ["usageCollection", "home", "cloud", "customIntegrations"], "server": true, diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search/components/product_selector/product_selector.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search/components/product_selector/product_selector.tsx index a94c5d008b124..2df342ce3c672 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search/components/product_selector/product_selector.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search/components/product_selector/product_selector.tsx @@ -27,6 +27,7 @@ import { KibanaPageTemplateSolutionNavAvatar, NO_DATA_PAGE_TEMPLATE_PROPS, } from '../../../../../../../../src/plugins/kibana_react/public'; +import { Chat } from '../../../../../../cloud/public'; import { APP_SEARCH_PLUGIN, WORKPLACE_SEARCH_PLUGIN } from '../../../../../common/constants'; import { docLinks } from '../../../shared/doc_links'; import { KibanaLogic } from '../../../shared/kibana'; @@ -173,10 +174,9 @@ export const ProductSelector: React.FC = ({ })}

- - {shouldShowEnterpriseSearchCards ? productCards : insufficientAccessMessage} + ); }; diff --git a/x-pack/plugins/enterprise_search/public/applications/index.tsx b/x-pack/plugins/enterprise_search/public/applications/index.tsx index 75c4131f2bf6c..62c9835b5aec6 100644 --- a/x-pack/plugins/enterprise_search/public/applications/index.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/index.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React from 'react'; +import React, { FC } from 'react'; import ReactDOM from 'react-dom'; import { Provider } from 'react-redux'; import { Router } from 'react-router-dom'; @@ -43,6 +43,9 @@ export const renderApp = ( const { publicUrl, errorConnectingMessage, ...initialData } = data; externalUrl.enterpriseSearchUrl = publicUrl || config.host || ''; + const EmptyContext: FC = ({ children }) => <>{children}; + const CloudContext = plugins.cloud?.CloudContextProvider || EmptyContext; + resetContext({ createStore: true }); const store = getContext().store; @@ -74,12 +77,14 @@ export const renderApp = ( - - - - - - + + + + + + + + , diff --git a/x-pack/plugins/enterprise_search/public/plugin.ts b/x-pack/plugins/enterprise_search/public/plugin.ts index bca1197d8bb5b..1cc96be1b40f8 100644 --- a/x-pack/plugins/enterprise_search/public/plugin.ts +++ b/x-pack/plugins/enterprise_search/public/plugin.ts @@ -20,7 +20,7 @@ import { FeatureCatalogueCategory, HomePublicPluginSetup, } from '../../../../src/plugins/home/public'; -import { CloudSetup } from '../../cloud/public'; +import { CloudSetup, CloudStart } from '../../cloud/public'; import { LicensingPluginStart } from '../../licensing/public'; import { SecurityPluginSetup, SecurityPluginStart } from '../../security/public'; @@ -47,7 +47,7 @@ interface PluginsSetup { security: SecurityPluginSetup; } export interface PluginsStart { - cloud?: CloudSetup; + cloud?: CloudSetup & CloudStart; licensing: LicensingPluginStart; charts: ChartsPluginStart; data: DataPublicPluginStart; @@ -172,10 +172,18 @@ export class EnterpriseSearchPlugin implements Plugin { public stop() {} - private async getKibanaDeps(core: CoreSetup, params: AppMountParameters, cloud?: CloudSetup) { + private async getKibanaDeps( + core: CoreSetup, + params: AppMountParameters, + cloudSetup?: CloudSetup + ) { // Helper for using start dependencies on mount (instead of setup dependencies) // and for grouping Kibana-related args together (vs. plugin-specific args) const [coreStart, pluginsStart] = await core.getStartServices(); + const cloud = + cloudSetup && (pluginsStart as PluginsStart).cloud + ? { ...cloudSetup, ...(pluginsStart as PluginsStart).cloud } + : undefined; const plugins = { ...pluginsStart, cloud } as PluginsStart; return { params, core: coreStart, plugins };