Skip to content

Commit

Permalink
fix: remove the cell actions for agent status
Browse files Browse the repository at this point in the history
As discussed in #127010, the agent.status should not have hover actions
  • Loading branch information
janmonschke committed Apr 12, 2022
1 parent a897747 commit 2f1bd4d
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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(
Expand All @@ -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(
<TestProviders>
<SummaryValueCell {...enrichedHostIpData} timelineId={TimelineId.active} />
Expand All @@ -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(
<TestProviders>
<SummaryValueCell {...enrichedAgentStatusData} />
</TestProviders>
);

expect(screen.getByTestId('event-field-agent.status')).toBeInTheDocument();
expect(screen.queryByTestId('test-filter-for')).toBeNull();
expect(screen.queryByTestId('test-filter-out')).toBeNull();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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<AlertSummaryRow['description']> = ({
data,
eventId,
Expand All @@ -33,19 +37,21 @@ export const SummaryValueCell: React.FC<AlertSummaryRow['description']> = ({
style={{ flexGrow: 0 }}
values={values}
/>
{timelineId !== TimelineId.active && !isReadOnly && (
<ActionCell
contextId={timelineId}
data={data}
eventId={eventId}
fieldFromBrowserField={fieldFromBrowserField}
linkValue={linkValue}
timelineId={timelineId}
values={values}
applyWidthAndPadding={false}
hideAddToTimeline={false}
/>
)}
{timelineId !== TimelineId.active &&
!isReadOnly &&
!FIELDS_WITHOUT_ACTIONS.includes(data.field) && (
<ActionCell
contextId={timelineId}
data={data}
eventId={eventId}
fieldFromBrowserField={fieldFromBrowserField}
linkValue={linkValue}
timelineId={timelineId}
values={values}
applyWidthAndPadding={false}
hideAddToTimeline={false}
/>
)}
</>
);

Expand Down

0 comments on commit 2f1bd4d

Please sign in to comment.