From 465f50087cd040ef03e6ccec1cb7737427a713ce Mon Sep 17 00:00:00 2001 From: Jatin Kathuria Date: Mon, 8 Jul 2024 09:00:25 +0200 Subject: [PATCH] [8.14] [Security Solution][Alert table] Fix alert table refresh with bulk action (#183674) (#187722) # Backport This will backport the following commits from `main` to `8.14`: - [[Security Solution][Alert table] Fix alert table refresh with bulk action (#183674)](https://github.com/elastic/kibana/pull/183674) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: christineweng <18648970+christineweng@users.noreply.github.com> --- .../use_bulk_actions.tsx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_bulk_actions.tsx b/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_bulk_actions.tsx index 03e2655ff4047..aa798b00dc969 100644 --- a/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_bulk_actions.tsx +++ b/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_bulk_actions.tsx @@ -10,7 +10,7 @@ import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/type import type { SerializableRecord } from '@kbn/utility-types'; import { isEqual } from 'lodash'; import type { Filter } from '@kbn/es-query'; -import { useMemo } from 'react'; +import { useMemo, useCallback } from 'react'; import type { TableId } from '@kbn/securitysolution-data-table'; import { useBulkAlertAssigneesItems } from '../../../common/components/toolbar/bulk_actions/use_bulk_alert_assignees_items'; import { useBulkAlertTagsItems } from '../../../common/components/toolbar/bulk_actions/use_bulk_alert_tags_items'; @@ -18,6 +18,9 @@ import { SourcererScopeName } from '../../../common/store/sourcerer/model'; import { useGlobalTime } from '../../../common/containers/use_global_time'; import { useAddBulkToTimelineAction } from '../../components/alerts_table/timeline_actions/use_add_bulk_to_timeline'; import { useBulkAlertActionItems } from './use_alert_actions'; +import { useDeepEqualSelector } from '../../../common/hooks/use_selector'; +import type { inputsModel } from '../../../common/store'; +import { inputsSelectors } from '../../../common/store'; // check to see if the query is a known "empty" shape export function isKnownEmptyQuery(query: QueryDslQueryContainer) { @@ -82,6 +85,14 @@ export const getBulkActionHook = }; }, [filters, from, to]); + const getGlobalQueriesSelector = useMemo(() => inputsSelectors.globalQuery(), []); + const globalQueries = useDeepEqualSelector(getGlobalQueriesSelector); + + const refetch = useCallback(() => { + refresh(); + globalQueries.forEach((q) => q.refetch && (q.refetch as inputsModel.Refetch)()); + }, [globalQueries, refresh]); + const alertActionParams = useMemo(() => { return { scopeId: SourcererScopeName.detections, @@ -89,9 +100,9 @@ export const getBulkActionHook = from, to, tableId, - refetch: refresh, + refetch, }; - }, [from, to, filters, refresh]); + }, [from, to, filters, refetch]); const bulkAlertTagParams = useMemo(() => { return {