Skip to content

Commit

Permalink
[8.13] [Security Solution] fix alert dashboard filters (#179911) (#18…
Browse files Browse the repository at this point in the history
…0187)

# Backport

This will backport the following commits from `main` to `8.13`:
- [[Security Solution] fix alert dashboard filters
(#179911)](#179911)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Luke
G","email":"11671118+lgestc@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-04-05T14:14:39Z","message":"[Security
Solution] fix alert dashboard filters (#179911)\n\n## Summary\r\nThis PR
fixes the following
issue:\r\nhttps://github.com//issues/177906\r\n\r\nApplied
the fix suggested by Xavier, and it seems to resolve the
issue.\r\n\r\nTo test:\r\n1. On current main, generate large volume of
alerts, switch to 100 rows\r\nper page, then go to the last page.\r\n2.
Filter in on any column, eg. @timestamp. You should see the
exact\r\nvalue applied to top
filters.","sha":"3d4ffac06aab70a48e4ae3564c89e323c3daef55","branchLabelMapping":{"^v8.14.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:ResponseOps","Team:Threat
Hunting:Investigations","backport:prev-minor","v8.14.0"],"title":"[Security
Solution] fix alert dashboard
filters","number":179911,"url":"#179911
Solution] fix alert dashboard filters (#179911)\n\n## Summary\r\nThis PR
fixes the following
issue:\r\nhttps://github.com//issues/177906\r\n\r\nApplied
the fix suggested by Xavier, and it seems to resolve the
issue.\r\n\r\nTo test:\r\n1. On current main, generate large volume of
alerts, switch to 100 rows\r\nper page, then go to the last page.\r\n2.
Filter in on any column, eg. @timestamp. You should see the
exact\r\nvalue applied to top
filters.","sha":"3d4ffac06aab70a48e4ae3564c89e323c3daef55"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.14.0","branchLabelMappingKey":"^v8.14.0$","isSourceBranch":true,"state":"MERGED","url":"#179911
Solution] fix alert dashboard filters (#179911)\n\n## Summary\r\nThis PR
fixes the following
issue:\r\nhttps://github.com//issues/177906\r\n\r\nApplied
the fix suggested by Xavier, and it seems to resolve the
issue.\r\n\r\nTo test:\r\n1. On current main, generate large volume of
alerts, switch to 100 rows\r\nper page, then go to the last page.\r\n2.
Filter in on any column, eg. @timestamp. You should see the
exact\r\nvalue applied to top
filters.","sha":"3d4ffac06aab70a48e4ae3564c89e323c3daef55"}}]}]
BACKPORT-->

Co-authored-by: Luke G <11671118+lgestc@users.noreply.github.com>
  • Loading branch information
kibanamachine and lgestc committed Apr 5, 2024
1 parent 6e8ab9e commit d4d06bd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
Expand Up @@ -94,6 +94,7 @@ describe('getUseCellActionsHook', () => {
dataGridRef: mockDataGridRef,
ecsData: [],
pageSize: 10,
pageIndex: 0,
}),
{
wrapper: TestProviderWithActions,
Expand All @@ -118,6 +119,7 @@ describe('getUseCellActionsHook', () => {
dataGridRef: mockDataGridRef,
ecsData: [],
pageSize: 10,
pageIndex: 0,
}),
{
wrapper: TestProviderWithCustomStateAndActions,
Expand Down
Expand Up @@ -23,6 +23,8 @@ export const getUseCellActionsHook = (tableId: TableId) => {
columns,
data,
dataGridRef,
pageSize,
pageIndex,
}) => {
const getFieldSpec = useGetFieldSpec(SourcererScopeName.detections);
const dataViewId = useDataViewId(SourcererScopeName.detections);
Expand Down Expand Up @@ -79,10 +81,10 @@ export const getUseCellActionsHook = (tableId: TableId) => {

const getCellValue = useCallback<UseDataGridColumnsSecurityCellActionsProps['getCellValue']>(
(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 =
Expand Down
Expand Up @@ -454,6 +454,7 @@ const AlertsTable: React.FunctionComponent<AlertsTableProps> = (props: AlertsTab
ecsData: ecsAlertsData,
dataGridRef,
pageSize: pagination.pageSize,
pageIndex: pagination.pageIndex,
})
: getCellActionsStub;

Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/triggers_actions_ui/public/types.ts
Expand Up @@ -668,6 +668,7 @@ export type UseCellActions = (props: {
dataGridRef: RefObject<EuiDataGridRefProps>;
ecsData: unknown[];
pageSize: number;
pageIndex: number;
}) => {
// getCellAction function for system to return cell actions per Id
getCellActions: (columnId: string, columnIndex: number) => EuiDataGridColumnCellAction[];
Expand Down

0 comments on commit d4d06bd

Please sign in to comment.