diff --git a/x-pack/plugins/security_solution/public/app/app.tsx b/x-pack/plugins/security_solution/public/app/app.tsx index 51b48abddc92f..7c83b49431683 100644 --- a/x-pack/plugins/security_solution/public/app/app.tsx +++ b/x-pack/plugins/security_solution/public/app/app.tsx @@ -11,12 +11,11 @@ import React, { memo } from 'react'; import type { Store, Action } from 'redux'; import { Provider as ReduxStoreProvider } from 'react-redux'; -import { KibanaThemeProvider } from '@kbn/kibana-react-plugin/public'; +import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; import type { AppMountParameters } from '@kbn/core/public'; import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common'; import { CellActionsProvider } from '@kbn/cell-actions'; -import { KibanaErrorBoundary, KibanaErrorBoundaryProvider } from '@kbn/shared-ux-error-boundary'; import { NavigationProvider } from '@kbn/security-solution-navigation'; import { UpsellingProvider } from '../common/components/upselling_provider'; import { ManageUserInfo } from '../detections/components/user_info'; @@ -43,8 +42,6 @@ interface StartAppComponent { const StartAppComponent: FC = ({ children, history, store, theme$ }) => { const services = useKibana().services; const { - i18n, - analytics, application: { capabilities }, uiActions, upselling, @@ -53,43 +50,37 @@ const StartAppComponent: FC = ({ children, history, store, th const darkMode = useDarkMode(); return ( - - - - - - - - - - - - - - - - - {children} - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + {children} + + + + + + + + + + + + + + + ); }; diff --git a/x-pack/plugins/security_solution/public/common/components/sourcerer/alerts_sourcerer.test.tsx b/x-pack/plugins/security_solution/public/common/components/sourcerer/alerts_sourcerer.test.tsx index 6d37aff3c804e..223afb3918422 100644 --- a/x-pack/plugins/security_solution/public/common/components/sourcerer/alerts_sourcerer.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/sourcerer/alerts_sourcerer.test.tsx @@ -31,8 +31,8 @@ jest.mock('react-redux', () => { }; }); -jest.mock('@kbn/kibana-react-plugin/public', () => { - const original = jest.requireActual('@kbn/kibana-react-plugin/public'); +jest.mock('@kbn/react-kibana-mount', () => { + const original = jest.requireActual('@kbn/react-kibana-mount'); return { ...original, diff --git a/x-pack/plugins/security_solution/public/common/components/sourcerer/index.test.tsx b/x-pack/plugins/security_solution/public/common/components/sourcerer/index.test.tsx index f0770b74a9caf..3ed7c87590354 100644 --- a/x-pack/plugins/security_solution/public/common/components/sourcerer/index.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/sourcerer/index.test.tsx @@ -37,8 +37,8 @@ jest.mock('react-redux', () => { }; }); -jest.mock('@kbn/kibana-react-plugin/public', () => { - const original = jest.requireActual('@kbn/kibana-react-plugin/public'); +jest.mock('@kbn/react-kibana-mount', () => { + const original = jest.requireActual('@kbn/react-kibana-mount'); return { ...original, diff --git a/x-pack/plugins/security_solution/public/common/components/sourcerer/misc.test.tsx b/x-pack/plugins/security_solution/public/common/components/sourcerer/misc.test.tsx index 6573dc4d8fb05..b90627d1e8d68 100644 --- a/x-pack/plugins/security_solution/public/common/components/sourcerer/misc.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/sourcerer/misc.test.tsx @@ -38,8 +38,8 @@ jest.mock('react-redux', () => { }; }); -jest.mock('@kbn/kibana-react-plugin/public', () => { - const original = jest.requireActual('@kbn/kibana-react-plugin/public'); +jest.mock('@kbn/react-kibana-mount', () => { + const original = jest.requireActual('@kbn/react-kibana-mount'); return { ...original, diff --git a/x-pack/plugins/security_solution/public/common/components/sourcerer/sourcerer_integration.test.tsx b/x-pack/plugins/security_solution/public/common/components/sourcerer/sourcerer_integration.test.tsx index 749800194ac91..753b9324d38f0 100644 --- a/x-pack/plugins/security_solution/public/common/components/sourcerer/sourcerer_integration.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/sourcerer/sourcerer_integration.test.tsx @@ -34,8 +34,8 @@ jest.mock('react-redux', () => { }; }); -jest.mock('@kbn/kibana-react-plugin/public', () => { - const original = jest.requireActual('@kbn/kibana-react-plugin/public'); +jest.mock('@kbn/react-kibana-mount', () => { + const original = jest.requireActual('@kbn/react-kibana-mount'); return { ...original, diff --git a/x-pack/plugins/security_solution/public/common/components/sourcerer/timeline_sourcerer.test.tsx b/x-pack/plugins/security_solution/public/common/components/sourcerer/timeline_sourcerer.test.tsx index 878e88c88a5fb..b89eae2be49eb 100644 --- a/x-pack/plugins/security_solution/public/common/components/sourcerer/timeline_sourcerer.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/sourcerer/timeline_sourcerer.test.tsx @@ -32,8 +32,8 @@ jest.mock('react-redux', () => { }; }); -jest.mock('@kbn/kibana-react-plugin/public', () => { - const original = jest.requireActual('@kbn/kibana-react-plugin/public'); +jest.mock('@kbn/react-kibana-mount', () => { + const original = jest.requireActual('@kbn/react-kibana-mount'); return { ...original, diff --git a/x-pack/plugins/security_solution/public/common/components/sourcerer/use_update_data_view.tsx b/x-pack/plugins/security_solution/public/common/components/sourcerer/use_update_data_view.tsx index 100ad09cc6024..49c0468d51cbf 100644 --- a/x-pack/plugins/security_solution/public/common/components/sourcerer/use_update_data_view.tsx +++ b/x-pack/plugins/security_solution/public/common/components/sourcerer/use_update_data_view.tsx @@ -8,7 +8,7 @@ import React, { useCallback } from 'react'; import { EuiLink } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; -import { toMountPoint } from '@kbn/kibana-react-plugin/public'; +import { toMountPoint } from '@kbn/react-kibana-mount'; import { useKibana } from '../../lib/kibana'; import { DEFAULT_INDEX_KEY } from '../../../../common/constants'; import * as i18n from './translations'; @@ -19,7 +19,7 @@ import { ensurePatternFormat } from '../../../../common/utils/sourcerer'; export const useUpdateDataView = ( onOpenAndReset: () => void ): ((missingPatterns: string[]) => Promise) => { - const { theme, uiSettings } = useKibana().services; + const { uiSettings, ...startServices } = useKibana().services; const { addSuccess, addError } = useAppToasts(); return useCallback( async (missingPatterns: string[]): Promise => { @@ -40,8 +40,8 @@ export const useUpdateDataView = ( if (isUiSettingsSuccess) { addSuccess({ color: 'success', - title: toMountPoint(i18n.SUCCESS_TOAST_TITLE, { theme$: theme.theme$ }), - text: toMountPoint(, { theme$: theme.theme$ }), + title: toMountPoint(i18n.SUCCESS_TOAST_TITLE, startServices), + text: toMountPoint(, startServices), iconType: undefined, toastLifeTimeMs: 600000, }); @@ -67,6 +67,6 @@ export const useUpdateDataView = ( }); return false; }, - [addError, addSuccess, onOpenAndReset, theme.theme$, uiSettings] + [addError, addSuccess, onOpenAndReset, uiSettings, startServices] ); }; diff --git a/x-pack/plugins/security_solution/public/common/components/visualization_actions/use_save_to_library.tsx b/x-pack/plugins/security_solution/public/common/components/visualization_actions/use_save_to_library.tsx index 158b30979881a..a47195f8e57bb 100644 --- a/x-pack/plugins/security_solution/public/common/components/visualization_actions/use_save_to_library.tsx +++ b/x-pack/plugins/security_solution/public/common/components/visualization_actions/use_save_to_library.tsx @@ -21,7 +21,7 @@ export const useSaveToLibrary = ({ }: { attributes: LensAttributes | undefined | null; }) => { - const { lens, theme, i18n } = useKibana().services; + const { lens, ...startServices } = useKibana().services; const { SaveModalComponent, canUseEditor } = lens; const getSecuritySolutionUrl = useGetSecuritySolutionUrl(); const { redirectTo, getEditOrCreateDashboardPath } = useRedirectToDashboardFromLens({ @@ -45,11 +45,11 @@ export const useSaveToLibrary = ({ } redirectTo={redirectTo} />, - { theme, i18n } + startServices ); mount(targetDomElement); - }, [SaveModalComponent, attributes, getEditOrCreateDashboardPath, i18n, redirectTo, theme]); + }, [SaveModalComponent, attributes, getEditOrCreateDashboardPath, redirectTo, startServices]); const disableVisualizations = useMemo( () => !canUseEditor() || attributes == null, diff --git a/x-pack/plugins/security_solution/public/common/mock/endpoint/app_root_provider.tsx b/x-pack/plugins/security_solution/public/common/mock/endpoint/app_root_provider.tsx index e32297f729ec3..57a23c249201b 100644 --- a/x-pack/plugins/security_solution/public/common/mock/endpoint/app_root_provider.tsx +++ b/x-pack/plugins/security_solution/public/common/mock/endpoint/app_root_provider.tsx @@ -8,12 +8,12 @@ import type { ReactNode } from 'react'; import React, { memo } from 'react'; import { Provider } from 'react-redux'; -import { I18nProvider } from '@kbn/i18n-react'; import { Router } from '@kbn/shared-ux-router'; import type { History } from 'history'; import useObservable from 'react-use/lib/useObservable'; import type { Store } from 'redux'; import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common'; +import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; import type { CoreStart } from '@kbn/core/public'; import { NavigationProvider } from '@kbn/security-solution-navigation'; @@ -36,14 +36,14 @@ export const AppRootProvider = memo<{ startServices: StartServices; queryClient: QueryClient; children: ReactNode | ReactNode[]; -}>(({ store, history, coreStart, depsStart: { data }, queryClient, startServices, children }) => { +}>(({ store, history, coreStart, queryClient, startServices, children }) => { const { theme: themeStart } = coreStart; const theme = useObservable(themeStart.theme$, themeStart.getTheme()); const isDarkMode = theme.darkMode; return ( - - + + @@ -61,8 +61,8 @@ export const AppRootProvider = memo<{ - - + + ); }); diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/use_bulk_actions.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/use_bulk_actions.tsx index d66f1b45feb9a..0e57febd33979 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/use_bulk_actions.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/bulk_actions/use_bulk_actions.tsx @@ -9,9 +9,10 @@ import type { EuiContextMenuPanelDescriptor } from '@elastic/eui'; import { EuiButton, EuiFlexGroup, EuiFlexItem, EuiTextColor } from '@elastic/eui'; import type { Toast } from '@kbn/core/public'; -import { toMountPoint } from '@kbn/kibana-react-plugin/public'; +import { toMountPoint } from '@kbn/react-kibana-mount'; import { euiThemeVars } from '@kbn/ui-theme'; import React, { useCallback } from 'react'; +import { useKibana } from '../../../../../common/lib/kibana'; import { convertRulesFilterToKQL } from '../../../../../../common/detection_engine/rule_management/rule_filtering'; import { DuplicateOptions } from '../../../../../../common/detection_engine/rule_management/constants'; import type { @@ -65,6 +66,7 @@ export const useBulkActions = ({ completeBulkEditForm, executeBulkActionsDryRun, }: UseBulkActionsArgs) => { + const { services: startServices } = useKibana(); const hasMlPermissions = useHasMlPermissions(); const rulesTableContext = useRulesTableContext(); const hasActionsPrivileges = useHasActionsPrivileges(); @@ -258,7 +260,8 @@ export const useBulkActions = ({ - + , + startServices ), iconType: undefined, }, @@ -481,6 +484,7 @@ export const useBulkActions = ({ executeBulkActionsDryRun, filterOptions, completeBulkEditForm, + startServices, ] ); diff --git a/x-pack/plugins/security_solution/public/entity_analytics/components/risk_score_onboarding/risk_score_enable_button.tsx b/x-pack/plugins/security_solution/public/entity_analytics/components/risk_score_onboarding/risk_score_enable_button.tsx index e6242e75677c1..f75204ad5ffd2 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/components/risk_score_onboarding/risk_score_enable_button.tsx +++ b/x-pack/plugins/security_solution/public/entity_analytics/components/risk_score_onboarding/risk_score_enable_button.tsx @@ -35,7 +35,7 @@ const RiskScoreEnableButtonComponent = ({ }; }) => { const spaceId = useSpaceId(); - const { http, notifications, theme, dashboard } = useKibana().services; + const { http, dashboard, ...startServices } = useKibana().services; const { renderDocLink, renderDashboardLink } = useRiskScoreToastContent(riskScoreEntity); const { fetch, isLoading } = useFetch(REQUEST_NAMES.ENABLE_RISK_SCORE, installRiskScoreModule); const isRiskEngineEnabled = useIsExperimentalFeatureEnabled('riskScoringRoutesEnabled'); @@ -44,27 +44,25 @@ const RiskScoreEnableButtonComponent = ({ fetch({ dashboard, http, - notifications, refetch, renderDashboardLink, renderDocLink, riskScoreEntity, spaceId, - theme, timerange, + startServices, }); }, [ dashboard, fetch, http, - notifications, refetch, renderDashboardLink, renderDocLink, riskScoreEntity, spaceId, - theme, timerange, + startServices, ]); return ( diff --git a/x-pack/plugins/security_solution/public/entity_analytics/components/risk_score_onboarding/risk_score_restart_button.tsx b/x-pack/plugins/security_solution/public/entity_analytics/components/risk_score_onboarding/risk_score_restart_button.tsx index 7f4316b77ee97..70f28df4420f9 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/components/risk_score_onboarding/risk_score_restart_button.tsx +++ b/x-pack/plugins/security_solution/public/entity_analytics/components/risk_score_onboarding/risk_score_restart_button.tsx @@ -31,18 +31,18 @@ const RiskScoreRestartButtonComponent = ({ const spaceId = useSpaceId(); const { renderDocLink } = useRiskScoreToastContent(riskScoreEntity); - const { http, notifications } = useKibana().services; + const { http, ...startServices } = useKibana().services; const onClick = useCallback(async () => { fetch({ http, - notifications, refetch, renderDocLink, riskScoreEntity, spaceId, + startServices, }); - }, [fetch, http, notifications, refetch, renderDocLink, riskScoreEntity, spaceId]); + }, [fetch, http, refetch, renderDocLink, riskScoreEntity, spaceId, startServices]); return ( React.ReactNode; renderDocLink?: (message: string) => React.ReactNode; riskScoreEntity: RiskScoreEntity; spaceId?: string; - theme?: ThemeServiceStart; timerange: { from: string; to: string; }; + startServices: StartRenderServices; } type UpgradeRiskScoreModule = InstallRiskScoreModule; @@ -47,34 +48,32 @@ type UpgradeRiskScoreModule = InstallRiskScoreModule; const installHostRiskScoreModule = async ({ dashboard, http, - notifications, refetch, renderDashboardLink, renderDocLink, - theme, timerange, + startServices, }: InstallRiskScoreModule) => { await installRiskScore({ http, renderDocLink, - notifications, options: { riskScoreEntity: RiskScoreEntity.host, }, + startServices, }); // Install dashboards and relevant saved objects await bulkCreatePrebuiltSavedObjects({ http, - theme, dashboard, renderDashboardLink, renderDocLink, ...timerange, - notifications, options: { templateName: `${RiskScoreEntity.host}RiskScoreDashboards`, }, + startServices, }); if (refetch) { @@ -85,35 +84,33 @@ const installHostRiskScoreModule = async ({ const installUserRiskScoreModule = async ({ dashboard, http, - notifications, refetch, renderDashboardLink, renderDocLink, spaceId = 'default', - theme, timerange, + startServices, }: InstallRiskScoreModule) => { await installRiskScore({ http, renderDocLink, - notifications, options: { riskScoreEntity: RiskScoreEntity.user, }, + startServices, }); // Install dashboards and relevant saved objects await bulkCreatePrebuiltSavedObjects({ dashboard, http, - notifications, options: { templateName: `${RiskScoreEntity.user}RiskScoreDashboards`, }, renderDashboardLink, renderDocLink, + startServices, ...timerange, - theme, }); if (refetch) { @@ -131,21 +128,19 @@ export const installRiskScoreModule = async (settings: InstallRiskScoreModule) = export const uninstallRiskScoreModule = async ({ http, - notifications, refetch, renderDocLink, riskScoreEntity, spaceId = 'default', - theme, + startServices, }: { http: HttpSetup; - notifications?: NotificationsStart; refetch?: inputsModel.Refetch; renderDocLink?: (message: string) => React.ReactNode; riskScoreEntity: RiskScoreEntity; spaceId?: string; - theme?: ThemeServiceStart; deleteAll?: boolean; + startServices: StartRenderServices; }) => { const legacyTransformIds = [ // transform Ids never changed since 8.3 @@ -196,12 +191,11 @@ export const uninstallRiskScoreModule = async ({ options: { templateName: `${riskScoreEntity}RiskScoreDashboards`, }, + startServices, }), deleteTransforms({ http, - theme, renderDocLink, - notifications, errorMessage: `${UNINSTALLATION_ERROR} - ${TRANSFORM_DELETION_ERROR_MESSAGE( legacyTransformIds.length )}`, @@ -211,6 +205,7 @@ export const uninstallRiskScoreModule = async ({ deleteDestDataView: true, forceDelete: false, }, + startServices, }), /** * Intended not to pass notification to deleteIngestPipelines. @@ -226,6 +221,7 @@ export const uninstallRiskScoreModule = async ({ legacyIngestPipelineNames.length )}`, names: legacyIngestPipelineNames.join(','), + startServices, }), /** * Intended not to pass notification to deleteStoredScripts. @@ -241,6 +237,7 @@ export const uninstallRiskScoreModule = async ({ riskScoreEntity === RiskScoreEntity.user ? legacyRiskScoreUsersScriptIds : legacyRiskScoreHostsScriptIds, + startServices, }), ]); @@ -252,83 +249,77 @@ export const uninstallRiskScoreModule = async ({ export const upgradeHostRiskScoreModule = async ({ dashboard, http, - notifications, refetch, renderDashboardLink, renderDocLink, spaceId = 'default', - theme, timerange, + startServices, }: UpgradeRiskScoreModule) => { await uninstallRiskScoreModule({ http, - notifications, renderDocLink, riskScoreEntity: RiskScoreEntity.host, spaceId, - theme, + startServices, }); await installRiskScoreModule({ dashboard, http, - notifications, refetch, renderDashboardLink, renderDocLink, riskScoreEntity: RiskScoreEntity.host, spaceId, - theme, timerange, + startServices, }); }; export const upgradeUserRiskScoreModule = async ({ dashboard, http, - notifications, refetch, renderDashboardLink, renderDocLink, spaceId = 'default', - theme, timerange, + startServices, }: UpgradeRiskScoreModule) => { await uninstallRiskScoreModule({ http, - notifications, renderDocLink, riskScoreEntity: RiskScoreEntity.user, spaceId, - theme, + startServices, }); await installRiskScoreModule({ dashboard, http, - notifications, refetch, renderDashboardLink, renderDocLink, riskScoreEntity: RiskScoreEntity.user, spaceId, - theme, timerange, + startServices, }); }; export const restartRiskScoreTransforms = async ({ http, - notifications, refetch, renderDocLink, riskScoreEntity, spaceId, + startServices, }: { http: HttpSetup; - notifications?: NotificationsStart; refetch?: inputsModel.Refetch; renderDocLink?: (message: string) => React.ReactNode; riskScoreEntity: RiskScoreEntity; spaceId?: string; + startServices: StartRenderServices; }) => { const transformIds = [ utils.getRiskScorePivotTransformId(riskScoreEntity, spaceId), @@ -337,16 +328,16 @@ export const restartRiskScoreTransforms = async ({ await stopTransforms({ http, - notifications, renderDocLink, transformIds, + startServices, }); const res = await startTransforms({ http, - notifications, renderDocLink, transformIds, + startServices, }); if (refetch) { diff --git a/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/ingest_pipelines.test.ts b/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/ingest_pipelines.test.ts index 5b4c99e95fd9c..604d8a2947a16 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/ingest_pipelines.test.ts +++ b/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/ingest_pipelines.test.ts @@ -5,7 +5,8 @@ * 2.0. */ -import type { HttpSetup, NotificationsStart } from '@kbn/core/public'; +import { coreMock } from '@kbn/core/public/mocks'; +import type { HttpSetup } from '@kbn/core/public'; import { createIngestPipeline, deleteIngestPipelines } from './ingest_pipelines'; const mockRequest = jest.fn(); @@ -15,14 +16,8 @@ const mockHttp = { delete: mockRequest, } as unknown as HttpSetup; -const mockAddDanger = jest.fn(); -const mockAddError = jest.fn(); -const mockNotification = { - toasts: { - addDanger: mockAddDanger, - addError: mockAddError, - }, -} as unknown as NotificationsStart; +const startServices = coreMock.createStart(); +const mockAddDanger = jest.spyOn(startServices.notifications.toasts, 'addDanger'); const mockRenderDocLink = jest.fn(); @@ -33,9 +28,9 @@ describe('createIngestPipeline', () => { mockRequest.mockRejectedValue({ body: { message: 'test error' } }); await createIngestPipeline({ http: mockHttp, - notifications: mockNotification, options: mockOptions, renderDocLink: mockRenderDocLink, + startServices, }); }); @@ -47,7 +42,12 @@ describe('createIngestPipeline', () => { }); it('handles error', () => { - expect(mockAddDanger.mock.calls[0][0].title).toEqual('Failed to create Ingest pipeline'); + expect(mockAddDanger.mock.calls[0][0]).toMatchInlineSnapshot(` + Object { + "text": [Function], + "title": "Failed to create Ingest pipeline", + } + `); expect(mockRenderDocLink.mock.calls[0][0]).toEqual('test error'); }); }); @@ -57,9 +57,9 @@ describe('deleteIngestPipelines', () => { mockRequest.mockRejectedValue({ body: { message: 'test error' } }); await deleteIngestPipelines({ http: mockHttp, - notifications: mockNotification, names: 'test,abc', renderDocLink: mockRenderDocLink, + startServices, }); }); @@ -71,7 +71,12 @@ describe('deleteIngestPipelines', () => { }); it('handles error', () => { - expect(mockAddDanger.mock.calls[0][0].title).toEqual('Failed to delete Ingest pipelines'); + expect(mockAddDanger.mock.calls[0][0]).toMatchInlineSnapshot(` + Object { + "text": [Function], + "title": "Failed to delete Ingest pipelines", + } + `); expect(mockRenderDocLink.mock.calls[0][0]).toEqual('test error'); }); }); diff --git a/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/ingest_pipelines.ts b/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/ingest_pipelines.ts index 8195a50440df9..9edc8ca886447 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/ingest_pipelines.ts +++ b/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/ingest_pipelines.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { toMountPoint } from '@kbn/kibana-react-plugin/public'; +import { toMountPoint } from '@kbn/react-kibana-mount'; import { INGEST_PIPELINE_CREATION_ERROR_MESSAGE, INGEST_PIPELINE_DELETION_ERROR_MESSAGE, @@ -17,11 +17,10 @@ const INGEST_PIPELINES_API_BASE_PATH = `/api/ingest_pipelines`; export async function createIngestPipeline({ errorMessage, http, - notifications, options, renderDocLink, signal, - theme, + startServices: { notifications, ...startServices }, }: CreateIngestPipeline) { const res = await http .post(INGEST_PIPELINES_API_BASE_PATH, { @@ -29,11 +28,12 @@ export async function createIngestPipeline({ signal, }) .catch((e) => { - notifications?.toasts?.addDanger({ + notifications.toasts.addDanger({ title: errorMessage ?? INGEST_PIPELINE_CREATION_ERROR_MESSAGE, - text: toMountPoint(renderDocLink ? renderDocLink(e?.body?.message) : e?.body?.message, { - theme$: theme?.theme$, - }), + text: toMountPoint( + renderDocLink ? renderDocLink(e?.body?.message) : e?.body?.message, + startServices + ), }); }); @@ -44,10 +44,9 @@ export async function deleteIngestPipelines({ errorMessage, http, names, // separate with ',' - notifications, renderDocLink, signal, - theme, + startServices: { notifications, ...startServices }, }: DeleteIngestPipeline) { const count = names.split(',').length; const res = await http @@ -55,11 +54,12 @@ export async function deleteIngestPipelines({ signal, }) .catch((e) => { - notifications?.toasts?.addDanger({ + notifications.toasts.addDanger({ title: errorMessage ?? INGEST_PIPELINE_DELETION_ERROR_MESSAGE(count), - text: toMountPoint(renderDocLink ? renderDocLink(e?.body?.message) : e?.body?.message, { - theme$: theme?.theme$, - }), + text: toMountPoint( + renderDocLink ? renderDocLink(e?.body?.message) : e?.body?.message, + startServices + ), }); }); diff --git a/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/onboarding.ts b/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/onboarding.ts index ff6344679455f..66ebddf348bdb 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/onboarding.ts +++ b/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/onboarding.ts @@ -5,8 +5,9 @@ * 2.0. */ -import type { HttpSetup, NotificationsStart } from '@kbn/core/public'; +import type { HttpSetup } from '@kbn/core/public'; +import type { StartRenderServices } from '../../../types'; import { INTERNAL_RISK_SCORE_URL } from '../../../../common/constants'; import { RiskScoreEntity } from '../../../../common/search_strategy'; @@ -27,18 +28,19 @@ const toastLifeTimeMs = 600000; export const installRiskScore = ({ errorMessage, http, - notifications, options, renderDocLink, signal, + startServices, }: { errorMessage?: string; http: HttpSetup; - notifications?: NotificationsStart; options: Options; renderDocLink?: (message: string) => React.ReactNode; signal?: AbortSignal; + startServices: Pick; }) => { + const { notifications } = startServices; return http .post(INTERNAL_RISK_SCORE_URL, { version: '1', @@ -61,7 +63,7 @@ export const installRiskScore = ({ ); if (resp.error.length > 0) { - notifications?.toasts?.addError(new Error(errorMessage ?? INSTALLATION_ERROR), { + notifications.toasts.addError(new Error(errorMessage ?? INSTALLATION_ERROR), { title: errorMessage ?? INSTALLATION_ERROR, toastMessage: renderDocLink ? (renderDocLink(resp.error.join(', ')) as unknown as string) @@ -69,7 +71,7 @@ export const installRiskScore = ({ toastLifeTimeMs, }); } else { - notifications?.toasts?.addSuccess({ + notifications.toasts.addSuccess({ 'data-test-subj': `${options.riskScoreEntity}EnableSuccessToast`, title: options.riskScoreEntity === RiskScoreEntity.user @@ -80,7 +82,7 @@ export const installRiskScore = ({ } }) .catch((e) => { - notifications?.toasts?.addError(new Error(errorMessage ?? INSTALLATION_ERROR), { + notifications.toasts.addError(new Error(errorMessage ?? INSTALLATION_ERROR), { title: errorMessage ?? INSTALLATION_ERROR, toastMessage: renderDocLink ? renderDocLink(e?.body?.message) : e?.body?.message, toastLifeTimeMs, diff --git a/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/saved_objects.ts b/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/saved_objects.ts index 4c3f863ddbeae..eb9adc159d019 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/saved_objects.ts +++ b/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/saved_objects.ts @@ -5,9 +5,10 @@ * 2.0. */ -import type { HttpSetup, NotificationsStart, ThemeServiceStart } from '@kbn/core/public'; -import { toMountPoint } from '@kbn/kibana-react-plugin/public'; +import type { HttpSetup } from '@kbn/core/public'; +import { toMountPoint } from '@kbn/react-kibana-mount'; import type { DashboardStart } from '@kbn/dashboard-plugin/public'; +import type { StartRenderServices } from '../../../types'; import { RISKY_HOSTS_DASHBOARD_TITLE, RISKY_USERS_DASHBOARD_TITLE, @@ -38,23 +39,21 @@ export const bulkCreatePrebuiltSavedObjects = async ({ to, errorMessage, http, - notifications, options, renderDashboardLink, renderDocLink, from, - theme, + startServices: { notifications, ...startServices }, }: { dashboard?: DashboardStart; to: string; errorMessage?: string; http: HttpSetup; - notifications?: NotificationsStart; options: Options; renderDashboardLink?: (message: string, dashboardUrl: string) => React.ReactNode; renderDocLink?: (message: string) => React.ReactNode; from: string; - theme?: ThemeServiceStart; + startServices: StartRenderServices; }) => { const res = await http .post< @@ -72,7 +71,7 @@ export const bulkCreatePrebuiltSavedObjects = async ({ const error = response?.error?.message; if (error) { - notifications?.toasts?.addError(new Error(errorMessage ?? IMPORT_SAVED_OBJECTS_FAILURE), { + notifications.toasts.addError(new Error(errorMessage ?? IMPORT_SAVED_OBJECTS_FAILURE), { title: errorMessage ?? IMPORT_SAVED_OBJECTS_FAILURE, toastMessage: renderDocLink ? (renderDocLink(error) as unknown as string) : error, toastLifeTimeMs, @@ -104,23 +103,21 @@ export const bulkCreatePrebuiltSavedObjects = async ({ return; } - notifications?.toasts?.addSuccess({ + notifications.toasts.addSuccess({ 'data-test-subj': `${options.templateName}SuccessToast`, title: IMPORT_SAVED_OBJECTS_SUCCESS(response?.body?.length), text: toMountPoint( renderDashboardLink && targetUrl ? renderDashboardLink(successMessage, targetUrl) : successMessage, - { - theme$: theme?.theme$, - } + startServices ), toastLifeTimeMs, }); } }) .catch((e) => { - notifications?.toasts?.addError(new Error(errorMessage ?? IMPORT_SAVED_OBJECTS_FAILURE), { + notifications.toasts.addError(new Error(errorMessage ?? IMPORT_SAVED_OBJECTS_FAILURE), { title: errorMessage ?? IMPORT_SAVED_OBJECTS_FAILURE, toastMessage: renderDocLink ? renderDocLink(e?.body?.message) : e?.body?.message, toastLifeTimeMs, @@ -132,19 +129,19 @@ export const bulkCreatePrebuiltSavedObjects = async ({ export const bulkDeletePrebuiltSavedObjects = async ({ http, - notifications, errorMessage, options, + startServices: { notifications }, }: { http: HttpSetup; - notifications?: NotificationsStart; errorMessage?: string; options: Options; + startServices: StartRenderServices; }) => { const res = await http .post(prebuiltSavedObjectsBulkDeleteUrl(options.templateName), { version: '1' }) .catch((e) => { - notifications?.toasts?.addDanger({ + notifications.toasts.addDanger({ title: errorMessage ?? DELETE_SAVED_OBJECTS_FAILURE, text: e?.body?.message, }); diff --git a/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/stored_scripts.test.ts b/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/stored_scripts.test.ts index 90bcde6900a1c..fe23e8dbdb6c9 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/stored_scripts.test.ts +++ b/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/stored_scripts.test.ts @@ -5,7 +5,8 @@ * 2.0. */ -import type { HttpSetup, NotificationsStart } from '@kbn/core/public'; +import { coreMock } from '@kbn/core/public/mocks'; +import type { HttpSetup } from '@kbn/core/public'; import { createStoredScript, deleteStoredScript } from './stored_scripts'; const mockRequest = jest.fn(); @@ -15,14 +16,8 @@ const mockHttp = { delete: mockRequest, } as unknown as HttpSetup; -const mockAddDanger = jest.fn(); -const mockAddError = jest.fn(); -const mockNotification = { - toasts: { - addDanger: mockAddDanger, - addError: mockAddError, - }, -} as unknown as NotificationsStart; +const startServices = coreMock.createStart(); +const mockAddDanger = jest.spyOn(startServices.notifications.toasts, 'addDanger'); const mockRenderDocLink = jest.fn(); @@ -33,9 +28,9 @@ describe('createStoredScript', () => { mockRequest.mockRejectedValue({ body: { message: 'test error' } }); await createStoredScript({ http: mockHttp, - notifications: mockNotification, options: mockOptions, renderDocLink: mockRenderDocLink, + startServices, }); }); @@ -47,7 +42,12 @@ describe('createStoredScript', () => { }); it('handles error', () => { - expect(mockAddDanger.mock.calls[0][0].title).toEqual('Failed to create stored script'); + expect(mockAddDanger.mock.calls[0][0]).toMatchInlineSnapshot(` + Object { + "text": [Function], + "title": "Failed to create stored script", + } + `); expect(mockRenderDocLink.mock.calls[0][0]).toEqual('test error'); }); }); @@ -59,9 +59,9 @@ describe('deleteStoredScript', () => { mockRequest.mockRejectedValue({ body: { message: 'test error' } }); await deleteStoredScript({ http: mockHttp, - notifications: mockNotification, options: mockOptions, renderDocLink: mockRenderDocLink, + startServices, }); }); @@ -73,7 +73,12 @@ describe('deleteStoredScript', () => { }); it('handles error', () => { - expect(mockAddDanger.mock.calls[0][0].title).toEqual('Failed to delete stored script'); + expect(mockAddDanger.mock.calls[0][0]).toMatchInlineSnapshot(` + Object { + "text": [Function], + "title": "Failed to delete stored script", + } + `); expect(mockRenderDocLink.mock.calls[0][0]).toEqual('test error'); }); }); diff --git a/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/stored_scripts.ts b/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/stored_scripts.ts index 243106325982a..90aeef15c22a8 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/stored_scripts.ts +++ b/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/stored_scripts.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { toMountPoint } from '@kbn/kibana-react-plugin/public'; +import { toMountPoint } from '@kbn/react-kibana-mount'; import { RISK_SCORE_CREATE_STORED_SCRIPT, RISK_SCORE_DELETE_STORED_SCRIPT, @@ -19,11 +19,10 @@ import type { CreateStoredScript, DeleteStoredScript, DeleteStoredScripts } from export async function createStoredScript({ errorMessage, http, - notifications, options, renderDocLink, signal, - theme, + startServices: { notifications, ...startServices }, }: CreateStoredScript) { const res = await http .put(RISK_SCORE_CREATE_STORED_SCRIPT, { @@ -32,11 +31,12 @@ export async function createStoredScript({ signal, }) .catch((e) => { - notifications?.toasts?.addDanger({ + notifications.toasts.addDanger({ title: errorMessage ?? STORED_SCRIPT_CREATION_ERROR_MESSAGE, - text: toMountPoint(renderDocLink ? renderDocLink(e?.body?.message) : e?.body?.message, { - theme$: theme?.theme$, - }), + text: toMountPoint( + renderDocLink ? renderDocLink(e?.body?.message) : e?.body?.message, + startServices + ), }); }); @@ -46,11 +46,10 @@ export async function createStoredScript({ export async function deleteStoredScript({ errorMessage, http, - notifications, options, renderDocLink, signal, - theme, + startServices: { notifications, ...startServices }, }: DeleteStoredScript) { const res = await http .delete(RISK_SCORE_DELETE_STORED_SCRIPT, { @@ -59,11 +58,12 @@ export async function deleteStoredScript({ signal, }) .catch((e) => { - notifications?.toasts?.addDanger({ + notifications.toasts.addDanger({ title: errorMessage ?? STORED_SCRIPT_DELETION_ERROR_MESSAGE, - text: toMountPoint(renderDocLink ? renderDocLink(e?.body?.message) : e?.body?.message, { - theme$: theme?.theme$, - }), + text: toMountPoint( + renderDocLink ? renderDocLink(e?.body?.message) : e?.body?.message, + startServices + ), }); }); @@ -72,19 +72,19 @@ export async function deleteStoredScript({ export async function deleteStoredScripts({ http, - notifications, signal, errorMessage, ids, + startServices, }: DeleteStoredScripts) { const result = await Promise.all( ids.map((id) => { return deleteStoredScript({ http, - notifications, signal, errorMessage, options: { id }, + startServices, }); }) ); diff --git a/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/transforms.test.ts b/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/transforms.test.ts index c59df3029691b..d45d19d8d6227 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/transforms.test.ts +++ b/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/transforms.test.ts @@ -4,7 +4,9 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { HttpSetup, NotificationsStart } from '@kbn/core/public'; + +import { coreMock } from '@kbn/core/public/mocks'; +import type { HttpSetup } from '@kbn/core/public'; import { createTransform, deleteTransforms, getTransformState, stopTransforms } from './transforms'; const mockRequest = jest.fn(); @@ -15,14 +17,8 @@ const mockHttp = { delete: mockRequest, } as unknown as HttpSetup; -const mockAddDanger = jest.fn(); -const mockAddError = jest.fn(); -const mockNotification = { - toasts: { - addDanger: mockAddDanger, - addError: mockAddError, - }, -} as unknown as NotificationsStart; +const startServices = coreMock.createStart(); +const mockAddError = jest.spyOn(startServices.notifications.toasts, 'addError'); const mockRenderDocLink = jest.fn(); @@ -37,10 +33,10 @@ describe('createTransform', () => { }); await createTransform({ http: mockHttp, - notifications: mockNotification, options: mockOptions, renderDocLink: mockRenderDocLink, transformId: 'test', + startServices, }); }); @@ -64,9 +60,9 @@ describe('getTransformState', () => { }); await getTransformState({ http: mockHttp, - notifications: mockNotification, renderDocLink: mockRenderDocLink, transformId: 'test', + startServices, }); }); @@ -90,9 +86,9 @@ describe('startTransforms', () => { }); await getTransformState({ http: mockHttp, - notifications: mockNotification, renderDocLink: mockRenderDocLink, transformId: 'test', + startServices, }); }); @@ -130,9 +126,9 @@ describe('stopTransforms', () => { await stopTransforms({ http: mockHttp, - notifications: mockNotification, transformIds: ['test'], renderDocLink: mockRenderDocLink, + startServices, }); }); @@ -189,10 +185,10 @@ describe('deleteTransforms', () => { }); await deleteTransforms({ http: mockHttp, - notifications: mockNotification, options: mockOptions, transformIds: ['test'], renderDocLink: mockRenderDocLink, + startServices, }); }); diff --git a/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/transforms.ts b/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/transforms.ts index 1a824ba4b05ad..9619b062b5f3d 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/transforms.ts +++ b/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/transforms.ts @@ -40,11 +40,11 @@ const getErrorToastMessage = ({ export async function createTransform({ errorMessage, http, - notifications, options, renderDocLink, signal, transformId, + startServices: { notifications }, }: CreateTransform) { const res = await http .put(`${TRANSFORM_API_BASE_PATH}/transforms/${transformId}`, { @@ -64,7 +64,7 @@ export async function createTransform({ return id; }, []); - notifications?.toasts?.addError(new Error(errorMessageTitle), { + notifications.toasts.addError(new Error(errorMessageTitle), { title: errorMessageTitle, toastMessage: getErrorToastMessage({ messageBody: failedIds.join(', '), @@ -76,7 +76,7 @@ export async function createTransform({ return result; }) .catch((e) => { - notifications?.toasts?.addError(e, { + notifications.toasts.addError(e, { title: errorMessage ?? TRANSFORM_CREATION_ERROR_MESSAGE, toastMessage: getErrorToastMessage({ messageBody: e?.body?.message, renderDocLink }), toastLifeTimeMs, @@ -88,11 +88,11 @@ export async function createTransform({ export async function startTransforms({ http, - notifications, renderDocLink, signal, errorMessage, transformIds, + startServices: { notifications }, }: StartTransforms) { const res = await http .post(`${TRANSFORM_API_BASE_PATH}/start_transforms`, { @@ -113,7 +113,7 @@ export async function startTransforms({ const errorMessageTitle = errorMessage ?? START_TRANSFORMS_ERROR_MESSAGE(failedIds.length); if (failedIds.length > 0) { - notifications?.toasts?.addError(new Error(errorMessageTitle), { + notifications.toasts.addError(new Error(errorMessageTitle), { title: errorMessageTitle, toastMessage: getErrorToastMessage({ messageBody: failedIds.join(', '), @@ -126,7 +126,7 @@ export async function startTransforms({ return result; }) .catch((e) => { - notifications?.toasts?.addError(e, { + notifications.toasts.addError(e, { title: errorMessage ?? START_TRANSFORMS_ERROR_MESSAGE(transformIds.length), toastMessage: getErrorToastMessage({ messageBody: e?.body?.message, renderDocLink }), toastLifeTimeMs, @@ -138,11 +138,11 @@ export async function startTransforms({ export async function getTransformState({ http, - notifications, renderDocLink, signal, errorMessage = GET_TRANSFORM_STATE_ERROR_MESSAGE, transformId, + startServices: { notifications }, }: GetTransformState) { const res = await http .get<{ transforms: Array<{ id: string; state: string }>; count: number }>( @@ -154,7 +154,7 @@ export async function getTransformState({ ) .then((result) => { if (result.count === 0) { - notifications?.toasts?.addError(new Error(errorMessage), { + notifications.toasts.addError(new Error(errorMessage), { title: errorMessage, toastMessage: getErrorToastMessage({ messageBody: `${GET_TRANSFORM_STATE_NOT_FOUND_MESSAGE}: ${transformId}`, @@ -166,7 +166,7 @@ export async function getTransformState({ return result; }) .catch((e) => { - notifications?.toasts?.addError(e, { + notifications.toasts.addError(e, { title: errorMessage, toastMessage: getErrorToastMessage({ messageBody: e?.body?.message, renderDocLink }), toastLifeTimeMs, @@ -178,19 +178,19 @@ export async function getTransformState({ export async function getTransformsState({ http, - notifications, signal, errorMessage, transformIds, + startServices, }: GetTransformsState) { const states = await Promise.all( transformIds.map((transformId) => { const transformState = getTransformState({ http, - notifications, signal, errorMessage, transformId, + startServices, }); return transformState; }) @@ -200,13 +200,14 @@ export async function getTransformsState({ export async function stopTransforms({ http, - notifications, signal, errorMessage, transformIds, renderDocLink, + startServices, }: StopTransforms) { - const states = await getTransformsState({ http, signal, transformIds }); + const { notifications } = startServices; + const states = await getTransformsState({ http, signal, transformIds, startServices }); const res = await http .post(`${TRANSFORM_API_BASE_PATH}/stop_transforms`, { version: '1', @@ -236,7 +237,7 @@ export async function stopTransforms({ const errorMessageTitle = errorMessage ?? STOP_TRANSFORMS_ERROR_MESSAGE(failedIds.length); if (failedIds.length > 0) { - notifications?.toasts?.addError(new Error(errorMessageTitle), { + notifications.toasts.addError(new Error(errorMessageTitle), { title: errorMessageTitle, toastMessage: getErrorToastMessage({ messageBody: failedIds.join(', '), @@ -249,7 +250,7 @@ export async function stopTransforms({ return result; }) .catch((e) => { - notifications?.toasts?.addError(e, { + notifications.toasts.addError(e, { title: errorMessage ?? STOP_TRANSFORMS_ERROR_MESSAGE(transformIds.length), toastMessage: getErrorToastMessage({ messageBody: e?.body?.message, @@ -264,14 +265,15 @@ export async function stopTransforms({ export async function deleteTransforms({ http, - notifications, signal, errorMessage, transformIds, options, renderDocLink, + startServices, }: DeleteTransforms) { - await stopTransforms({ http, signal, transformIds }); + const { notifications } = startServices; + await stopTransforms({ http, signal, transformIds, startServices }); const res = await http .post(`${TRANSFORM_API_BASE_PATH}/delete_transforms`, { version: '1', @@ -298,7 +300,7 @@ export async function deleteTransforms({ const errorMessageTitle = errorMessage ?? TRANSFORM_DELETION_ERROR_MESSAGE(failedIds.length); if (failedIds.length > 0) { - notifications?.toasts?.addError(new Error(errorMessageTitle), { + notifications.toasts.addError(new Error(errorMessageTitle), { title: errorMessageTitle, toastMessage: getErrorToastMessage({ messageBody: failedIds.join(', '), @@ -311,7 +313,7 @@ export async function deleteTransforms({ return result; }) .catch((e) => { - notifications?.toasts?.addError(e, { + notifications.toasts.addError(e, { title: errorMessage ?? TRANSFORM_DELETION_ERROR_MESSAGE(transformIds.length), toastMessage: getErrorToastMessage({ messageBody: e?.body?.message, diff --git a/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/types.ts b/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/types.ts index e2888772e7b57..a6c91f47d60a5 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/types.ts +++ b/x-pack/plugins/security_solution/public/entity_analytics/deprecated_risk_engine/api/types.ts @@ -4,15 +4,15 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import type { HttpSetup, NotificationsStart, ThemeServiceStart } from '@kbn/core/public'; +import type { HttpSetup } from '@kbn/core/public'; +import type { StartRenderServices } from '../../../types'; interface RiskyScoreApiBase { errorMessage?: string; http: HttpSetup; - notifications?: NotificationsStart; renderDocLink?: (message: string) => React.ReactNode; signal?: AbortSignal; - theme?: ThemeServiceStart; + startServices: StartRenderServices; } export interface CreateIngestPipeline extends RiskyScoreApiBase { options: { diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/ingest_manager_integration/mocks.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/ingest_manager_integration/mocks.tsx index 56c0e2b9b11a2..a19bea940adfc 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/ingest_manager_integration/mocks.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/ingest_manager_integration/mocks.tsx @@ -10,9 +10,9 @@ import type { Action, Reducer } from 'redux'; import type { RenderOptions } from '@testing-library/react'; // eslint-disable-next-line import/no-extraneous-dependencies import { render as reactRender } from '@testing-library/react'; -import { I18nProvider } from '@kbn/i18n-react'; import type { PackageInfo } from '@kbn/fleet-plugin/common/types'; import { EuiThemeProvider } from '@kbn/kibana-react-plugin/common'; +import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; import { deepFreeze } from '@kbn/std'; import type { AppContextTestRender, UiRender } from '../../../../../common/mock/endpoint'; @@ -99,8 +99,8 @@ export const createFleetContextRendererMock = (): AppContextTestRender => { }); return ( - - + + { {children} - - + + ); }; diff --git a/x-pack/plugins/security_solution/public/types.ts b/x-pack/plugins/security_solution/public/types.ts index 409f019238caf..96f2538f157f7 100644 --- a/x-pack/plugins/security_solution/public/types.ts +++ b/x-pack/plugins/security_solution/public/types.ts @@ -186,6 +186,16 @@ export type StartServices = CoreStart & timelineFilterManager: FilterManager; }; +export type StartRenderServices = Pick< + CoreStart, + // Used extensively in rendering Security Solution UI + | 'notifications' + // Needed for rendering Shared React modules + | 'analytics' + | 'i18n' + | 'theme' +>; + export interface PluginSetup { resolver: () => Promise; experimentalFeatures: ExperimentalFeatures; diff --git a/x-pack/plugins/security_solution/tsconfig.json b/x-pack/plugins/security_solution/tsconfig.json index 1a6b87b875580..17a7aea6839c7 100644 --- a/x-pack/plugins/security_solution/tsconfig.json +++ b/x-pack/plugins/security_solution/tsconfig.json @@ -181,7 +181,6 @@ "@kbn/dom-drag-drop", "@kbn/unified-field-list", "@kbn/resizable-layout", - "@kbn/shared-ux-error-boundary", "@kbn/zod-helpers", "@kbn/core-http-common", "@kbn/search-errors", @@ -200,6 +199,7 @@ "@kbn/core-ui-settings-browser-mocks", "@kbn/management-plugin", "@kbn/security-plugin-types-server", - "@kbn/deeplinks-security" + "@kbn/deeplinks-security", + "@kbn/react-kibana-context-render" ] }