Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiProvider] Fix Security Solution code #183878

Merged
merged 4 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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: [] },
Expand All @@ -42,7 +45,7 @@ describe('ExecutionLogTable', () => {
test('Shows total events returned', () => {
const ruleDetailsContext = useRuleDetailsContextMock.create();
(useRuleDetailsContext as jest.Mock).mockReturnValue(ruleDetailsContext);
render(<ExecutionLogTable ruleId={'0'} selectAlertsTab={noop} />, {
render(<ExecutionLogTable ruleId={'0'} selectAlertsTab={noop} {...coreStart} />, {
wrapper: TestProviders,
});
expect(screen.getByTestId('executionsShowing')).toHaveTextContent('Showing 7 rule executions');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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;
}
Expand All @@ -96,6 +106,7 @@ interface CachedGlobalQueryState {
const ExecutionLogTableComponent: React.FC<ExecutionLogTableProps> = ({
ruleId,
selectAlertsTab,
...startServices
}) => {
const {
docLinks,
Expand Down Expand Up @@ -300,7 +311,7 @@ const ExecutionLogTableComponent: React.FC<ExecutionLogTableProps> = ({
{
title: i18n.ACTIONS_SEARCH_FILTERS_HAVE_BEEN_UPDATED_TITLE,
text: mountReactNode(
<>
<KibanaRenderContextProvider {...startServices}>
<p>{i18n.ACTIONS_SEARCH_FILTERS_HAVE_BEEN_UPDATED_DESCRIPTION}</p>
<EuiFlexGroup justifyContent="flexEnd" gutterSize="s">
<EuiFlexItem grow={false}>
Expand All @@ -309,7 +320,7 @@ const ExecutionLogTableComponent: React.FC<ExecutionLogTableProps> = ({
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
</>
</KibanaRenderContextProvider>
),
},
// Essentially keep toast around till user dismisses via 'x'
Expand All @@ -333,6 +344,7 @@ const ExecutionLogTableComponent: React.FC<ExecutionLogTableProps> = ({
selectAlertsTab,
timerange,
uuidDataViewField,
startServices,
]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ const RuleDetailsPageComponent: React.FC<DetectionEngineComponentProps> = ({
clearSelected,
}) => {
const {
analytics,
i18n: i18nStart,
theme,
application: {
navigateToApp,
capabilities: { actions },
Expand Down Expand Up @@ -769,7 +772,13 @@ const RuleDetailsPageComponent: React.FC<DetectionEngineComponentProps> = ({
/>
</Route>
<Route path={`/rules/id/:detailName/:tabName(${RuleDetailTabs.executionResults})`}>
<ExecutionLogTable ruleId={ruleId} selectAlertsTab={navigateToAlertsTab} />
<ExecutionLogTable
ruleId={ruleId}
selectAlertsTab={navigateToAlertsTab}
analytics={analytics}
i18n={i18nStart}
theme={theme}
/>
</Route>
<Route path={`/rules/id/:detailName/:tabName(${RuleDetailTabs.executionEvents})`}>
<ExecutionEventsTable ruleId={ruleId} />
Expand Down
5 changes: 4 additions & 1 deletion x-pack/plugins/security_solution/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}