[Security Solution][Alert flyout] Fix dual hover actions in table tab (#212316)

## Summary

Ref: https://github.com/elastic/kibana/issues/212138

This PR fixed a bug where the fields in the table tab have 2 hover
actions, by pruning an unused branch in formatted fields (the [original
logic](https://github.com/elastic/kibana/pull/207959/files#diff-ccbcd249520d7f127960805d59a0ebfd00613785a2dd5b047545bb8b4e565e26L331)
was if the field is not draggable, show the value as text)


![image](https://github.com/user-attachments/assets/f9922476-cd8b-43f5-9c35-6ad790357da7)


### Checklist

- [ ] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)
- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [ ] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
christineweng 2025-02-26 20:03:35 -06:00 committed by GitHub
parent f8e31e5fcb
commit f7b7a6cafa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 7 additions and 31 deletions

View file

@ -226,7 +226,7 @@ describe('Events', () => {
expect(wrapper.find('[data-test-subj="truncatable-message"]').exists()).toEqual(true);
});
test('it does NOT render the truncatable message style when fieldName is NOT message', () => {
test('it does NOT render the truncatable message style when truncate is false', () => {
const wrapper = mount(
<TestProviders>
<FormattedFieldValue
@ -234,6 +234,7 @@ describe('Events', () => {
contextId="test"
fieldName="NOT-message"
fieldType="text"
truncate={false}
value={'a NON-message value'}
/>
</TestProviders>

View file

@ -22,7 +22,6 @@ import {
} from '../../../../../../common/field_maps/field_names';
import { AgentStatus } from '../../../../../common/components/endpoint/agents/agent_status';
import { INDICATOR_REFERENCE } from '../../../../../../common/cti/constants';
import { DefaultDraggable } from '../../../../../common/components/draggables';
import { Bytes, BYTES_FORMAT } from './bytes';
import { Duration, EVENT_DURATION_FIELD_NAME } from '../../../duration';
import { getOrEmptyTagFromValue } from '../../../../../common/components/empty_value';
@ -38,7 +37,6 @@ import {
EVENT_URL_FIELD_NAME,
GEO_FIELD_TYPE,
IP_FIELD_TYPE,
MESSAGE_FIELD_NAME,
REFERENCE_URL_FIELD_NAME,
RULE_REFERENCE_FIELD_NAME,
SIGNAL_RULE_NAME_FIELD_NAME,
@ -51,9 +49,6 @@ import { UserName } from './user_name';
import { AssetCriticalityLevel } from './asset_criticality_level';
import { ServiceName } from './service_name';
// simple black-list to prevent dragging and dropping fields such as message name
const columnNamesNotDraggable = [MESSAGE_FIELD_NAME];
// Offset top-aligned tooltips so that cell actions are more visible
const dataGridToolTipOffset = css`
&[data-position='top'] {
@ -226,7 +221,7 @@ const FormattedFieldValueComponent: React.FC<{
title,
value,
});
} else if (isUnifiedDataTable || columnNamesNotDraggable.includes(fieldName)) {
} else {
return truncate && !isEmpty(value) ? (
<TruncatableText data-test-subj="truncatable-message">
<EuiToolTip
@ -248,27 +243,7 @@ const FormattedFieldValueComponent: React.FC<{
</EuiToolTip>
</TruncatableText>
) : (
<span data-test-subj={`formatted-field-${fieldName}`}>{value}</span>
);
} else {
// This should not be reached for the unified data table
const contentValue = getOrEmptyTagFromValue(value);
const content = truncate ? <TruncatableText>{contentValue}</TruncatableText> : contentValue;
return (
<DefaultDraggable
field={fieldName}
id={`event-details-value-default-draggable-${contextId}-${eventId}-${fieldName}-${value}`}
fieldType={fieldType ?? ''}
isAggregatable={isAggregatable}
value={`${value}`}
tooltipContent={
fieldType === DATE_FIELD_TYPE || fieldType === EVENT_DURATION_FIELD_NAME
? null
: fieldName
}
>
{content}
</DefaultDraggable>
<span data-test-subj={`formatted-field-${fieldName}`}>{getOrEmptyTagFromValue(value)}</span>
);
}
};

View file

@ -27,9 +27,9 @@ export const ALERT_GRID_CELL = '[data-test-subj="dataGridRowCell"]';
export const ALERT_RULE_NAME = '[data-test-subj="formatted-field-kibana.alert.rule.name"]';
export const ALERT_RISK_SCORE = '[data-test-subj="render-content-kibana.alert.risk_score"]';
export const ALERT_RISK_SCORE = '[data-test-subj="formatted-field-kibana.alert.risk_score"]';
export const ALERT_SEVERITY = '[data-test-subj="render-content-kibana.alert.severity"]';
export const ALERT_SEVERITY = '[data-test-subj="formatted-field-kibana.alert.severity"]';
export const ALERT_DATA_GRID = '[data-test-subj="euiDataGridBody"]';

View file

@ -268,7 +268,7 @@ export const TIMESTAMP_HOVER_ACTION_OVERFLOW_BTN =
export const TIMELINE_STATUS = '[data-test-subj="timeline-save-status"]';
export const ALERT_TABLE_SEVERITY_VALUES =
'[data-test-subj="render-content-kibana.alert.severity"]';
'[data-test-subj="formatted-field-kibana.alert.severity"]';
export const ALERT_TABLE_FILE_NAME_HEADER = '[data-gridcell-column-id="file.name"]';