[Security Solution] Disables reason column internal rendering for the rule preview table (#138312) (#138455)

(cherry picked from commit 24ababf408)

Co-authored-by: Davis Plumlee <56367316+dplumlee@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2022-08-09 16:52:38 -04:00 committed by GitHub
parent 7eb3e9e0ea
commit ef7f4cf6d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 2 deletions

View file

@ -14,7 +14,7 @@ import { reasonColumnRenderer } from './reason_column_renderer';
import { plainColumnRenderer } from './plain_column_renderer';
import type { ColumnHeaderOptions, RowRenderer } from '../../../../../../common/types';
import { RowRendererId } from '../../../../../../common/types';
import { RowRendererId, TimelineId } from '../../../../../../common/types';
import { render } from '@testing-library/react';
import { TestProviders } from '@kbn/timelines-plugin/public/mock';
@ -135,5 +135,19 @@ describe('reasonColumnRenderer', () => {
expect(wrapper.queryByTestId('reason-cell-renderer')).toBeInTheDocument();
});
it("doesn't render reason renderers when timeline id is for the rule preview page", () => {
const renderedColumn = reasonColumnRenderer.renderColumn({
...defaultProps,
isDetails: true,
ecsData: validEcs,
rowRenderers,
timelineId: TimelineId.rulePreview,
});
const wrapper = render(<TestProviders>{renderedColumn}</TestProviders>);
expect(wrapper.queryByTestId('reason-cell-renderer')).not.toBeInTheDocument();
});
});
});

View file

@ -10,6 +10,7 @@ import { isEqual } from 'lodash/fp';
import React, { useMemo } from 'react';
import type { ColumnHeaderOptions, RowRenderer } from '../../../../../../common/types';
import { TimelineId } from '../../../../../../common/types';
import type { Ecs } from '../../../../../../common/ecs';
import { eventRendererNames } from '../../../row_renderers_browser/catalog/constants';
import type { ColumnRenderer } from './column_renderer';
@ -91,9 +92,12 @@ const ReasonCell: React.FC<{
);
}, [rowRenderer, ecsData, timelineId]);
// We don't currently show enriched renders for rule preview table
const isPlainText = useMemo(() => timelineId === TimelineId.rulePreview, [timelineId]);
return (
<>
{rowRenderer && rowRender ? (
{rowRenderer && rowRender && !isPlainText ? (
<>
{value}
<h4>{i18n.REASON_RENDERER_TITLE(eventRendererNames[rowRenderer.id] ?? '')}</h4>