From 8c81f313f5eb868c43ed6340825b968e3a4393c6 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Thu, 16 May 2024 15:54:49 -0700 Subject: [PATCH 1/3] Fix security solution --- .../execution_log_table.test.tsx | 5 ++++- .../execution_log_table.tsx | 18 +++++++++++++++--- .../pages/rule_details/index.tsx | 11 ++++++++++- x-pack/plugins/security_solution/tsconfig.json | 5 ++++- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/execution_log_table/execution_log_table.test.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/execution_log_table/execution_log_table.test.tsx index 939c2a03547d71..cda7e4e200877d 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/execution_log_table/execution_log_table.test.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/execution_log_table/execution_log_table.test.tsx @@ -8,6 +8,7 @@ import React from 'react'; import { noop } from 'lodash/fp'; import { render, screen } from '@testing-library/react'; +import { coreMock } from '@kbn/core/public/mocks'; import { TestProviders } from '../../../../../common/mock'; import { useRuleDetailsContextMock } from '../__mocks__/rule_details_context'; @@ -22,6 +23,8 @@ jest.mock('../../../../../common/containers/sourcerer'); jest.mock('../../../../rule_monitoring/components/execution_results_table/use_execution_results'); jest.mock('../rule_details_context'); +const coreStart = coreMock.createStart(); + const mockUseSourcererDataView = useSourcererDataView as jest.Mock; mockUseSourcererDataView.mockReturnValue({ indexPattern: { fields: [] }, @@ -42,7 +45,7 @@ describe('ExecutionLogTable', () => { test('Shows total events returned', () => { const ruleDetailsContext = useRuleDetailsContextMock.create(); (useRuleDetailsContext as jest.Mock).mockReturnValue(ruleDetailsContext); - render(, { + render(, { wrapper: TestProviders, }); expect(screen.getByTestId('executionsShowing')).toHaveTextContent('Showing 7 rule executions'); diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/execution_log_table/execution_log_table.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/execution_log_table/execution_log_table.tsx index 1171c22fbcea2f..0918e3ece5eec0 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/execution_log_table/execution_log_table.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/execution_log_table/execution_log_table.tsx @@ -27,6 +27,10 @@ import type { Filter, Query } from '@kbn/es-query'; import { buildFilter, FILTERS } from '@kbn/es-query'; import { MAX_EXECUTION_EVENTS_DISPLAYED } from '@kbn/securitysolution-rules'; import { mountReactNode } from '@kbn/core-mount-utils-browser-internal'; +import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; +import type { AnalyticsServiceStart } from '@kbn/core-analytics-browser'; +import type { I18nStart } from '@kbn/core-i18n-browser'; +import type { ThemeServiceStart } from '@kbn/core-theme-browser'; import { InputsModelId } from '../../../../../common/store/inputs/constants'; @@ -82,7 +86,13 @@ const DatePickerEuiFlexItem = styled(EuiFlexItem)` max-width: 582px; `; -interface ExecutionLogTableProps { +interface StartServices { + analytics: AnalyticsServiceStart; + i18n: I18nStart; + theme: ThemeServiceStart; +} + +interface ExecutionLogTableProps extends StartServices { ruleId: string; selectAlertsTab: () => void; } @@ -96,6 +106,7 @@ interface CachedGlobalQueryState { const ExecutionLogTableComponent: React.FC = ({ ruleId, selectAlertsTab, + ...startServices }) => { const { docLinks, @@ -300,7 +311,7 @@ const ExecutionLogTableComponent: React.FC = ({ { title: i18n.ACTIONS_SEARCH_FILTERS_HAVE_BEEN_UPDATED_TITLE, text: mountReactNode( - <> +

{i18n.ACTIONS_SEARCH_FILTERS_HAVE_BEEN_UPDATED_DESCRIPTION}

@@ -309,7 +320,7 @@ const ExecutionLogTableComponent: React.FC = ({ - +
), }, // Essentially keep toast around till user dismisses via 'x' @@ -333,6 +344,7 @@ const ExecutionLogTableComponent: React.FC = ({ selectAlertsTab, timerange, uuidDataViewField, + startServices, ] ); diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/index.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/index.tsx index e99e6d6659034e..2dacd37f7d2451 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/index.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/index.tsx @@ -179,6 +179,9 @@ const RuleDetailsPageComponent: React.FC = ({ clearSelected, }) => { const { + analytics, + i18n: i18nStart, + theme, application: { navigateToApp, capabilities: { actions }, @@ -769,7 +772,13 @@ const RuleDetailsPageComponent: React.FC = ({ /> - + diff --git a/x-pack/plugins/security_solution/tsconfig.json b/x-pack/plugins/security_solution/tsconfig.json index bb26581356fa1a..380a79c08f5bf0 100644 --- a/x-pack/plugins/security_solution/tsconfig.json +++ b/x-pack/plugins/security_solution/tsconfig.json @@ -201,6 +201,9 @@ "@kbn/deeplinks-security", "@kbn/react-kibana-context-render", "@kbn/search-types", - "@kbn/field-utils" + "@kbn/field-utils", + "@kbn/core-analytics-browser", + "@kbn/core-i18n-browser", + "@kbn/core-theme-browser" ] } From 97e75f8ff841d7b17b0d250410a3efb8f09d2d63 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Thu, 23 May 2024 13:19:24 -0700 Subject: [PATCH 2/3] switch mountReactNode with toMountPoint in rule_details/execution_log_table/execution_log_table.tsx --- .../execution_log_table/execution_log_table.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/execution_log_table/execution_log_table.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/execution_log_table/execution_log_table.tsx index 0918e3ece5eec0..77705480755111 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/execution_log_table/execution_log_table.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_details_ui/pages/rule_details/execution_log_table/execution_log_table.tsx @@ -26,8 +26,7 @@ import { import type { Filter, Query } from '@kbn/es-query'; import { buildFilter, FILTERS } from '@kbn/es-query'; import { MAX_EXECUTION_EVENTS_DISPLAYED } from '@kbn/securitysolution-rules'; -import { mountReactNode } from '@kbn/core-mount-utils-browser-internal'; -import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; +import { toMountPoint } from '@kbn/react-kibana-mount'; import type { AnalyticsServiceStart } from '@kbn/core-analytics-browser'; import type { I18nStart } from '@kbn/core-i18n-browser'; import type { ThemeServiceStart } from '@kbn/core-theme-browser'; @@ -310,8 +309,8 @@ const ExecutionLogTableComponent: React.FC = ({ successToastId.current = addSuccess( { title: i18n.ACTIONS_SEARCH_FILTERS_HAVE_BEEN_UPDATED_TITLE, - text: mountReactNode( - + text: toMountPoint( + <>

{i18n.ACTIONS_SEARCH_FILTERS_HAVE_BEEN_UPDATED_DESCRIPTION}

@@ -320,7 +319,8 @@ const ExecutionLogTableComponent: React.FC = ({ -
+ , + startServices ), }, // Essentially keep toast around till user dismisses via 'x' From 08fdb8ac55253c5752101daafd00d262fc495c22 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 23 May 2024 20:26:18 +0000 Subject: [PATCH 3/3] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- x-pack/plugins/security_solution/tsconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugins/security_solution/tsconfig.json b/x-pack/plugins/security_solution/tsconfig.json index 74d22452b7ccc2..0a74be06da7d02 100644 --- a/x-pack/plugins/security_solution/tsconfig.json +++ b/x-pack/plugins/security_solution/tsconfig.json @@ -105,7 +105,6 @@ "@kbn/react-field", "@kbn/field-types", "@kbn/securitysolution-rules", - "@kbn/core-mount-utils-browser-internal", "@kbn/cases-components", "@kbn/event-log-plugin", "@kbn/task-manager-plugin",