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 @@ -9,6 +9,7 @@ import React, { memo, useCallback, useMemo, useState } from 'react';
import { EuiButtonIcon, EuiContextMenu, EuiPopover } from '@elastic/eui';
import type { EcsSecurityExtension as Ecs } from '@kbn/securitysolution-ecs';
import { i18n } from '@kbn/i18n';
import { flattenObject } from '@kbn/object-utils';
import { useAlertTagsActions } from '../../alerts_table/timeline_actions/use_alert_tags_actions';
import { useAddToCaseActions } from '../../alerts_table/timeline_actions/use_add_to_case_actions';

Expand Down Expand Up @@ -62,8 +63,17 @@ export const MoreActionsRowControlColumn = memo(
[togglePopover]
);

const nonEcsData = useMemo(() => {
const flattened = flattenObject(ecsAlert);
return Object.entries(flattened).map(([key, value]) => ({
field: key,
value: value as string[],
}));
}, [ecsAlert]);

const { addToCaseActionItems } = useAddToCaseActions({
ecsData: ecsAlert,
nonEcsData,
onMenuItemClick: closePopover,
ariaLabel: ADD_TO_CASE_ARIA_LABEL,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ const defaultProps = {
name: ['test-host'],
},
},
nonEcsData: [
{ field: 'event.kind', value: ['signal'] },
{ field: 'host.name', value: ['test-host'] },
],
refetch,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import type { AlertTableContextMenuItem } from '../types';
export interface UseAddToCaseActions {
onMenuItemClick: () => void;
ariaLabel?: string;
ecsData?: Ecs;
nonEcsData?: TimelineNonEcsData[];
ecsData: Ecs;
nonEcsData: TimelineNonEcsData[];
onSuccess?: () => Promise<void>;
refetch?: (() => void) | undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import React, { memo, useCallback, useMemo, useState } from 'react';
import { EuiButton, EuiContextMenu, EuiPopover } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { flattenObject } from '@kbn/object-utils';
import { useAIForSOCDetailsContext } from '../context';
import { useAddToCaseActions } from '../../../detections/components/alerts_table/timeline_actions/use_add_to_case_actions';
import { useAlertTagsActions } from '../../../detections/components/alerts_table/timeline_actions/use_alert_tags_actions';
Expand Down Expand Up @@ -59,8 +60,17 @@ export const TakeActionButton = memo(() => {
[togglePopover]
);

const nonEcsData = useMemo(() => {
const flattened = flattenObject(dataAsNestedObject);
return Object.entries(flattened).map(([key, value]) => ({
field: key,
value: value as string[],
}));
}, [dataAsNestedObject]);

const { addToCaseActionItems } = useAddToCaseActions({
ecsData: dataAsNestedObject,
nonEcsData,
onMenuItemClick: closePopover,
ariaLabel: ADD_TO_CASE_ARIA_LABEL,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export interface TakeActionDropdownProps {
/**
* The actual raw document object
*/
dataAsNestedObject?: Ecs;
dataAsNestedObject: Ecs;
/**
* Callback called when the popover closes
*/
Expand Down