diff --git a/x-pack/plugins/fleet/public/applications/fleet/app.tsx b/x-pack/plugins/fleet/public/applications/fleet/app.tsx index 35098941434e1..99a0d8ffbdbbe 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/app.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/app.tsx @@ -7,10 +7,11 @@ import React, { memo, useEffect, useState } from 'react'; import type { AppMountParameters } from '@kbn/core/public'; -import { EuiErrorBoundary, EuiPortal } from '@elastic/eui'; +import { EuiPortal } from '@elastic/eui'; import type { History } from 'history'; import { Redirect, useRouteMatch } from 'react-router-dom'; import { Router, Routes, Route } from '@kbn/shared-ux-router'; +import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import useObservable from 'react-use/lib/useObservable'; @@ -19,8 +20,6 @@ import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; import type { TopNavMenuData } from '@kbn/navigation-plugin/public'; -import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; - import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app'; import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common'; @@ -171,7 +170,6 @@ export const FleetAppContext: React.FC<{ history: AppMountParameters['history']; kibanaVersion: string; extensions: UIExtensionsStorage; - theme$: AppMountParameters['theme$']; /** For testing purposes only */ routerHistory?: History; fleetStatus?: FleetStatusProviderProps; @@ -184,49 +182,41 @@ export const FleetAppContext: React.FC<{ history, kibanaVersion, extensions, - routerHistory, - theme$, + routerHistory: _routerHistory, fleetStatus, }) => { - const darkModeObservable = useObservable(theme$); + const darkModeObservable = useObservable(startServices.theme.theme$); const isDarkMode = darkModeObservable && darkModeObservable.darkMode; return ( - - - - - - - - - - - - - - - {children} - - - - - - - - - - + + + + + + + + + + + + + {children} + + + + + + + + - - + + ); } ); diff --git a/x-pack/plugins/fleet/public/applications/fleet/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/index.tsx index bf3cba4f8d8ec..48d74842c4eb3 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/index.tsx @@ -39,7 +39,6 @@ interface FleetAppProps { kibanaVersion: string; extensions: UIExtensionsStorage; setHeaderActionMenu: AppMountParameters['setHeaderActionMenu']; - theme$: AppMountParameters['theme$']; } const FleetApp = ({ startServices, @@ -48,7 +47,6 @@ const FleetApp = ({ kibanaVersion, extensions, setHeaderActionMenu, - theme$, }: FleetAppProps) => { return ( @@ -68,7 +65,7 @@ const FleetApp = ({ export function renderApp( startServices: FleetStartServices, - { element, history, setHeaderActionMenu, theme$ }: AppMountParameters, + { element, history, setHeaderActionMenu }: AppMountParameters, config: FleetConfigType, kibanaVersion: string, extensions: UIExtensionsStorage @@ -81,7 +78,6 @@ export function renderApp( kibanaVersion={kibanaVersion} extensions={extensions} setHeaderActionMenu={setHeaderActionMenu} - theme$={theme$} />, element ); diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.test.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.test.tsx index 450692f2201c3..a79f43c461c0c 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.test.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.test.tsx @@ -355,7 +355,7 @@ describe('edit package policy page', () => { render(); await waitFor(() => { - expect(renderResult.getByTestId('euiErrorBoundary')).toBeVisible(); + expect(renderResult.getByTestId('errorBoundaryFatalHeader')).toBeVisible(); }); }); diff --git a/x-pack/plugins/fleet/public/applications/integrations/app.tsx b/x-pack/plugins/fleet/public/applications/integrations/app.tsx index b7272481c015e..fdd924799255c 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/app.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/app.tsx @@ -7,7 +7,7 @@ import React, { memo } from 'react'; import type { AppMountParameters } from '@kbn/core/public'; -import { EuiErrorBoundary, EuiPortal } from '@elastic/eui'; +import { EuiPortal } from '@elastic/eui'; import type { History } from 'history'; import { Redirect } from 'react-router-dom'; import { Router, Routes, Route } from '@kbn/shared-ux-router'; @@ -16,11 +16,10 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; +import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; import { RedirectAppLinks } from '@kbn/shared-ux-link-redirect-app'; import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common'; -import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; - import type { FleetConfigType, FleetStartServices } from '../../plugin'; import { @@ -59,7 +58,6 @@ export const IntegrationsAppContext: React.FC<{ kibanaVersion: string; extensions: UIExtensionsStorage; setHeaderActionMenu: AppMountParameters['setHeaderActionMenu']; - theme$: AppMountParameters['theme$']; /** For testing purposes only */ routerHistory?: History; // TODO remove fleetStatus?: FleetStatusProviderProps; @@ -73,59 +71,53 @@ export const IntegrationsAppContext: React.FC<{ kibanaVersion, extensions, setHeaderActionMenu, - theme$, fleetStatus, }) => { - const theme = useObservable(theme$); + const theme = useObservable(startServices.theme.theme$); const isDarkMode = theme && theme.darkMode; const CloudContext = startServices.cloud?.CloudContextProvider || EmptyContext; return ( - - + + - - - - - - - - - - - - - - - - - {children} - - - - - - - - - - - - - - + + + + + + + + + + + + + + + {children} + + + + + + + + + + + + - - + + ); } ); diff --git a/x-pack/plugins/fleet/public/applications/integrations/components/header/header.tsx b/x-pack/plugins/fleet/public/applications/integrations/components/header/header.tsx index 782d06d319d99..6ca3dc473e10c 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/components/header/header.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/components/header/header.tsx @@ -10,18 +10,20 @@ import { EuiHeaderSectionItem, EuiHeaderSection, EuiHeaderLinks } from '@elastic import type { AppMountParameters } from '@kbn/core/public'; +import type { FleetStartServices } from '../../../../plugin'; + import { HeaderPortal } from './header_portal'; import { DeploymentDetails } from './deployment_details'; export const IntegrationsHeader = ({ setHeaderActionMenu, - theme$, + startServices, }: { setHeaderActionMenu: AppMountParameters['setHeaderActionMenu']; - theme$: AppMountParameters['theme$']; + startServices: Pick; }) => { return ( - + diff --git a/x-pack/plugins/fleet/public/applications/integrations/components/header/header_portal.tsx b/x-pack/plugins/fleet/public/applications/integrations/components/header/header_portal.tsx index c64b290d6f6df..9c2c085ed42e1 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/components/header/header_portal.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/components/header/header_portal.tsx @@ -10,20 +10,22 @@ import type { FC } from 'react'; import React, { useEffect, useMemo } from 'react'; import { createHtmlPortalNode, InPortal, OutPortal } from 'react-reverse-portal'; -import { toMountPoint } from '@kbn/kibana-react-plugin/public'; +import { toMountPoint } from '@kbn/react-kibana-mount'; + +import type { FleetStartServices } from '../../../../plugin'; export interface Props { children: React.ReactNode; setHeaderActionMenu: AppMountParameters['setHeaderActionMenu']; - theme$: AppMountParameters['theme$']; + startServices: Pick; } -export const HeaderPortal: FC = ({ children, setHeaderActionMenu, theme$ }) => { +export const HeaderPortal: FC = ({ children, setHeaderActionMenu, startServices }) => { const portalNode = useMemo(() => createHtmlPortalNode(), []); useEffect(() => { setHeaderActionMenu((element) => { - const mount = toMountPoint(, { theme$ }); + const mount = toMountPoint(, startServices); return mount(element); }); @@ -31,7 +33,7 @@ export const HeaderPortal: FC = ({ children, setHeaderActionMenu, theme$ portalNode.unmount(); setHeaderActionMenu(undefined); }; - }, [portalNode, setHeaderActionMenu, theme$]); + }, [portalNode, setHeaderActionMenu, startServices]); return {children}; }; diff --git a/x-pack/plugins/fleet/public/applications/integrations/hooks/use_confirm_force_install.tsx b/x-pack/plugins/fleet/public/applications/integrations/hooks/use_confirm_force_install.tsx index 1adacb5fe733d..200f1ee010b0d 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/hooks/use_confirm_force_install.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/hooks/use_confirm_force_install.tsx @@ -5,8 +5,8 @@ * 2.0. */ -import type { DocLinksStart, OverlayStart } from '@kbn/core/public'; -import { toMountPoint } from '@kbn/kibana-react-plugin/public'; +import type { CoreStart } from '@kbn/core/public'; +import { toMountPoint } from '@kbn/react-kibana-mount'; import React, { useCallback } from 'react'; @@ -15,15 +15,13 @@ import { ConfirmForceInstallModal } from '../components'; const confirmForceInstall = ({ pkg, - overlays, - docLinks, + core, }: { pkg: { name: string; version: string }; - overlays: OverlayStart; - docLinks: DocLinksStart; + core: CoreStart; }): Promise => new Promise((resolve) => { - const session = overlays.openModal( + const session = core.overlays.openModal( toMountPoint( + docLinks={core.docLinks} + />, + core ) ); }); export const useConfirmForceInstall = () => { - const { overlays, docLinks } = useStartServices(); + const core = useStartServices(); return useCallback( - (pkg: { name: string; version: string }) => confirmForceInstall({ pkg, overlays, docLinks }), - [docLinks, overlays] + (pkg: { name: string; version: string }) => confirmForceInstall({ pkg, core }), + [core] ); }; diff --git a/x-pack/plugins/fleet/public/applications/integrations/hooks/use_confirm_open_unverified.tsx b/x-pack/plugins/fleet/public/applications/integrations/hooks/use_confirm_open_unverified.tsx index 1d36a13d319a8..a6e06d3206115 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/hooks/use_confirm_open_unverified.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/hooks/use_confirm_open_unverified.tsx @@ -5,26 +5,31 @@ * 2.0. */ -import type { DocLinksStart, OverlayStart } from '@kbn/core/public'; -import { toMountPoint } from '@kbn/kibana-react-plugin/public'; +import { toMountPoint } from '@kbn/react-kibana-mount'; import React, { useCallback } from 'react'; // Direct imports are important here, importing all hooks breaks unit tests // and increases bundle size because this is imported on first page load +import type { FleetStartServices } from '../../../plugin'; + import { useStartServices } from '../../../hooks/use_core'; import { ConfirmOpenUnverifiedModal } from '../components/confirm_open_unverified_modal'; +type StartServicesConfirmOpen = Pick< + FleetStartServices, + 'docLinks' | 'overlays' | 'analytics' | 'i18n' | 'theme' +>; + const confirmOpenUnverified = ({ pkgName, - overlays, - docLinks, + fleetServices, }: { pkgName: string; - overlays: OverlayStart; - docLinks: DocLinksStart; + fleetServices: StartServicesConfirmOpen; }): Promise => new Promise((resolve) => { + const { overlays, docLinks, ...startServices } = fleetServices; const session = overlays.openModal( toMountPoint( + />, + startServices ) ); }); export const useConfirmOpenUnverified = () => { - const { overlays, docLinks } = useStartServices(); + const fleetServices = useStartServices(); return useCallback( - (pkgName: string) => confirmOpenUnverified({ pkgName, overlays, docLinks }), - [docLinks, overlays] + (pkgName: string) => confirmOpenUnverified({ pkgName, fleetServices }), + [fleetServices] ); }; diff --git a/x-pack/plugins/fleet/public/applications/integrations/hooks/use_package_install.test.tsx b/x-pack/plugins/fleet/public/applications/integrations/hooks/use_package_install.test.tsx index d7bfd56f8a8e1..6040c3bacd70f 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/hooks/use_package_install.test.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/hooks/use_package_install.test.tsx @@ -7,14 +7,22 @@ import React from 'react'; import { act, type WrapperComponent } from '@testing-library/react-hooks'; +import { coreMock } from '@kbn/core/public/mocks'; import { createIntegrationsTestRendererMock } from '../../../mock'; import { useInstallPackage, PackageInstallProvider } from './use_package_install'; describe('usePackageInstall', () => { + const coreStart = coreMock.createStart(); + + const addErrorSpy = jest.spyOn(coreStart.notifications.toasts, 'addError'); + const addSuccessSpy = jest.spyOn(coreStart.notifications.toasts, 'addSuccess'); + beforeEach(() => { createIntegrationsTestRendererMock(); + addErrorSpy.mockReset(); + addSuccessSpy.mockReset(); }); describe('useInstallPackage', () => { @@ -40,14 +48,8 @@ describe('usePackageInstall', () => { throw error; }) as any); - const notifications = renderer.startServices.notifications; const wrapper: WrapperComponent = ({ children }) => ( - - {children} - + {children} ); const { result } = renderer.renderHook(() => useInstallPackage(), wrapper); @@ -55,12 +57,11 @@ describe('usePackageInstall', () => { return { installPackage, - notifications, }; } it('should work for install', async () => { - const { notifications, installPackage } = createRenderer(); + const { installPackage } = createRenderer(); let res: boolean | undefined; await act(async () => { res = await installPackage({ @@ -70,14 +71,14 @@ describe('usePackageInstall', () => { }); }); - expect(notifications.toasts.addError).not.toBeCalled(); - expect(notifications.toasts.addSuccess).toBeCalled(); + expect(addErrorSpy).not.toBeCalled(); + expect(addSuccessSpy).toBeCalled(); expect(res).toBeTruthy(); }); it('should work for upgrade', async () => { - const { notifications, installPackage } = createRenderer(); + const { installPackage } = createRenderer(); let res: boolean | undefined; await act(async () => { res = await installPackage({ @@ -88,14 +89,14 @@ describe('usePackageInstall', () => { }); }); - expect(notifications.toasts.addError).not.toBeCalled(); - expect(notifications.toasts.addSuccess).toBeCalled(); + expect(addErrorSpy).not.toBeCalled(); + expect(addSuccessSpy).toBeCalled(); expect(res).toBeTruthy(); }); it('should handle install error', async () => { - const { notifications, installPackage } = createRenderer(); + const { installPackage } = createRenderer(); let res: boolean | undefined; await act(async () => { @@ -106,8 +107,8 @@ describe('usePackageInstall', () => { }); }); - expect(notifications.toasts.addSuccess).not.toBeCalled(); - expect(notifications.toasts.addError).toBeCalled(); + expect(addSuccessSpy).not.toBeCalled(); + expect(addErrorSpy).toBeCalled(); expect(res).toBeFalsy(); }); diff --git a/x-pack/plugins/fleet/public/applications/integrations/hooks/use_package_install.tsx b/x-pack/plugins/fleet/public/applications/integrations/hooks/use_package_install.tsx index c238a9b48bcbb..f60e887e25fbb 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/hooks/use_package_install.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/hooks/use_package_install.tsx @@ -13,13 +13,10 @@ import React, { useCallback, useState } from 'react'; import { useHistory } from 'react-router-dom'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; -import type { NotificationsStart } from '@kbn/core/public'; -import type { Observable } from 'rxjs'; -import type { CoreTheme } from '@kbn/core/public'; - -import { toMountPoint } from '@kbn/kibana-react-plugin/public'; +import { toMountPoint } from '@kbn/react-kibana-mount'; import type { PackageInfo } from '../../../types'; +import type { FleetStartServices } from '../../../plugin'; import { sendInstallPackage, sendRemovePackage, useLink } from '../../../hooks'; import { InstallStatus } from '../../../types'; @@ -27,6 +24,8 @@ import { isVerificationError } from '../services'; import { useConfirmForceInstall } from '.'; +type StartServices = Pick; + interface PackagesInstall { [key: string]: PackageInstallItem; } @@ -43,13 +42,7 @@ type InstallPackageProps = Pick & { }; type SetPackageInstallStatusProps = Pick & PackageInstallItem; -function usePackageInstall({ - notifications, - theme$, -}: { - notifications: NotificationsStart; - theme$: Observable; -}) { +function usePackageInstall({ startServices }: { startServices: StartServices }) { const history = useHistory(); const { getPath } = useLink(); const [packages, setPackage] = useState({}); @@ -68,6 +61,8 @@ function usePackageInstall({ [] ); + const { notifications } = startServices; + const getPackageInstallStatus = useCallback( (pkg: string): PackageInstallItem => { return packages[pkg]; @@ -115,7 +110,7 @@ function usePackageInstall({ defaultMessage="Reinstalled {title}" values={{ title }} />, - { theme$ } + startServices ), text: toMountPoint( , - { theme$ } + startServices ), }); } else if (isUpgrade) { @@ -134,7 +129,7 @@ function usePackageInstall({ defaultMessage="Upgraded {title}" values={{ title }} />, - { theme$ } + startServices ), text: toMountPoint( , - { theme$ } + startServices ), }); } else { @@ -153,7 +148,7 @@ function usePackageInstall({ defaultMessage="Installed {title}" values={{ title }} />, - { theme$ } + startServices ), text: toMountPoint( , - { theme$ } + startServices ), }); } @@ -192,14 +187,7 @@ function usePackageInstall({ return true; }, // eslint-disable-next-line react-hooks/exhaustive-deps - [ - getPackageInstallStatus, - setPackageInstallStatus, - notifications.toasts, - theme$, - getPath, - history, - ] + [getPackageInstallStatus, setPackageInstallStatus, startServices, getPath, history] ); const uninstallPackage = useCallback( @@ -221,14 +209,14 @@ function usePackageInstall({ defaultMessage="Failed to uninstall {title} package" values={{ title }} />, - { theme$ } + startServices ), text: toMountPoint( , - { theme$ } + startServices ), iconType: 'error', }); @@ -242,7 +230,7 @@ function usePackageInstall({ defaultMessage="Uninstalled {title}" values={{ title }} />, - { theme$ } + startServices ), text: toMountPoint( , - { theme$ } + startServices ), }); if (redirectToVersion !== version) { @@ -261,7 +249,7 @@ function usePackageInstall({ } } }, - [notifications.toasts, setPackageInstallStatus, getPath, history, theme$] + [notifications.toasts, setPackageInstallStatus, getPath, history, startServices] ); return { diff --git a/x-pack/plugins/fleet/public/applications/integrations/index.tsx b/x-pack/plugins/fleet/public/applications/integrations/index.tsx index 8dfef726157ba..ae9b7e5528d93 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/index.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/index.tsx @@ -40,7 +40,6 @@ interface IntegrationsAppProps { kibanaVersion: string; extensions: UIExtensionsStorage; setHeaderActionMenu: AppMountParameters['setHeaderActionMenu']; - theme$: AppMountParameters['theme$']; } const IntegrationsApp = ({ basepath, @@ -50,7 +49,6 @@ const IntegrationsApp = ({ kibanaVersion, extensions, setHeaderActionMenu, - theme$, }: IntegrationsAppProps) => { return ( @@ -70,7 +67,7 @@ const IntegrationsApp = ({ export function renderApp( startServices: FleetStartServices, - { element, appBasePath, history, setHeaderActionMenu, theme$ }: AppMountParameters, + { element, appBasePath, history, setHeaderActionMenu }: AppMountParameters, config: FleetConfigType, kibanaVersion: string, extensions: UIExtensionsStorage, @@ -86,7 +83,6 @@ export function renderApp( kibanaVersion={kibanaVersion} extensions={extensions} setHeaderActionMenu={setHeaderActionMenu} - theme$={theme$} /> , element diff --git a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.tsx index bc9ae4ebe164c..8e594f6c8d7d9 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/index.tsx @@ -783,7 +783,7 @@ export function Detail() { /> - + diff --git a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/settings/settings.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/settings/settings.tsx index adeb17a5efdcc..5c7d73f3e6794 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/settings/settings.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/settings/settings.tsx @@ -23,14 +23,12 @@ import { import { i18n } from '@kbn/i18n'; -import type { Observable } from 'rxjs'; -import type { CoreTheme } from '@kbn/core/public'; - import { getNumTransformAssets, TransformInstallWithCurrentUserPermissionCallout, } from '../../../../../../../components/transform_install_as_current_user_callout'; +import type { FleetStartServices } from '../../../../../../../plugin'; import type { PackageInfo } from '../../../../../types'; import { InstallStatus } from '../../../../../types'; import { @@ -117,10 +115,10 @@ const LatestVersionLink = ({ name, version }: { name: string; version: string }) interface Props { packageInfo: PackageInfo; - theme$: Observable; + startServices: Pick; } -export const SettingsPage: React.FC = memo(({ packageInfo, theme$ }: Props) => { +export const SettingsPage: React.FC = memo(({ packageInfo, startServices }: Props) => { const { name, title, latestVersion, version, keepPoliciesUpToDate } = packageInfo; const [isUpgradingPackagePolicies, setIsUpgradingPackagePolicies] = useState(false); const [isChangelogModalOpen, setIsChangelogModalOpen] = useState(false); @@ -339,7 +337,7 @@ export const SettingsPage: React.FC = memo(({ packageInfo, theme$ }: Prop dryRunData={dryRunData} isUpgradingPackagePolicies={isUpgradingPackagePolicies} setIsUpgradingPackagePolicies={setIsUpgradingPackagePolicies} - theme$={theme$} + startServices={startServices} />

diff --git a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/settings/update_button.tsx b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/settings/update_button.tsx index a5cb7e56e511a..d1f82c7a8b852 100644 --- a/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/settings/update_button.tsx +++ b/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/detail/settings/update_button.tsx @@ -18,11 +18,10 @@ import { EuiConfirmModal, EuiSpacer, } from '@elastic/eui'; -import type { Observable } from 'rxjs'; -import type { CoreTheme } from '@kbn/core/public'; -import { toMountPoint } from '@kbn/kibana-react-plugin/public'; +import { toMountPoint } from '@kbn/react-kibana-mount'; +import type { FleetStartServices } from '../../../../../../../plugin'; import type { PackageInfo, UpgradePackagePolicyDryRunResponse, @@ -45,7 +44,7 @@ interface UpdateButtonProps extends Pick>; - theme$: Observable; + startServices: Pick; } /* @@ -77,7 +76,7 @@ export const UpdateButton: React.FunctionComponent = ({ setIsUpgradingPackagePolicies = () => {}, title, version, - theme$, + startServices, }) => { const history = useHistory(); const { getPath } = useLink(); @@ -185,7 +184,7 @@ export const UpdateButton: React.FunctionComponent = ({ defaultMessage="Updated {title} and upgraded policies" values={{ title }} />, - { theme$ } + startServices ), text: toMountPoint( = ({ defaultMessage="Successfully updated {title} and upgraded policies" values={{ title }} />, - { theme$ } + startServices ), }); @@ -230,7 +229,7 @@ export const UpdateButton: React.FunctionComponent = ({ packagePolicyIds, dryRunData, notifications.toasts, - theme$, + startServices, navigateToNewSettingsPage, ]); diff --git a/x-pack/plugins/fleet/public/components/devtools_request_flyout/devtools_request_flyout.tsx b/x-pack/plugins/fleet/public/components/devtools_request_flyout/devtools_request_flyout.tsx index b550202b8326f..955d9dd39b1b4 100644 --- a/x-pack/plugins/fleet/public/components/devtools_request_flyout/devtools_request_flyout.tsx +++ b/x-pack/plugins/fleet/public/components/devtools_request_flyout/devtools_request_flyout.tsx @@ -12,7 +12,8 @@ import type { EuiButtonEmptyProps } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n-react'; import { ViewApiRequestFlyout } from '@kbn/es-ui-shared-plugin/public'; -import { KibanaContextProvider, toMountPoint } from '@kbn/kibana-react-plugin/public'; +import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; +import { toMountPoint } from '@kbn/react-kibana-mount'; import { useStartServices } from '../../hooks'; @@ -41,7 +42,7 @@ export const DevtoolsRequestFlyoutButton: React.FunctionComponent< description={description} /> , - { theme$: services.theme.theme$ } + services ) ); diff --git a/x-pack/plugins/fleet/public/mock/create_test_renderer.tsx b/x-pack/plugins/fleet/public/mock/create_test_renderer.tsx index 2a122aff23db2..ded8351892e2e 100644 --- a/x-pack/plugins/fleet/public/mock/create_test_renderer.tsx +++ b/x-pack/plugins/fleet/public/mock/create_test_renderer.tsx @@ -15,8 +15,6 @@ import type { RenderHookResult } from '@testing-library/react-hooks'; import { Router } from '@kbn/shared-ux-router'; import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; -import { themeServiceMock } from '@kbn/core/public/mocks'; - import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; import type { ScopedHistory } from '@kbn/core/public'; import { CoreScopedHistory } from '@kbn/core/public'; @@ -103,7 +101,6 @@ export const createFleetTestRendererMock = (): TestRenderer => { kibanaVersion={testRendererMocks.kibanaVersion} extensions={extensions} routerHistory={testRendererMocks.history} - theme$={themeServiceMock.createTheme$()} fleetStatus={{ enabled: true, isLoading: false, @@ -167,7 +164,6 @@ export const createIntegrationsTestRendererMock = (): TestRenderer => { kibanaVersion={testRendererMocks.kibanaVersion} extensions={extensions} routerHistory={testRendererMocks.history} - theme$={themeServiceMock.createTheme$()} setHeaderActionMenu={() => {}} fleetStatus={{ enabled: true, diff --git a/x-pack/plugins/fleet/public/plugin.ts b/x-pack/plugins/fleet/public/plugin.ts index 3a22a8bc5b5a9..ec1ead9aabd94 100644 --- a/x-pack/plugins/fleet/public/plugin.ts +++ b/x-pack/plugins/fleet/public/plugin.ts @@ -51,6 +51,8 @@ import type { GuidedOnboardingPluginStart } from '@kbn/guided-onboarding-plugin/ import type { DashboardStart } from '@kbn/dashboard-plugin/public'; +import { Subject } from 'rxjs'; + import type { FleetAuthz } from '../common'; import { appRoutesService, INTEGRATIONS_PLUGIN_ID, PLUGIN_ID, setupRouteService } from '../common'; import { @@ -85,7 +87,6 @@ import type { import { LazyCustomLogsAssetsExtension } from './lazy_custom_logs_assets_extension'; import { setCustomIntegrations, setCustomIntegrationsStart } from './services/custom_integrations'; import { getFleetDeepLinks } from './deep_links'; -import { Subject } from 'rxjs'; export type { FleetConfigType } from '../common/types'; @@ -193,7 +194,7 @@ export class FleetPlugin implements Plugin