From f14587c4cae97a9f892c2cf08227d2094d3f07c3 Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Wed, 14 Jun 2023 10:30:20 +0200 Subject: [PATCH 01/20] global drift wip --- package.json | 1 - .../src/chrome_service.test.tsx | 27 ++++++++++ .../src/chrome_service.tsx | 13 +++++ .../core-chrome-browser-internal/src/types.ts | 6 +++ .../src/chrome_service.mock.ts | 2 + .../core-chrome-browser/src/contracts.ts | 7 +++ .../src/rendering_service.test.tsx | 6 +++ .../src/rendering_service.tsx | 4 ++ packages/kbn-optimizer/limits.yml | 1 - src/plugins/home/kibana.jsonc | 18 ++----- .../guided_onboarding/getting_started.tsx | 4 +- .../public/application/kibana_services.ts | 2 - src/plugins/home/public/plugin.ts | 9 +--- .../management_app/management_app.tsx | 5 +- src/plugins/management/public/plugin.ts | 5 +- tsconfig.base.json | 2 - .../cloud_chat/kibana.jsonc | 3 +- .../public/components/chat/chat.tsx | 4 +- .../cloud_chat/public/index.ts | 1 - .../cloud_chat/public/plugin.test.ts | 12 +---- .../cloud_chat/public/plugin.tsx | 24 +++------ .../cloud_chat_provider/README.md | 5 -- .../cloud_chat_provider/jest.config.js | 18 ------- .../cloud_chat_provider/kibana.jsonc | 11 ----- .../cloud_chat_provider/public/index.ts | 15 ------ .../cloud_chat_provider/public/plugin.tsx | 49 ------------------- .../cloud_chat_provider/tsconfig.json | 15 ------ x-pack/plugins/data_visualizer/kibana.jsonc | 3 +- .../file_data_visualizer_view.js | 3 -- x-pack/plugins/enterprise_search/kibana.jsonc | 3 +- .../product_selector/product_selector.tsx | 2 - x-pack/plugins/fleet/kibana.jsonc | 1 - .../public/applications/integrations/app.tsx | 2 - yarn.lock | 4 -- 34 files changed, 85 insertions(+), 202 deletions(-) delete mode 100755 x-pack/plugins/cloud_integrations/cloud_chat_provider/README.md delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat_provider/jest.config.js delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat_provider/kibana.jsonc delete mode 100755 x-pack/plugins/cloud_integrations/cloud_chat_provider/public/index.ts delete mode 100755 x-pack/plugins/cloud_integrations/cloud_chat_provider/public/plugin.tsx delete mode 100644 x-pack/plugins/cloud_integrations/cloud_chat_provider/tsconfig.json diff --git a/package.json b/package.json index f65e02b6dabec..c0a1939873898 100644 --- a/package.json +++ b/package.json @@ -168,7 +168,6 @@ "@kbn/chart-icons": "link:packages/kbn-chart-icons", "@kbn/charts-plugin": "link:src/plugins/charts", "@kbn/cloud-chat-plugin": "link:x-pack/plugins/cloud_integrations/cloud_chat", - "@kbn/cloud-chat-provider-plugin": "link:x-pack/plugins/cloud_integrations/cloud_chat_provider", "@kbn/cloud-data-migration-plugin": "link:x-pack/plugins/cloud_integrations/cloud_data_migration", "@kbn/cloud-defend-plugin": "link:x-pack/plugins/cloud_defend", "@kbn/cloud-experiments-plugin": "link:x-pack/plugins/cloud_integrations/cloud_experiments", diff --git a/packages/core/chrome/core-chrome-browser-internal/src/chrome_service.test.tsx b/packages/core/chrome/core-chrome-browser-internal/src/chrome_service.test.tsx index 0e18b5b72c367..84fa94bd4ae82 100644 --- a/packages/core/chrome/core-chrome-browser-internal/src/chrome_service.test.tsx +++ b/packages/core/chrome/core-chrome-browser-internal/src/chrome_service.test.tsx @@ -8,6 +8,7 @@ import { shallow, mount } from 'enzyme'; import React from 'react'; +import { render, act } from '@testing-library/react'; import * as Rx from 'rxjs'; import { toArray } from 'rxjs/operators'; import { injectedMetadataServiceMock } from '@kbn/core-injected-metadata-browser-mocks'; @@ -497,6 +498,32 @@ describe('start', () => { `); }); }); + + describe('chat', () => { + it('returns an empty component', async () => { + const { chrome } = await start(); + const Chat = chrome.getChatComponent(); + const { container } = render(); + expect(container).toMatchInlineSnapshot(`
`); + }); + + it('renders a chat component', async () => { + const { chrome } = await start(); + const Chat = chrome.getChatComponent(); + const { container } = render(); + act(() => { + chrome.setChatComponent(() =>
); + }); + + expect(container).toMatchInlineSnapshot(` +
+
+
+ `); + }); + }); }); describe('stop', () => { diff --git a/packages/core/chrome/core-chrome-browser-internal/src/chrome_service.tsx b/packages/core/chrome/core-chrome-browser-internal/src/chrome_service.tsx index ede90c7098b5f..ca851ec4cf4b8 100644 --- a/packages/core/chrome/core-chrome-browser-internal/src/chrome_service.tsx +++ b/packages/core/chrome/core-chrome-browser-internal/src/chrome_service.tsx @@ -69,6 +69,9 @@ export class ChromeService { private readonly recentlyAccessed = new RecentlyAccessedService(); private readonly docTitle = new DocTitleService(); private readonly projectNavigation = new ProjectNavigationService(); + private readonly chatComponent$ = new BehaviorSubject<{ Comp: React.ComponentType | null }>({ + Comp: null, + }); constructor(private readonly params: ConstructorParams) {} @@ -340,6 +343,11 @@ export class ChromeService { ); }; + const Chat: React.FC = () => { + const ChatComponent = useObservable(this.chatComponent$, { Comp: null }).Comp; + return ChatComponent ? : <>; + }; + return { navControls, navLinks, @@ -418,6 +426,11 @@ export class ChromeService { setSideNavComponent: setProjectSideNavComponent, setBreadcrumbs: setProjectBreadcrumbs, }, + + getChatComponent: () => Chat, + setChatComponent: (ChatComponent: React.ComponentType | null) => { + this.chatComponent$.next({ Comp: ChatComponent }); + }, }; } diff --git a/packages/core/chrome/core-chrome-browser-internal/src/types.ts b/packages/core/chrome/core-chrome-browser-internal/src/types.ts index 427fb2c90d7e0..fa08cd3f5086e 100644 --- a/packages/core/chrome/core-chrome-browser-internal/src/types.ts +++ b/packages/core/chrome/core-chrome-browser-internal/src/types.ts @@ -6,6 +6,7 @@ * Side Public License, v 1. */ +import type { ComponentType } from 'react'; import type { ChromeProjectNavigation, ChromeStart, @@ -30,6 +31,11 @@ export interface InternalChromeStart extends ChromeStart { */ getBodyClasses$(): Observable; + /** + * Used only by the rendering service to render the slot of cloud chat UI + */ + getChatComponent(): ComponentType; + /** * Used only by the serverless plugin to customize project-style chrome. * @internal diff --git a/packages/core/chrome/core-chrome-browser-mocks/src/chrome_service.mock.ts b/packages/core/chrome/core-chrome-browser-mocks/src/chrome_service.mock.ts index 68554c646cd99..6ac19f08515c6 100644 --- a/packages/core/chrome/core-chrome-browser-mocks/src/chrome_service.mock.ts +++ b/packages/core/chrome/core-chrome-browser-mocks/src/chrome_service.mock.ts @@ -69,6 +69,8 @@ const createStartContractMock = () => { setSideNavComponent: jest.fn(), setBreadcrumbs: jest.fn(), }, + getChatComponent: jest.fn(() => () => null), + setChatComponent: jest.fn(), }; startContract.navLinks.getAll.mockReturnValue([]); startContract.getIsVisible$.mockReturnValue(new BehaviorSubject(false)); diff --git a/packages/core/chrome/core-chrome-browser/src/contracts.ts b/packages/core/chrome/core-chrome-browser/src/contracts.ts index f64995c877c7f..1218a2d679b11 100644 --- a/packages/core/chrome/core-chrome-browser/src/contracts.ts +++ b/packages/core/chrome/core-chrome-browser/src/contracts.ts @@ -7,6 +7,7 @@ */ import type { Observable } from 'rxjs'; +import type { ComponentType } from 'React'; import type { ChromeNavLink, ChromeNavLinks } from './nav_links'; import type { ChromeRecentlyAccessed } from './recently_accessed'; import type { ChromeDocTitle } from './doc_title'; @@ -161,4 +162,10 @@ export interface ChromeStart { * Get an observable of the current style type of the chrome. */ getChromeStyle$(): Observable; + + /** + * Set the chat component to be rendered in the chat slot. Used by cloud chat plugin. + * @param ChatComponent + */ + setChatComponent(ChatComponent: ComponentType | null): void; } diff --git a/packages/core/rendering/core-rendering-browser-internal/src/rendering_service.test.tsx b/packages/core/rendering/core-rendering-browser-internal/src/rendering_service.test.tsx index 09589ebb0a40d..657cb9c7a101b 100644 --- a/packages/core/rendering/core-rendering-browser-internal/src/rendering_service.test.tsx +++ b/packages/core/rendering/core-rendering-browser-internal/src/rendering_service.test.tsx @@ -32,6 +32,7 @@ describe('RenderingService#start', () => { chrome = chromeServiceMock.createStartContract(); chrome.getHeaderComponent.mockReturnValue(
Hello chrome!
); + chrome.getChatComponent.mockReturnValue(() =>
Hello chat!
); overlays = overlayServiceMock.createStartContract(); overlays.banners.getComponent.mockReturnValue(
I'm a banner!
); @@ -110,4 +111,9 @@ describe('RenderingService#start', () => { startService(); expect(document.querySelector(`style[data-emotion="eui-styles-global"]`)).toBeDefined(); }); + + it('renders the chat UI', () => { + startService(); + expect(targetDomElement.innerHTML).toMatch(/Hello chat!/); + }); }); diff --git a/packages/core/rendering/core-rendering-browser-internal/src/rendering_service.tsx b/packages/core/rendering/core-rendering-browser-internal/src/rendering_service.tsx index 89397191a8b2b..0c551649727be 100644 --- a/packages/core/rendering/core-rendering-browser-internal/src/rendering_service.tsx +++ b/packages/core/rendering/core-rendering-browser-internal/src/rendering_service.tsx @@ -40,6 +40,7 @@ export class RenderingService { const chromeHeader = chrome.getHeaderComponent(); const appComponent = application.getComponent(); const bannerComponent = overlays.banners.getComponent(); + const Chat = chrome.getChatComponent(); const body = document.querySelector('body')!; chrome @@ -67,6 +68,9 @@ export class RenderingService { {/* The actual plugin/app */} {appComponent} + + {/* Chat component slot for the component set via chrome.setChatComponent api. */} + , targetDomElement diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index db5f45fb4447f..2b0a611831f8b 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -11,7 +11,6 @@ pageLoadAssetSize: charts: 55000 cloud: 21076 cloudChat: 19894 - cloudChatProvider: 17114 cloudDataMigration: 19170 cloudDefend: 18697 cloudExperiments: 59358 diff --git a/src/plugins/home/kibana.jsonc b/src/plugins/home/kibana.jsonc index da5387492ec47..cc68748e10220 100644 --- a/src/plugins/home/kibana.jsonc +++ b/src/plugins/home/kibana.jsonc @@ -6,20 +6,8 @@ "id": "home", "server": true, "browser": true, - "requiredPlugins": [ - "dataViews", - "share", - "urlForwarding" - ], - "optionalPlugins": [ - "usageCollection", - "customIntegrations", - "cloud", - "guidedOnboarding", - "cloudChatProvider" - ], - "requiredBundles": [ - "kibanaReact" - ] + "requiredPlugins": ["dataViews", "share", "urlForwarding"], + "optionalPlugins": ["usageCollection", "customIntegrations", "cloud", "guidedOnboarding"], + "requiredBundles": ["kibanaReact"] } } diff --git a/src/plugins/home/public/application/components/guided_onboarding/getting_started.tsx b/src/plugins/home/public/application/components/guided_onboarding/getting_started.tsx index 0c48be20291f1..06bf800881cde 100644 --- a/src/plugins/home/public/application/components/guided_onboarding/getting_started.tsx +++ b/src/plugins/home/public/application/components/guided_onboarding/getting_started.tsx @@ -43,8 +43,7 @@ const skipText = i18n.translate('home.guidedOnboarding.gettingStarted.skip.butto }); export const GettingStarted = () => { - const { application, trackUiMetric, chrome, guidedOnboardingService, cloud, cloudChat } = - getServices(); + const { application, trackUiMetric, chrome, guidedOnboardingService, cloud } = getServices(); const [guidesState, setGuidesState] = useState([]); const [isLoading, setIsLoading] = useState(false); @@ -227,7 +226,6 @@ export const GettingStarted = () => { {skipText}
- {cloudChat?.Chat && } ); diff --git a/src/plugins/home/public/application/kibana_services.ts b/src/plugins/home/public/application/kibana_services.ts index 3621a9e7e6efe..af0a94b232fe6 100644 --- a/src/plugins/home/public/application/kibana_services.ts +++ b/src/plugins/home/public/application/kibana_services.ts @@ -22,7 +22,6 @@ import { DataViewsContract } from '@kbn/data-views-plugin/public'; import { SharePluginSetup } from '@kbn/share-plugin/public'; import { GuidedOnboardingApi } from '@kbn/guided-onboarding-plugin/public'; import { CloudSetup } from '@kbn/cloud-plugin/public'; -import { CloudChatProviderPluginStart } from '@kbn/cloud-chat-provider-plugin/public'; import { TutorialService } from '../services/tutorials'; import { AddDataService } from '../services/add_data'; import { FeatureCatalogueRegistry } from '../services/feature_catalogue'; @@ -54,7 +53,6 @@ export interface HomeKibanaServices { welcomeService: WelcomeService; guidedOnboardingService?: GuidedOnboardingApi; cloud?: CloudSetup; - cloudChat?: CloudChatProviderPluginStart; } let services: HomeKibanaServices | null = null; diff --git a/src/plugins/home/public/plugin.ts b/src/plugins/home/public/plugin.ts index 439c35ff3d239..b7270058aae6c 100644 --- a/src/plugins/home/public/plugin.ts +++ b/src/plugins/home/public/plugin.ts @@ -22,7 +22,6 @@ import type { GuidedOnboardingPluginStart } from '@kbn/guided-onboarding-plugin/ import { AppNavLinkStatus } from '@kbn/core/public'; import { SharePluginSetup } from '@kbn/share-plugin/public'; import type { CloudSetup } from '@kbn/cloud-plugin/public'; -import type { CloudChatProviderPluginStart } from '@kbn/cloud-chat-provider-plugin/public'; import { PLUGIN_ID, HOME_APP_BASE_PATH } from '../common/constants'; import { setServices } from './application/kibana_services'; import { ConfigSchema } from '../config'; @@ -43,7 +42,6 @@ export interface HomePluginStartDependencies { dataViews: DataViewsPublicPluginStart; urlForwarding: UrlForwardingStart; guidedOnboarding: GuidedOnboardingPluginStart; - cloudChatProvider?: CloudChatProviderPluginStart; } export interface HomePluginSetupDependencies { @@ -82,10 +80,8 @@ export class HomePublicPlugin const trackUiMetric = usageCollection ? usageCollection.reportUiCounter.bind(usageCollection, 'Kibana_home') : () => {}; - const [ - coreStart, - { dataViews, urlForwarding: urlForwardingStart, guidedOnboarding, cloudChatProvider }, - ] = await core.getStartServices(); + const [coreStart, { dataViews, urlForwarding: urlForwardingStart, guidedOnboarding }] = + await core.getStartServices(); setServices({ share, trackUiMetric, @@ -110,7 +106,6 @@ export class HomePublicPlugin welcomeService: this.welcomeService, guidedOnboardingService: guidedOnboarding.guidedOnboardingApi, cloud, - cloudChat: cloudChatProvider, }); coreStart.chrome.docTitle.change( i18n.translate('home.pageTitle', { defaultMessage: 'Home' }) diff --git a/src/plugins/management/public/components/management_app/management_app.tsx b/src/plugins/management/public/components/management_app/management_app.tsx index 51289c0fbf791..50ab45a867c98 100644 --- a/src/plugins/management/public/components/management_app/management_app.tsx +++ b/src/plugins/management/public/components/management_app/management_app.tsx @@ -16,7 +16,6 @@ import { AppMountParameters, ChromeBreadcrumb, ScopedHistory } from '@kbn/core/p import { reactRouterNavigate, KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; import { KibanaPageTemplate, KibanaPageTemplateProps } from '@kbn/shared-ux-page-kibana-template'; -import type { CloudChatProviderPluginStart } from '@kbn/cloud-chat-provider-plugin/public'; import useObservable from 'react-use/lib/useObservable'; import { ManagementSection, @@ -39,11 +38,10 @@ export interface ManagementAppDependencies { kibanaVersion: string; setBreadcrumbs: (newBreadcrumbs: ChromeBreadcrumb[]) => void; isSidebarEnabled$: BehaviorSubject; - cloudChat?: CloudChatProviderPluginStart; } export const ManagementApp = ({ dependencies, history, theme$ }: ManagementAppProps) => { - const { setBreadcrumbs, isSidebarEnabled$, cloudChat } = dependencies; + const { setBreadcrumbs, isSidebarEnabled$ } = dependencies; const [selectedId, setSelectedId] = useState(''); const [sections, setSections] = useState(); const isSidebarEnabled = useObservable(isSidebarEnabled$); @@ -116,7 +114,6 @@ export const ManagementApp = ({ dependencies, history, theme$ }: ManagementAppPr dependencies={dependencies} /> - {cloudChat?.Chat ? : null} ); diff --git a/src/plugins/management/public/plugin.ts b/src/plugins/management/public/plugin.ts index edb6bd55fc49b..578ae13a79c32 100644 --- a/src/plugins/management/public/plugin.ts +++ b/src/plugins/management/public/plugin.ts @@ -10,7 +10,6 @@ import { i18n } from '@kbn/i18n'; import { BehaviorSubject } from 'rxjs'; import type { SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/public'; import { HomePublicPluginSetup } from '@kbn/home-plugin/public'; -import { CloudChatProviderPluginStart } from '@kbn/cloud-chat-provider-plugin/public'; import { CoreSetup, CoreStart, @@ -40,7 +39,6 @@ interface ManagementSetupDependencies { interface ManagementStartDependencies { share: SharePluginStart; - cloudChatProvider?: CloudChatProviderPluginStart; } export class ManagementPlugin @@ -113,14 +111,13 @@ export class ManagementPlugin updater$: this.appUpdater, async mount(params: AppMountParameters) { const { renderApp } = await import('./application'); - const [coreStart, plugins] = await core.getStartServices(); + const [coreStart] = await core.getStartServices(); return renderApp(params, { sections: getSectionsServiceStartPrivate(), kibanaVersion, setBreadcrumbs: coreStart.chrome.setBreadcrumbs, isSidebarEnabled$: managementPlugin.isSidebarEnabled$, - cloudChat: plugins.cloudChatProvider, }); }, }); diff --git a/tsconfig.base.json b/tsconfig.base.json index 6830598bf44a8..58821a7ed4273 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -128,8 +128,6 @@ "@kbn/cli-dev-mode/*": ["packages/kbn-cli-dev-mode/*"], "@kbn/cloud-chat-plugin": ["x-pack/plugins/cloud_integrations/cloud_chat"], "@kbn/cloud-chat-plugin/*": ["x-pack/plugins/cloud_integrations/cloud_chat/*"], - "@kbn/cloud-chat-provider-plugin": ["x-pack/plugins/cloud_integrations/cloud_chat_provider"], - "@kbn/cloud-chat-provider-plugin/*": ["x-pack/plugins/cloud_integrations/cloud_chat_provider/*"], "@kbn/cloud-data-migration-plugin": ["x-pack/plugins/cloud_integrations/cloud_data_migration"], "@kbn/cloud-data-migration-plugin/*": ["x-pack/plugins/cloud_integrations/cloud_data_migration/*"], "@kbn/cloud-defend-plugin": ["x-pack/plugins/cloud_defend"], diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/kibana.jsonc b/x-pack/plugins/cloud_integrations/cloud_chat/kibana.jsonc index d69c5f602727d..a8bbc4a8966ef 100644 --- a/x-pack/plugins/cloud_integrations/cloud_chat/kibana.jsonc +++ b/x-pack/plugins/cloud_integrations/cloud_chat/kibana.jsonc @@ -13,8 +13,7 @@ "chat" ], "requiredPlugins": [ - "cloud", - "cloudChatProvider" + "cloud" ], "optionalPlugins": [ "security" diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat/chat.tsx b/x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat/chat.tsx index f58c5d0834ae2..1a11542699ed3 100644 --- a/x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat/chat.tsx +++ b/x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat/chat.tsx @@ -37,10 +37,10 @@ export const Chat = ({ onHide = () => {}, onReady, onResize }: Props) => { } const { isReady, isResized, style } = config; - const { bottom, height, right } = style; + const { right } = style; const buttonCSS = css` - bottom: calc(${bottom} + ${height}); + bottom: ${euiThemeVars.euiSizeXS}; position: fixed; right: calc(${right} + ${euiThemeVars.euiSizeXS}); visibility: ${isReady && isResized ? 'visible' : 'hidden'}; diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/public/index.ts b/x-pack/plugins/cloud_integrations/cloud_chat/public/index.ts index 58efae58ce491..4407f19670560 100755 --- a/x-pack/plugins/cloud_integrations/cloud_chat/public/index.ts +++ b/x-pack/plugins/cloud_integrations/cloud_chat/public/index.ts @@ -13,4 +13,3 @@ export function plugin(initializerContext: PluginInitializerContext) { } export { Chat } from './components'; -export type { CloudChatPluginStart } from './plugin'; diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/public/plugin.test.ts b/x-pack/plugins/cloud_integrations/cloud_chat/public/plugin.test.ts index 18611944e1b63..f44c7cd5112e3 100644 --- a/x-pack/plugins/cloud_integrations/cloud_chat/public/plugin.test.ts +++ b/x-pack/plugins/cloud_integrations/cloud_chat/public/plugin.test.ts @@ -64,17 +64,12 @@ describe('Cloud Chat Plugin', () => { const cloud = cloudMock.createSetup(); - const cloudChatProvider = { - registerChatProvider: jest.fn(), - }; - plugin.setup(coreSetup, { cloud: { ...cloud, isCloudEnabled, trialEndDate }, ...(securityEnabled ? { security: securitySetup } : {}), - cloudChatProvider, }); - return { initContext, plugin, coreSetup, cloudChatProvider }; + return { initContext, plugin, coreSetup }; }; it('chatConfig is not retrieved if cloud is not enabled', async () => { @@ -119,11 +114,6 @@ describe('Cloud Chat Plugin', () => { }); expect(coreSetup.http.get).toHaveBeenCalled(); }); - - it('Chat component is registered with chatProvider plugin', async () => { - const { cloudChatProvider } = await setupPlugin({}); - expect(cloudChatProvider.registerChatProvider).toBeCalled(); - }); }); }); }); diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/public/plugin.tsx b/x-pack/plugins/cloud_integrations/cloud_chat/public/plugin.tsx index b3dea31598a75..23cc3251cd2de 100755 --- a/x-pack/plugins/cloud_integrations/cloud_chat/public/plugin.tsx +++ b/x-pack/plugins/cloud_integrations/cloud_chat/public/plugin.tsx @@ -11,7 +11,6 @@ import type { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from '@kb import type { HttpSetup } from '@kbn/core-http-browser'; import type { SecurityPluginSetup } from '@kbn/security-plugin/public'; import type { CloudSetup, CloudStart } from '@kbn/cloud-plugin/public'; -import { CloudChatProviderPluginSetup } from '@kbn/cloud-chat-provider-plugin/public'; import { ReplaySubject } from 'rxjs'; import type { GetChatUserDataResponseBody } from '../common/types'; import { GET_CHAT_USER_DATA_ROUTE_PATH } from '../common/constants'; @@ -22,7 +21,6 @@ import { Chat } from './components'; interface CloudChatSetupDeps { cloud: CloudSetup; security?: SecurityPluginSetup; - cloudChatProvider: CloudChatProviderPluginSetup; } interface CloudChatStartDeps { @@ -38,23 +36,16 @@ interface CloudChatConfig { trialBuffer: number; } -export interface CloudChatPluginStart { - Chat: React.ComponentType; -} - -export class CloudChatPlugin - implements Plugin -{ +export class CloudChatPlugin implements Plugin { private readonly config: CloudChatConfig; private chatConfig$ = new ReplaySubject(1); - private Chat: React.ComponentType | undefined; constructor(initializerContext: PluginInitializerContext) { this.config = initializerContext.config.get(); } - public setup(core: CoreSetup, { cloud, security, cloudChatProvider }: CloudChatSetupDeps) { - this.setupChat({ http: core.http, cloud, security, cloudChatProvider }).catch((e) => + public setup(core: CoreSetup, { cloud, security }: CloudChatSetupDeps) { + this.setupChat({ http: core.http, cloud, security }).catch((e) => // eslint-disable-next-line no-console console.debug(`Error setting up Chat: ${e.toString()}`) ); @@ -65,19 +56,16 @@ export class CloudChatPlugin return {children}; }; cloud.registerCloudService(CloudChatContextProvider); - cloudChatProvider.registerChatProvider(() => this.Chat); } public start(core: CoreStart, { cloud }: CloudChatStartDeps) { const CloudContextProvider = cloud.CloudContextProvider; - this.Chat = () => ( + + core.chrome.setChatComponent(() => ( - ); - return { - Chat: this.Chat, - }; + )); } public stop() {} diff --git a/x-pack/plugins/cloud_integrations/cloud_chat_provider/README.md b/x-pack/plugins/cloud_integrations/cloud_chat_provider/README.md deleted file mode 100755 index a811eec10b2dc..0000000000000 --- a/x-pack/plugins/cloud_integrations/cloud_chat_provider/README.md +++ /dev/null @@ -1,5 +0,0 @@ -# Cloud Chat Provider - -This plugin exists as a workaround for using `cloudChat` plugin in plugins which can't have a direct dependency on security plugin. - -Ideally we'd remove this plugin and used `cloudChat` directly https://github.com/elastic/kibana/issues/159008 diff --git a/x-pack/plugins/cloud_integrations/cloud_chat_provider/jest.config.js b/x-pack/plugins/cloud_integrations/cloud_chat_provider/jest.config.js deleted file mode 100644 index 366eba666d02a..0000000000000 --- a/x-pack/plugins/cloud_integrations/cloud_chat_provider/jest.config.js +++ /dev/null @@ -1,18 +0,0 @@ -/* - * 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: ['/x-pack/plugins/cloud_integrations/cloud_chat_provider'], - coverageDirectory: - '/target/kibana-coverage/jest/x-pack/plugins/cloud_integrations/cloud_chat_provider', - coverageReporters: ['text', 'html'], - collectCoverageFrom: [ - '/x-pack/plugins/cloud_integrations/cloud_chat_provider/{common,public,server}/**/*.{ts,tsx}', - ], -}; diff --git a/x-pack/plugins/cloud_integrations/cloud_chat_provider/kibana.jsonc b/x-pack/plugins/cloud_integrations/cloud_chat_provider/kibana.jsonc deleted file mode 100644 index 7b94be0eda78d..0000000000000 --- a/x-pack/plugins/cloud_integrations/cloud_chat_provider/kibana.jsonc +++ /dev/null @@ -1,11 +0,0 @@ -{ - "type": "plugin", - "id": "@kbn/cloud-chat-provider-plugin", - "owner": "@elastic/kibana-core", - "description": "This plugin exists as a workaround for using `cloudChat` plugin in plugins which can't have a direct dependency on security plugin.", - "plugin": { - "id": "cloudChatProvider", - "server": false, - "browser": true - } -} diff --git a/x-pack/plugins/cloud_integrations/cloud_chat_provider/public/index.ts b/x-pack/plugins/cloud_integrations/cloud_chat_provider/public/index.ts deleted file mode 100755 index 8a447aa96df15..0000000000000 --- a/x-pack/plugins/cloud_integrations/cloud_chat_provider/public/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* - * 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 { PluginInitializerContext } from '@kbn/core/public'; -import { CloudChatProviderPlugin } from './plugin'; - -export function plugin(initializerContext: PluginInitializerContext) { - return new CloudChatProviderPlugin(initializerContext); -} - -export type { CloudChatProviderPluginSetup, CloudChatProviderPluginStart } from './plugin'; diff --git a/x-pack/plugins/cloud_integrations/cloud_chat_provider/public/plugin.tsx b/x-pack/plugins/cloud_integrations/cloud_chat_provider/public/plugin.tsx deleted file mode 100755 index 4b8d600791a2b..0000000000000 --- a/x-pack/plugins/cloud_integrations/cloud_chat_provider/public/plugin.tsx +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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 type { CoreSetup, CoreStart, Plugin } from '@kbn/core/public'; -import type { PluginInitializerContext } from '@kbn/core/public'; - -export interface CloudChatProviderPluginSetup { - registerChatProvider: (getChat: () => React.ComponentType | undefined) => void; -} - -export interface CloudChatProviderPluginStart { - Chat?: React.ComponentType; -} - -export class CloudChatProviderPlugin - implements Plugin -{ - private getChat: (() => React.ComponentType | undefined) | undefined; - - constructor(initializerContext: PluginInitializerContext) {} - - public setup(core: CoreSetup) { - return { - registerChatProvider: (getChat: () => React.ComponentType | undefined) => { - if (this.getChat) { - throw new Error('Chat component has already been provided'); - } - - this.getChat = getChat; - }, - }; - } - - public start(core: CoreStart) { - return { - Chat: () => { - const Chat = this.getChat?.(); - return Chat ? : <>; - }, - }; - } - - public stop() {} -} diff --git a/x-pack/plugins/cloud_integrations/cloud_chat_provider/tsconfig.json b/x-pack/plugins/cloud_integrations/cloud_chat_provider/tsconfig.json deleted file mode 100644 index 096eeb2b45a93..0000000000000 --- a/x-pack/plugins/cloud_integrations/cloud_chat_provider/tsconfig.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "extends": "../../../../tsconfig.base.json", - "compilerOptions": { - "outDir": "target/types" - }, - "include": [ - ".storybook/**/*", - "common/**/*", - "public/**/*", - "server/**/*", - "../../../typings/**/*" - ], - "kbn_references": ["@kbn/core"], - "exclude": ["target/**/*"] -} diff --git a/x-pack/plugins/data_visualizer/kibana.jsonc b/x-pack/plugins/data_visualizer/kibana.jsonc index 6f52718d21522..d2fc3c967f63a 100644 --- a/x-pack/plugins/data_visualizer/kibana.jsonc +++ b/x-pack/plugins/data_visualizer/kibana.jsonc @@ -36,8 +36,7 @@ "fieldFormats", "uiActions", "unifiedFieldList", - "lens", - "cloudChat", + "lens" ] } } diff --git a/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/file_data_visualizer_view/file_data_visualizer_view.js b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/file_data_visualizer_view/file_data_visualizer_view.js index b1378769efc92..5df9b688c6bf9 100644 --- a/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/file_data_visualizer_view/file_data_visualizer_view.js +++ b/x-pack/plugins/data_visualizer/public/application/file_data_visualizer/components/file_data_visualizer_view/file_data_visualizer_view.js @@ -30,8 +30,6 @@ import { processResults, } from '../../../common/components/utils'; -import { Chat } from '@kbn/cloud-chat-plugin/public'; - import { MODE } from './constants'; export class FileDataVisualizerView extends Component { @@ -388,7 +386,6 @@ export class FileDataVisualizerView extends Component { )} )} -
); } diff --git a/x-pack/plugins/enterprise_search/kibana.jsonc b/x-pack/plugins/enterprise_search/kibana.jsonc index 0a6d3ebee52ae..b8965245b98fd 100644 --- a/x-pack/plugins/enterprise_search/kibana.jsonc +++ b/x-pack/plugins/enterprise_search/kibana.jsonc @@ -34,8 +34,7 @@ "usageCollection" ], "requiredBundles": [ - "kibanaReact", - "cloudChat" + "kibanaReact" ] } } diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/product_selector/product_selector.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/product_selector/product_selector.tsx index e9eaa84359826..05dfcda6566b0 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/product_selector/product_selector.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_overview/components/product_selector/product_selector.tsx @@ -19,7 +19,6 @@ import { EuiSpacer, EuiTitle, } from '@elastic/eui'; -import { Chat } from '@kbn/cloud-chat-plugin/public'; import { i18n } from '@kbn/i18n'; import { @@ -371,7 +370,6 @@ export const ProductSelector: React.FC = ({ {shouldShowEnterpriseSearchCards ? productCards : insufficientAccessMessage} - ); }; diff --git a/x-pack/plugins/fleet/kibana.jsonc b/x-pack/plugins/fleet/kibana.jsonc index f86c939456445..2aa6e76097fe8 100644 --- a/x-pack/plugins/fleet/kibana.jsonc +++ b/x-pack/plugins/fleet/kibana.jsonc @@ -38,7 +38,6 @@ ], "requiredBundles": [ "kibanaReact", - "cloudChat", "esUiShared", "infra", "kibanaUtils", diff --git a/x-pack/plugins/fleet/public/applications/integrations/app.tsx b/x-pack/plugins/fleet/public/applications/integrations/app.tsx index bac899a06a9e6..97a5d4997a11e 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/app.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/app.tsx @@ -17,7 +17,6 @@ import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; import { KibanaContextProvider, RedirectAppLinks } from '@kbn/kibana-react-plugin/public'; import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common'; -import { Chat } from '@kbn/cloud-chat-plugin/public'; import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; @@ -102,7 +101,6 @@ export const IntegrationsAppContext: React.FC<{ {children} - diff --git a/yarn.lock b/yarn.lock index 0d175c93031de..0ef9162c9863f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3096,10 +3096,6 @@ version "0.0.0" uid "" -"@kbn/cloud-chat-provider-plugin@link:x-pack/plugins/cloud_integrations/cloud_chat_provider": - version "0.0.0" - uid "" - "@kbn/cloud-data-migration-plugin@link:x-pack/plugins/cloud_integrations/cloud_data_migration": version "0.0.0" uid "" From 1a922752ae6fc4a8c59d425f097b231e6cd1c24f Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Wed, 14 Jun 2023 12:03:11 +0200 Subject: [PATCH 02/20] fix ts configs --- src/plugins/home/tsconfig.json | 1 - src/plugins/management/tsconfig.json | 1 - x-pack/plugins/cloud_integrations/cloud_chat/tsconfig.json | 1 - x-pack/plugins/data_visualizer/tsconfig.json | 1 - x-pack/plugins/enterprise_search/tsconfig.json | 1 - x-pack/plugins/fleet/tsconfig.json | 1 - 6 files changed, 6 deletions(-) diff --git a/src/plugins/home/tsconfig.json b/src/plugins/home/tsconfig.json index 46f098c18521e..904cf7194c390 100644 --- a/src/plugins/home/tsconfig.json +++ b/src/plugins/home/tsconfig.json @@ -30,7 +30,6 @@ "@kbn/ebt-tools", "@kbn/core-analytics-server", "@kbn/storybook", - "@kbn/cloud-chat-provider-plugin", ], "exclude": [ "target/**/*", diff --git a/src/plugins/management/tsconfig.json b/src/plugins/management/tsconfig.json index ff1289aa55356..1edc7f9a5e594 100644 --- a/src/plugins/management/tsconfig.json +++ b/src/plugins/management/tsconfig.json @@ -20,7 +20,6 @@ "@kbn/i18n-react", "@kbn/shared-ux-page-kibana-template", "@kbn/shared-ux-router", - "@kbn/cloud-chat-provider-plugin", ], "exclude": [ "target/**/*", diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/tsconfig.json b/x-pack/plugins/cloud_integrations/cloud_chat/tsconfig.json index 25401990c691e..6cc297a5b4361 100644 --- a/x-pack/plugins/cloud_integrations/cloud_chat/tsconfig.json +++ b/x-pack/plugins/cloud_integrations/cloud_chat/tsconfig.json @@ -19,7 +19,6 @@ "@kbn/i18n", "@kbn/ui-theme", "@kbn/config-schema", - "@kbn/cloud-chat-provider-plugin", ], "exclude": [ "target/**/*", diff --git a/x-pack/plugins/data_visualizer/tsconfig.json b/x-pack/plugins/data_visualizer/tsconfig.json index 515434256ca7d..4e49ec82b7f50 100644 --- a/x-pack/plugins/data_visualizer/tsconfig.json +++ b/x-pack/plugins/data_visualizer/tsconfig.json @@ -14,7 +14,6 @@ "kbn_references": [ "@kbn/ace", "@kbn/charts-plugin", - "@kbn/cloud-chat-plugin", "@kbn/cloud-plugin", "@kbn/core-execution-context-common", "@kbn/core", diff --git a/x-pack/plugins/enterprise_search/tsconfig.json b/x-pack/plugins/enterprise_search/tsconfig.json index 0ea008f3691f5..860d55933f6b3 100644 --- a/x-pack/plugins/enterprise_search/tsconfig.json +++ b/x-pack/plugins/enterprise_search/tsconfig.json @@ -21,7 +21,6 @@ "@kbn/kibana-react-plugin", "@kbn/usage-collection-plugin", "@kbn/cloud-plugin", - "@kbn/cloud-chat-plugin", "@kbn/infra-plugin", "@kbn/features-plugin", "@kbn/lens-plugin", diff --git a/x-pack/plugins/fleet/tsconfig.json b/x-pack/plugins/fleet/tsconfig.json index 499af010d076f..b08f72870b5d5 100644 --- a/x-pack/plugins/fleet/tsconfig.json +++ b/x-pack/plugins/fleet/tsconfig.json @@ -39,7 +39,6 @@ "@kbn/home-plugin", // requiredBundles from ./kibana.json - "@kbn/cloud-chat-plugin", "@kbn/kibana-react-plugin", "@kbn/es-ui-shared-plugin", "@kbn/infra-plugin", From 55a08dbdf489283f228465919a809841863af759 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 14 Jun 2023 10:09:21 +0000 Subject: [PATCH 03/20] [CI] Auto-commit changed files from 'node scripts/generate codeowners' --- .github/CODEOWNERS | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 7d57bd2924ba0..4eb11b9aa1c92 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -67,7 +67,6 @@ packages/kbn-ci-stats-reporter @elastic/kibana-operations packages/kbn-ci-stats-shipper-cli @elastic/kibana-operations packages/kbn-cli-dev-mode @elastic/kibana-operations x-pack/plugins/cloud_integrations/cloud_chat @elastic/kibana-core -x-pack/plugins/cloud_integrations/cloud_chat_provider @elastic/kibana-core x-pack/plugins/cloud_integrations/cloud_data_migration @elastic/platform-onboarding x-pack/plugins/cloud_defend @elastic/sec-cloudnative-integrations x-pack/plugins/cloud_integrations/cloud_experiments @elastic/kibana-core From 741bf1dc7e87afee7f57495d08df4c0d0e1e5837 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 14 Jun 2023 10:17:40 +0000 Subject: [PATCH 04/20] [CI] Auto-commit changed files from 'node scripts/build_plugin_list_docs' --- docs/developer/plugin-list.asciidoc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/developer/plugin-list.asciidoc b/docs/developer/plugin-list.asciidoc index 954cf3c69d308..264478293d77d 100644 --- a/docs/developer/plugin-list.asciidoc +++ b/docs/developer/plugin-list.asciidoc @@ -467,10 +467,6 @@ for inventory and topology purposes. |Integrates with DriftChat in order to provide live support to our Elastic Cloud users. This plugin should only run on Elastic Cloud. -|{kib-repo}blob/{branch}/x-pack/plugins/cloud_integrations/cloud_chat_provider/README.md[cloudChatProvider] -|This plugin exists as a workaround for using cloudChat plugin in plugins which can't have a direct dependency on security plugin. - - |{kib-repo}blob/{branch}/x-pack/plugins/cloud_integrations/cloud_data_migration/README.md[cloudDataMigration] |Static migration page where self-managed users can see text/copy about migrating to Elastic Cloud From 1de509bf7f405bed29a3b08118f52dbf0e34bda2 Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Wed, 14 Jun 2023 14:09:00 +0200 Subject: [PATCH 05/20] try to fix react import issue --- packages/core/chrome/core-chrome-browser/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/core/chrome/core-chrome-browser/tsconfig.json b/packages/core/chrome/core-chrome-browser/tsconfig.json index ef655cc44a14d..564d200b4dfc2 100644 --- a/packages/core/chrome/core-chrome-browser/tsconfig.json +++ b/packages/core/chrome/core-chrome-browser/tsconfig.json @@ -4,7 +4,8 @@ "outDir": "target/types", "types": [ "jest", - "node" + "node", + "react" ] }, "include": [ From 78d62f57cfb53a8d0c5228005b045f4f57a7c30a Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Wed, 14 Jun 2023 14:32:03 +0200 Subject: [PATCH 06/20] fix import --- packages/core/chrome/core-chrome-browser/src/contracts.ts | 2 +- packages/core/chrome/core-chrome-browser/tsconfig.json | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/core/chrome/core-chrome-browser/src/contracts.ts b/packages/core/chrome/core-chrome-browser/src/contracts.ts index 1218a2d679b11..13b7b7efc9349 100644 --- a/packages/core/chrome/core-chrome-browser/src/contracts.ts +++ b/packages/core/chrome/core-chrome-browser/src/contracts.ts @@ -7,7 +7,7 @@ */ import type { Observable } from 'rxjs'; -import type { ComponentType } from 'React'; +import type { ComponentType } from 'react'; import type { ChromeNavLink, ChromeNavLinks } from './nav_links'; import type { ChromeRecentlyAccessed } from './recently_accessed'; import type { ChromeDocTitle } from './doc_title'; diff --git a/packages/core/chrome/core-chrome-browser/tsconfig.json b/packages/core/chrome/core-chrome-browser/tsconfig.json index 564d200b4dfc2..ef655cc44a14d 100644 --- a/packages/core/chrome/core-chrome-browser/tsconfig.json +++ b/packages/core/chrome/core-chrome-browser/tsconfig.json @@ -4,8 +4,7 @@ "outDir": "target/types", "types": [ "jest", - "node", - "react" + "node" ] }, "include": [ From 0b0ec7d2c2858f22d87b6bf9ba69269ab5ef2d38 Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Tue, 27 Jun 2023 13:37:56 +0200 Subject: [PATCH 07/20] Merge branch 'main' of github.com:elastic/kibana into d/2023-06-14-global-drift --- .../plugins/observability/public/pages/overview/overview.tsx | 3 --- .../security_solution/public/overview/pages/landing.tsx | 2 -- 2 files changed, 5 deletions(-) diff --git a/x-pack/plugins/observability/public/pages/overview/overview.tsx b/x-pack/plugins/observability/public/pages/overview/overview.tsx index a938cdc98023e..5212897a5c53c 100644 --- a/x-pack/plugins/observability/public/pages/overview/overview.tsx +++ b/x-pack/plugins/observability/public/pages/overview/overview.tsx @@ -11,7 +11,6 @@ import { BoolQuery } from '@kbn/es-query'; import { i18n } from '@kbn/i18n'; import { AlertConsumers } from '@kbn/rule-data-utils'; import { useBreadcrumbs, useFetcher } from '@kbn/observability-shared-plugin/public'; -import { Chat } from '@kbn/cloud-chat-plugin/public'; import { useKibana } from '../../utils/kibana_react'; import { LoadingObservability } from '../../components/loading_observability'; @@ -241,8 +240,6 @@ export function OverviewPage() { {isDataAssistantFlyoutVisible ? ( setIsDataAssistantFlyoutVisible(false)} /> ) : null} - - ); } diff --git a/x-pack/plugins/security_solution/public/overview/pages/landing.tsx b/x-pack/plugins/security_solution/public/overview/pages/landing.tsx index f8aec1eb62f2f..5ce2bc36afb2e 100644 --- a/x-pack/plugins/security_solution/public/overview/pages/landing.tsx +++ b/x-pack/plugins/security_solution/public/overview/pages/landing.tsx @@ -6,7 +6,6 @@ */ import React, { memo } from 'react'; -import { Chat } from '@kbn/cloud-chat-plugin/public'; import { css } from '@emotion/react'; import { SpyRoute } from '../../common/utils/route/spy_routes'; import { SecurityPageName } from '../../../common/constants'; @@ -24,7 +23,6 @@ export const LandingPage = memo(() => { > -
From cafddafe95fa97a9f08bcbc212c8fdc06f78cc0f Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Wed, 5 Jul 2023 11:16:06 +0200 Subject: [PATCH 08/20] global drift poc wip --- .../src/application_service.tsx | 1 + .../src/types.ts | 6 + .../src/plugin_context.ts | 2 + src/core/public/styles/chrome/_banner.scss | 4 + .../cloud_chat/kibana.jsonc | 3 + .../cloud_chat/public/chat_icon.svg | 6 + .../public/components/chat/chat.tsx | 114 ++++++++++-------- .../public/components/chat/use_chat_config.ts | 25 +++- .../cloud_chat/public/plugin.tsx | 57 ++++++++- .../cloud_chat/public/services/index.tsx | 7 ++ x-pack/plugins/data_visualizer/kibana.jsonc | 1 - x-pack/plugins/observability/kibana.jsonc | 2 +- x-pack/plugins/security_solution/kibana.jsonc | 3 +- 13 files changed, 173 insertions(+), 58 deletions(-) create mode 100644 x-pack/plugins/cloud_integrations/cloud_chat/public/chat_icon.svg diff --git a/packages/core/application/core-application-browser-internal/src/application_service.tsx b/packages/core/application/core-application-browser-internal/src/application_service.tsx index 0c8207ca1d2f6..4c9618d48399c 100644 --- a/packages/core/application/core-application-browser-internal/src/application_service.tsx +++ b/packages/core/application/core-application-browser-internal/src/application_service.tsx @@ -220,6 +220,7 @@ export class ApplicationService { }, registerAppUpdater: (appUpdater$: Observable) => registerStatusUpdater(allApplicationsFilter, appUpdater$), + history: this.history!, }; } diff --git a/packages/core/application/core-application-browser-internal/src/types.ts b/packages/core/application/core-application-browser-internal/src/types.ts index e3231c39526cd..b7a06901a376b 100644 --- a/packages/core/application/core-application-browser-internal/src/types.ts +++ b/packages/core/application/core-application-browser-internal/src/types.ts @@ -43,6 +43,12 @@ export interface InternalApplicationSetup extends Pick ): void; + + /** + * The global history instance, exposed only to Core. + * @internal + */ + history: History; } /** @internal */ diff --git a/packages/core/plugins/core-plugins-browser-internal/src/plugin_context.ts b/packages/core/plugins/core-plugins-browser-internal/src/plugin_context.ts index de5bfd8562a69..33e27d54f0df9 100644 --- a/packages/core/plugins/core-plugins-browser-internal/src/plugin_context.ts +++ b/packages/core/plugins/core-plugins-browser-internal/src/plugin_context.ts @@ -73,6 +73,8 @@ export function createPluginSetupContext< application: { register: (app) => deps.application.register(plugin.opaqueId, app), registerAppUpdater: (statusUpdater$) => deps.application.registerAppUpdater(statusUpdater$), + // @ts-ignore, + history: deps.application.history, }, customBranding: deps.customBranding, fatalErrors: deps.fatalErrors, diff --git a/src/core/public/styles/chrome/_banner.scss b/src/core/public/styles/chrome/_banner.scss index 41ec7b08c6c04..05b231d8c8a76 100644 --- a/src/core/public/styles/chrome/_banner.scss +++ b/src/core/public/styles/chrome/_banner.scss @@ -21,3 +21,7 @@ top: $kbnHeaderBannerHeight + $euiHeaderHeightCompensation; } } + +.header__firstBar { + z-index: 1001; +} diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/kibana.jsonc b/x-pack/plugins/cloud_integrations/cloud_chat/kibana.jsonc index a8bbc4a8966ef..37edfba2ea1bc 100644 --- a/x-pack/plugins/cloud_integrations/cloud_chat/kibana.jsonc +++ b/x-pack/plugins/cloud_integrations/cloud_chat/kibana.jsonc @@ -15,6 +15,9 @@ "requiredPlugins": [ "cloud" ], + "requiredBundles": [ + "kibanaReact" + ], "optionalPlugins": [ "security" ] diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/public/chat_icon.svg b/x-pack/plugins/cloud_integrations/cloud_chat/public/chat_icon.svg new file mode 100644 index 0000000000000..5a16e8960aa9f --- /dev/null +++ b/x-pack/plugins/cloud_integrations/cloud_chat/public/chat_icon.svg @@ -0,0 +1,6 @@ + + + diff --git a/x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat/chat.tsx b/x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat/chat.tsx index 1a11542699ed3..fb5f464b60c4b 100644 --- a/x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat/chat.tsx +++ b/x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat/chat.tsx @@ -6,11 +6,11 @@ */ import React, { useRef, useState } from 'react'; -import { css } from '@emotion/react'; +// import { css } from '@emotion/react'; import { i18n } from '@kbn/i18n'; -import { EuiButtonEmpty } from '@elastic/eui'; -import { euiThemeVars } from '@kbn/ui-theme'; +// import { EuiButtonEmpty } from '@elastic/eui'; +// import { euiThemeVars } from '@kbn/ui-theme'; import { useChatConfig } from './use_chat_config'; @@ -39,54 +39,74 @@ export const Chat = ({ onHide = () => {}, onReady, onResize }: Props) => { const { isReady, isResized, style } = config; const { right } = style; - const buttonCSS = css` - bottom: ${euiThemeVars.euiSizeXS}; - position: fixed; - right: calc(${right} + ${euiThemeVars.euiSizeXS}); - visibility: ${isReady && isResized ? 'visible' : 'hidden'}; - `; + // clipPath: 'inset(40px 4px 72px 30px)', - const button = ( - { - onHide(); - setIsClosed(true); - }} - size="xs" - > - {i18n.translate('xpack.cloudChat.hideChatButtonLabel', { - defaultMessage: 'Hide chat', + return ( +