From 2f1bd4d6862d77db6d2dbf098fe0b7b7bedac476 Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Tue, 12 Apr 2022 18:55:10 +0200 Subject: [PATCH 1/2] fix: remove the cell actions for agent status As discussed in https://github.com/elastic/kibana/issues/127010, the agent.status should not have hover actions --- .../table/summary_value_cell.test.tsx | 38 ++++++++++++++++++- .../table/summary_value_cell.tsx | 32 +++++++++------- 2 files changed, 55 insertions(+), 15 deletions(-) diff --git a/x-pack/plugins/security_solution/public/common/components/event_details/table/summary_value_cell.test.tsx b/x-pack/plugins/security_solution/public/common/components/event_details/table/summary_value_cell.test.tsx index b51aeb3253eee..10c4c839ee2e6 100644 --- a/x-pack/plugins/security_solution/public/common/components/event_details/table/summary_value_cell.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/event_details/table/summary_value_cell.test.tsx @@ -14,6 +14,7 @@ import { TestProviders } from '../../../mock'; import { EventFieldsData } from '../types'; import { AlertSummaryRow } from '../helpers'; import { TimelineId } from '../../../../../common/types'; +import { AGENT_STATUS_FIELD_NAME } from '../../../../timelines/components/timeline/body/renderers/constants'; jest.mock('../../../lib/kibana'); @@ -52,6 +53,27 @@ const enrichedHostIpData: AlertSummaryRow['description'] = { values: [...hostIpValues], }; +const enrichedAgentStatusData: AlertSummaryRow['description'] = { + data: { + field: AGENT_STATUS_FIELD_NAME, + format: '', + type: '', + aggregatable: false, + description: '', + example: '', + category: '', + fields: {}, + indexes: [], + name: AGENT_STATUS_FIELD_NAME, + searchable: false, + readFromDocValues: false, + isObjectArray: false, + }, + eventId, + values: [], + timelineId: TimelineId.test, +}; + describe('SummaryValueCell', () => { test('it should render', async () => { render( @@ -64,8 +86,8 @@ describe('SummaryValueCell', () => { expect(screen.getAllByTestId('test-filter-out')).toHaveLength(1); }); - describe('When in the timeline flyout with timelineId active', () => { - test('it should not render the default hover actions', async () => { + describe('Without hover actions', () => { + test('When in the timeline flyout with timelineId active', async () => { render( @@ -75,5 +97,17 @@ describe('SummaryValueCell', () => { expect(screen.queryByTestId('test-filter-for')).toBeNull(); expect(screen.queryByTestId('test-filter-out')).toBeNull(); }); + + test('When rendering the host status field', async () => { + render( + + + + ); + + expect(screen.getByTestId('event-field-agent.status')).toBeInTheDocument(); + expect(screen.queryByTestId('test-filter-for')).toBeNull(); + expect(screen.queryByTestId('test-filter-out')).toBeNull(); + }); }); }); diff --git a/x-pack/plugins/security_solution/public/common/components/event_details/table/summary_value_cell.tsx b/x-pack/plugins/security_solution/public/common/components/event_details/table/summary_value_cell.tsx index ad9ca84429f00..6db5eb1446628 100644 --- a/x-pack/plugins/security_solution/public/common/components/event_details/table/summary_value_cell.tsx +++ b/x-pack/plugins/security_solution/public/common/components/event_details/table/summary_value_cell.tsx @@ -12,6 +12,10 @@ import { FieldValueCell } from './field_value_cell'; import { AlertSummaryRow } from '../helpers'; import { TimelineId } from '../../../../../common/types'; +import { AGENT_STATUS_FIELD_NAME } from '../../../../timelines/components/timeline/body/renderers/constants'; + +const FIELDS_WITHOUT_ACTIONS = [AGENT_STATUS_FIELD_NAME]; + export const SummaryValueCell: React.FC = ({ data, eventId, @@ -33,19 +37,21 @@ export const SummaryValueCell: React.FC = ({ style={{ flexGrow: 0 }} values={values} /> - {timelineId !== TimelineId.active && !isReadOnly && ( - - )} + {timelineId !== TimelineId.active && + !isReadOnly && + !FIELDS_WITHOUT_ACTIONS.includes(data.field) && ( + + )} ); From 8be2307c66a4d1b95b601483e6373e34cc990aa3 Mon Sep 17 00:00:00 2001 From: Jan Monschke Date: Tue, 12 Apr 2022 19:08:55 +0200 Subject: [PATCH 2/2] chore: use object-lookup instead of array.includes --- .../table/summary_value_cell.tsx | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/x-pack/plugins/security_solution/public/common/components/event_details/table/summary_value_cell.tsx b/x-pack/plugins/security_solution/public/common/components/event_details/table/summary_value_cell.tsx index 6db5eb1446628..1c9c0292ed912 100644 --- a/x-pack/plugins/security_solution/public/common/components/event_details/table/summary_value_cell.tsx +++ b/x-pack/plugins/security_solution/public/common/components/event_details/table/summary_value_cell.tsx @@ -14,7 +14,7 @@ import { TimelineId } from '../../../../../common/types'; import { AGENT_STATUS_FIELD_NAME } from '../../../../timelines/components/timeline/body/renderers/constants'; -const FIELDS_WITHOUT_ACTIONS = [AGENT_STATUS_FIELD_NAME]; +const FIELDS_WITHOUT_ACTIONS: { [field: string]: boolean } = { [AGENT_STATUS_FIELD_NAME]: true }; export const SummaryValueCell: React.FC = ({ data, @@ -37,21 +37,19 @@ export const SummaryValueCell: React.FC = ({ style={{ flexGrow: 0 }} values={values} /> - {timelineId !== TimelineId.active && - !isReadOnly && - !FIELDS_WITHOUT_ACTIONS.includes(data.field) && ( - - )} + {timelineId !== TimelineId.active && !isReadOnly && !FIELDS_WITHOUT_ACTIONS[data.field] && ( + + )} );