[Security Solution][Bug] Alert Table raises error when switchting to event rendered view (#151994)

## Summary

This PR handles: 

1. #151992 [Security Solution] Alert Table raises error when switching
to event rendered view.
- Issue was related `cellActions` package where changes in columns was
not leading to re-calculation of cell actions on those new columns.
3. Minor table width issue - Sometime table is not expanded to the 100%
of the container width.

## Before


https://user-images.githubusercontent.com/7485038/220914906-dcce7ba1-0318-44fd-a097-df86344f7727.mov

## After ( Resolved Issue 1 & 2)


https://user-images.githubusercontent.com/7485038/220921916-fa4b36ad-b8e1-4a8d-ad0d-a778c911bb5b.mov
This commit is contained in:
Jatin Kathuria 2023-02-24 15:11:06 +01:00 committed by GitHub
parent ee3e5eb66c
commit 1af75fd500
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 2 deletions

View file

@ -176,5 +176,28 @@ describe('loadActions hooks', () => {
expect(result.current.value).toEqual([[actionEnabled], [actionEnabled]]);
});
it('should re-render when contexts is changed', async () => {
const { result, rerender, waitForNextUpdate } = renderHook(useBulkLoadActions, {
initialProps: [actionContext],
});
await waitForNextUpdate();
expect(mockGetActions).toHaveBeenCalledWith(actionContext);
rerender([actionContext2]);
await waitForNextUpdate();
expect(mockGetActions).toHaveBeenCalledWith(actionContext2);
mockGetActions.mockClear();
rerender([]);
await waitForNextUpdate();
expect(mockGetActions).toHaveBeenCalledTimes(0);
expect(result.current.value).toBeInstanceOf(Array);
expect(result.current.value).toHaveLength(0);
expect(result.current.loading).toBe(false);
});
});
});

View file

@ -66,7 +66,7 @@ export const useBulkLoadActions = (
)
)
),
[]
[contexts]
);
useThrowError(error);
return actionsState;

View file

@ -282,8 +282,8 @@ export const AlertsTableComponent: FC<DetectionEngineAlertTableProps> = ({
id: tableId,
title: i18n.SESSIONS_TITLE,
defaultColumns: finalColumns.map((c) => ({
...c,
initialWidth: DEFAULT_COLUMN_MIN_WIDTH,
...c,
})),
})
);