Skip to content

Commit

Permalink
[Security Solution][Alert table] Fix alert table refresh with bulk ac…
Browse files Browse the repository at this point in the history
…tion (#183674)

## 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

- #183025

No grouping


https://github.com/elastic/kibana/assets/18648970/0490187d-9f3e-49d0-80b3-4cd75e8fdbf8



Grouping


https://github.com/elastic/kibana/assets/18648970/80e55fda-2f89-4c8d-a882-2df413cb3560
  • Loading branch information
christineweng authored May 29, 2024
1 parent e221be3 commit 993903b
Showing 1 changed file with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ 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';
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) {
Expand Down Expand Up @@ -82,16 +85,24 @@ 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,
filters,
from,
to,
tableId,
refetch: refresh,
refetch,
};
}, [from, to, filters, refresh]);
}, [from, to, filters, refetch]);

const bulkAlertTagParams = useMemo(() => {
return {
Expand Down

0 comments on commit 993903b

Please sign in to comment.