Skip to content

Commit 3cc4fb7

Browse files
authored
[Security Solution][Sourcerer] Fix cell actions for DV manager (#224812)
## Summary Prior to this change, with data view manager feature flag enabled, we would only see the "expand" cell action in the alerts. Now, all the actions should be visible. This was because cell actions rendering was unintentinally omitted in the initial batch of changes that added data view sourcing from the new store / hooks. fixes elastic/security-team#12853 ### Testing ``` xpack.securitySolution.enableExperimental: ['newDataViewPickerEnabled'] ``` then navigate to alerts page, hovering on timeline cell for example should render full set of hover actions. ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] [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
1 parent ba6b874 commit 3cc4fb7

File tree

1 file changed

+12
-3
lines changed
  • x-pack/solutions/security/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table

1 file changed

+12
-3
lines changed

x-pack/solutions/security/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_cell_actions.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import type { TimelineNonEcsData } from '@kbn/timelines-plugin/common';
99
import { useCallback, useMemo } from 'react';
1010
import { TableId } from '@kbn/securitysolution-data-table';
1111
import type { RenderContext } from '@kbn/response-ops-alerts-table/types';
12+
import { useIsExperimentalFeatureEnabled } from '../../../common/hooks/use_experimental_features';
1213
import type { UseDataGridColumnsSecurityCellActionsProps } from '../../../common/components/cell_actions';
1314
import { useDataGridColumnsSecurityCellActions } from '../../../common/components/cell_actions';
1415
import { SecurityCellActionsTrigger, SecurityCellActionType } from '../../../app/actions/constants';
@@ -19,6 +20,7 @@ import type {
1920
SecurityAlertsTableContext,
2021
GetSecurityAlertsTableProp,
2122
} from '../../components/alerts_table/types';
23+
import { useDataView } from '../../../data_view_manager/hooks/use_data_view';
2224

2325
export const useCellActionsOptions = (
2426
tableId: TableId,
@@ -27,6 +29,9 @@ export const useCellActionsOptions = (
2729
'columns' | 'oldAlertsData' | 'pageIndex' | 'pageSize' | 'dataGridRef'
2830
>
2931
) => {
32+
const newDataViewPickerEnabled = useIsExperimentalFeatureEnabled('newDataViewPickerEnabled');
33+
const dataView = useDataView(SourcererScopeName.detections);
34+
3035
const {
3136
columns = [],
3237
oldAlertsData: data = [],
@@ -35,7 +40,9 @@ export const useCellActionsOptions = (
3540
dataGridRef,
3641
} = context ?? {};
3742
const getFieldSpec = useGetFieldSpec(SourcererScopeName.detections);
38-
const dataViewId = useDataViewId(SourcererScopeName.detections);
43+
const oldDataViewId = useDataViewId(SourcererScopeName.detections);
44+
const dataViewId = newDataViewPickerEnabled ? dataView?.dataView?.id : oldDataViewId;
45+
3946
const cellActionsMetadata = useMemo(
4047
() => ({ scopeId: tableId, dataViewId }),
4148
[dataViewId, tableId]
@@ -44,14 +51,16 @@ export const useCellActionsOptions = (
4451
() =>
4552
columns.map(
4653
(column) =>
47-
getFieldSpec(column.id) ?? {
54+
(newDataViewPickerEnabled
55+
? dataView.dataView?.fields?.getByName(column.id)?.toSpec()
56+
: getFieldSpec(column.id)) ?? {
4857
name: '',
4958
type: '', // When type is an empty string all cell actions are incompatible
5059
aggregatable: false,
5160
searchable: false,
5261
}
5362
),
54-
[columns, getFieldSpec]
63+
[columns, dataView.dataView?.fields, getFieldSpec, newDataViewPickerEnabled]
5564
);
5665

5766
/**

0 commit comments

Comments
 (0)