Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution][Alert table] Fix alert table refresh with bulk action #183674

Merged
merged 3 commits into from
May 29, 2024

Conversation

christineweng
Copy link
Contributor

@christineweng christineweng commented May 16, 2024

Summary

Currently components outside of alert table do not refresh after changing status with bulk action. This PR adds global query refresh in bulk actions

No grouping

Screen.Recording.2024-05-16.at.2.32.14.PM.mov

Grouping

Screen.Recording.2024-05-16.at.2.33.09.PM.mov

@christineweng
Copy link
Contributor Author

/ci

@christineweng christineweng marked this pull request as ready for review May 16, 2024 20:19
@christineweng christineweng requested review from a team as code owners May 16, 2024 20:19
@elasticmachine
Copy link
Contributor

Pinging @elastic/security-threat-hunting-investigations (Team:Threat Hunting:Investigations)

Copy link
Contributor

@PhilippeOberti PhilippeOberti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

desk tested and the fix works perfectly! I left a couple of small comments on the code

Copy link
Contributor

@logeekal logeekal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@christineweng, Left one comment. Let me know what you think. If needed, we can discuss it offline as well.

@@ -286,6 +292,7 @@ export const AlertsTableComponent: FC<DetectionEngineAlertTableProps> = ({
showSortSelector: !isEventRenderedView,
},
dynamicRowHeight: isEventRenderedView,
customRefetch,
Copy link
Contributor

@logeekal logeekal May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think, instead of passing a new prop to trigger actions table, we can make use of onUpdate prop?

We can may be trigger customRefetch everytime the table is updated? But I think there might be cases which it will get into infinite render loop.

Alternatively, I would ask you to take a look at below file. It creates bulk actions and passes to the Alert Table. May be here we can call global query refetch directly. This might keep refetch responsibilities well separated and we will probably avoid unintended re-renders.

export const getBulkActionHook =
(tableId: TableId): AlertsTableConfigurationRegistry['useBulkActions'] =>
(query, refresh) => {
const { from, to } = useGlobalTime();
const filters = useMemo(() => {
return getFiltersForDSLQuery(query);

Let me know what you think.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@logeekal thank you for pointing me to this file! i have moved the logic to this hook and under alert actions. it should refresh the global queries only when alert status changes

@christineweng christineweng requested a review from a team as a code owner May 28, 2024 22:02
@christineweng christineweng removed the request for review from a team May 28, 2024 22:02
@kibana-ci
Copy link
Collaborator

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 15.2MB 15.2MB +162.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @christineweng

Copy link
Contributor

@logeekal logeekal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay so Code looks good and Desk Testing works great. Thank you very much for making these changes.

Consider adding at least one cypress tests, may be for KPIs visualization which will make sure that this issue does not occur again.

@christineweng
Copy link
Contributor Author

Consider adding at least one cypress tests, may be for KPIs visualization which will make sure that this issue does not occur again.

Good call. I realized we don't have a lot of cypress coverage for the KPI charts.. created a ticket for it

@christineweng christineweng merged commit 993903b into elastic:main May 29, 2024
37 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:fix Team:Threat Hunting:Investigations Security Solution Investigations Team v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants