Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -51,7 +51,7 @@ export const AIForSOCPanel: React.FC<Partial<AIForSOCDetailsProps>> = memo(() =>
<HighlightedFields
dataFormattedForFieldBrowser={dataFormattedForFieldBrowser}
investigationFields={investigationFields}
isPreview={false}
showCellActions={false}
/>
</EuiFlexItem>
{attackDiscoveryAlertsEnabled && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ const renderHighlightedFields = (showEditButton = false) =>
<HighlightedFields
dataFormattedForFieldBrowser={mockContextValue.dataFormattedForFieldBrowser}
investigationFields={mockContextValue.investigationFields}
isPreview={mockContextValue.isPreview}
scopeId={mockContextValue.scopeId}
showEditButton={showEditButton}
showCellActions={false}
/>
</TestProviders>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ export interface HighlightedFieldsTableRow {
* Only needed if alerts page flyout (which uses CellActions), NOT in the AI for SOC alert summary flyout.
*/
scopeId: string;
/**
* Boolean to indicate this field is shown in a preview
* Only needed if alerts page flyout (which uses CellActions), NOT in the AI for SOC alert summary flyout.
*/
isPreview: boolean;
/**
* If true, cell actions will be shown on hover
*/
Expand Down Expand Up @@ -114,20 +109,16 @@ export interface HighlightedFieldsProps {
* User defined fields to highlight (defined on the rule)
*/
investigationFields: string[];
/**
* Boolean to indicate whether flyout is opened in rule preview
*/
isPreview: boolean;
/**
* Maintain backwards compatibility // TODO remove when possible
* Only needed if alerts page flyout (which uses CellActions), NOT in the AI for SOC alert summary flyout.
*/
scopeId?: string;
/**
* If true, cell actions will be shown on hover.
* This is false by default (for the AI for SOC alert summary page) and will be true for the alerts page.
* This is false for the AI for SOC alert summary page and true for the alerts page.
*/
showCellActions?: boolean;
showCellActions: boolean;
/**
* If true, the edit button will be shown on hover (granted that the editHighlightedFieldsEnabled is also turned on).
* This is false by default (for the AI for SOC alert summary page) and will be true for the alerts page.
Expand All @@ -143,9 +134,8 @@ export const HighlightedFields = memo(
({
dataFormattedForFieldBrowser,
investigationFields,
isPreview,
scopeId = '',
showCellActions = false,
showCellActions,
showEditButton = false,
}: HighlightedFieldsProps) => {
const [isEditLoading, setIsEditLoading] = useState(false);
Expand All @@ -155,9 +145,8 @@ export const HighlightedFields = memo(
investigationFields,
});
const items = useMemo(
() =>
convertHighlightedFieldsToTableRow(highlightedFields, scopeId, isPreview, showCellActions),
[highlightedFields, scopeId, isPreview, showCellActions]
() => convertHighlightedFieldsToTableRow(highlightedFields, scopeId, showCellActions),
[highlightedFields, scopeId, showCellActions]
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const KEY = 'investigation';
* It contains investigation guide (alerts only) and highlighted fields.
*/
export const InvestigationSection = memo(() => {
const { dataFormattedForFieldBrowser, getFieldsData, investigationFields, isPreview, scopeId } =
const { dataFormattedForFieldBrowser, getFieldsData, investigationFields, scopeId } =
useDocumentDetailsContext();
const eventKind = getField(getFieldsData('event.kind'));

Expand Down Expand Up @@ -55,7 +55,6 @@ export const InvestigationSection = memo(() => {
<HighlightedFields
dataFormattedForFieldBrowser={dataFormattedForFieldBrowser}
investigationFields={investigationFields}
isPreview={isPreview}
scopeId={scopeId}
showCellActions={true}
showEditButton={editHighlightedFieldsEnabled}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import {
} from './highlighted_fields_helpers';

const scopeId = 'scopeId';
const isPreview = false;
const showCellActions = false;

describe('convertHighlightedFieldsToTableRow', () => {
Expand All @@ -21,20 +20,19 @@ describe('convertHighlightedFieldsToTableRow', () => {
values: ['host-1'],
},
};
expect(
convertHighlightedFieldsToTableRow(highlightedFields, scopeId, isPreview, showCellActions)
).toEqual([
{
field: 'host.name',
description: {
expect(convertHighlightedFieldsToTableRow(highlightedFields, scopeId, showCellActions)).toEqual(
[
{
field: 'host.name',
values: ['host-1'],
scopeId: 'scopeId',
isPreview,
showCellActions,
description: {
field: 'host.name',
values: ['host-1'],
scopeId: 'scopeId',
showCellActions,
},
},
},
]);
]
);
});

it('should convert take override name over default name and use original values if not present in the override', () => {
Expand All @@ -44,21 +42,20 @@ describe('convertHighlightedFieldsToTableRow', () => {
values: ['host-1'],
},
};
expect(
convertHighlightedFieldsToTableRow(highlightedFields, scopeId, isPreview, showCellActions)
).toEqual([
{
field: 'host.name-override',
description: {
expect(convertHighlightedFieldsToTableRow(highlightedFields, scopeId, showCellActions)).toEqual(
[
{
field: 'host.name-override',
originalField: 'host.name',
values: ['host-1'],
scopeId: 'scopeId',
isPreview,
showCellActions,
description: {
field: 'host.name-override',
originalField: 'host.name',
values: ['host-1'],
scopeId: 'scopeId',
showCellActions,
},
},
},
]);
]
);
});

it('should convert take override name over default name and use provided values', () => {
Expand All @@ -68,21 +65,20 @@ describe('convertHighlightedFieldsToTableRow', () => {
values: ['host-1'],
},
};
expect(
convertHighlightedFieldsToTableRow(highlightedFields, scopeId, isPreview, showCellActions)
).toEqual([
{
field: 'host.name-override',
description: {
expect(convertHighlightedFieldsToTableRow(highlightedFields, scopeId, showCellActions)).toEqual(
[
{
field: 'host.name-override',
originalField: 'host.name',
values: ['value override!'],
scopeId: 'scopeId',
isPreview,
showCellActions,
description: {
field: 'host.name-override',
originalField: 'host.name',
values: ['value override!'],
scopeId: 'scopeId',
showCellActions,
},
},
},
]);
]
);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import type { HighlightedFieldsTableRow } from '../../right/components/highlight
export const convertHighlightedFieldsToTableRow = (
highlightedFields: UseHighlightedFieldsResult,
scopeId: string,
isPreview: boolean,
showCellActions: boolean
): HighlightedFieldsTableRow[] => {
const fieldNames = Object.keys(highlightedFields);
Expand All @@ -38,7 +37,6 @@ export const convertHighlightedFieldsToTableRow = (
...(overrideFieldName ? { originalField: fieldName } : {}),
values,
scopeId,
isPreview,
showCellActions,
},
};
Expand Down