From d4d06bdf0d1d5dcb4532f00d2cbaa83fc61bb877 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 5 Apr 2024 11:37:40 -0400 Subject: [PATCH] [8.13] [Security Solution] fix alert dashboard filters (#179911) (#180187) # Backport This will backport the following commits from `main` to `8.13`: - [[Security Solution] fix alert dashboard filters (#179911)](https://github.com/elastic/kibana/pull/179911) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Luke G <11671118+lgestc@users.noreply.github.com> --- .../trigger_actions_alert_table/use_cell_actions.test.tsx | 2 ++ .../trigger_actions_alert_table/use_cell_actions.tsx | 8 +++++--- .../application/sections/alerts_table/alerts_table.tsx | 1 + x-pack/plugins/triggers_actions_ui/public/types.ts | 1 + 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_cell_actions.test.tsx b/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_cell_actions.test.tsx index c58fd2c22ec2a..c1600c73caa6a 100644 --- a/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_cell_actions.test.tsx +++ b/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_cell_actions.test.tsx @@ -94,6 +94,7 @@ describe('getUseCellActionsHook', () => { dataGridRef: mockDataGridRef, ecsData: [], pageSize: 10, + pageIndex: 0, }), { wrapper: TestProviderWithActions, @@ -118,6 +119,7 @@ describe('getUseCellActionsHook', () => { dataGridRef: mockDataGridRef, ecsData: [], pageSize: 10, + pageIndex: 0, }), { wrapper: TestProviderWithCustomStateAndActions, diff --git a/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_cell_actions.tsx b/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_cell_actions.tsx index 71eaa81c02626..a36678841a904 100644 --- a/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_cell_actions.tsx +++ b/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_cell_actions.tsx @@ -23,6 +23,8 @@ export const getUseCellActionsHook = (tableId: TableId) => { columns, data, dataGridRef, + pageSize, + pageIndex, }) => { const getFieldSpec = useGetFieldSpec(SourcererScopeName.detections); const dataViewId = useDataViewId(SourcererScopeName.detections); @@ -79,10 +81,10 @@ export const getUseCellActionsHook = (tableId: TableId) => { const getCellValue = useCallback( (fieldName, rowIndex) => { - const pageRowIndex = rowIndex % finalData.length; - return finalData[pageRowIndex].find((rowData) => rowData.field === fieldName)?.value ?? []; + const pageRowIndex = rowIndex - pageSize * pageIndex; + return finalData[pageRowIndex]?.find((rowData) => rowData.field === fieldName)?.value ?? []; }, - [finalData] + [finalData, pageIndex, pageSize] ); const disabledActionTypes = diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/alerts_table.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/alerts_table.tsx index fcb6186114963..2939d2cdcfca0 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/alerts_table.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alerts_table/alerts_table.tsx @@ -454,6 +454,7 @@ const AlertsTable: React.FunctionComponent = (props: AlertsTab ecsData: ecsAlertsData, dataGridRef, pageSize: pagination.pageSize, + pageIndex: pagination.pageIndex, }) : getCellActionsStub; diff --git a/x-pack/plugins/triggers_actions_ui/public/types.ts b/x-pack/plugins/triggers_actions_ui/public/types.ts index 0bbcc5e90c7a9..ad8d62fc0ea4d 100644 --- a/x-pack/plugins/triggers_actions_ui/public/types.ts +++ b/x-pack/plugins/triggers_actions_ui/public/types.ts @@ -668,6 +668,7 @@ export type UseCellActions = (props: { dataGridRef: RefObject; ecsData: unknown[]; pageSize: number; + pageIndex: number; }) => { // getCellAction function for system to return cell actions per Id getCellActions: (columnId: string, columnIndex: number) => EuiDataGridColumnCellAction[];