Skip to content

Commit

Permalink
[8.14] [Security Solution][Alert table] Fix alert table refresh with …
Browse files Browse the repository at this point in the history
…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)](#183674)

<!--- Backport version: 8.9.8 -->

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

<!--BACKPORT
[{"author":{"name":"christineweng","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-05-29T18:43:24Z","message":"[Security
Solution][Alert table] Fix alert table refresh with bulk action
(#183674)\n\n## Summary\r\n\r\nCurrently components outside of alert
table do not refresh after\r\nchanging status with bulk action. This PR
adds global query refresh in\r\nbulk actions\r\n\r\n-
https://github.com/elastic/kibana/issues/183025\r\n\r\nNo
grouping\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/18648970/0490187d-9f3e-49d0-80b3-4cd75e8fdbf8\r\n\r\n\r\n\r\nGrouping\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/18648970/80e55fda-2f89-4c8d-a882-2df413cb3560","sha":"993903bb6177666b1dfd4b8ebf7fa4fa0ad4aed5","branchLabelMapping":{"^v8.15.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Threat
Hunting:Investigations","backport:prev-minor","v8.15.0","v8.14.3"],"number":183674,"url":"https://github.com/elastic/kibana/pull/183674","mergeCommit":{"message":"[Security
Solution][Alert table] Fix alert table refresh with bulk action
(#183674)\n\n## Summary\r\n\r\nCurrently components outside of alert
table do not refresh after\r\nchanging status with bulk action. This PR
adds global query refresh in\r\nbulk actions\r\n\r\n-
https://github.com/elastic/kibana/issues/183025\r\n\r\nNo
grouping\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/18648970/0490187d-9f3e-49d0-80b3-4cd75e8fdbf8\r\n\r\n\r\n\r\nGrouping\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/18648970/80e55fda-2f89-4c8d-a882-2df413cb3560","sha":"993903bb6177666b1dfd4b8ebf7fa4fa0ad4aed5"}},"sourceBranch":"main","suggestedTargetBranches":["8.14"],"targetPullRequestStates":[{"branch":"main","label":"v8.15.0","labelRegex":"^v8.15.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/183674","number":183674,"mergeCommit":{"message":"[Security
Solution][Alert table] Fix alert table refresh with bulk action
(#183674)\n\n## Summary\r\n\r\nCurrently components outside of alert
table do not refresh after\r\nchanging status with bulk action. This PR
adds global query refresh in\r\nbulk actions\r\n\r\n-
https://github.com/elastic/kibana/issues/183025\r\n\r\nNo
grouping\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/18648970/0490187d-9f3e-49d0-80b3-4cd75e8fdbf8\r\n\r\n\r\n\r\nGrouping\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/18648970/80e55fda-2f89-4c8d-a882-2df413cb3560","sha":"993903bb6177666b1dfd4b8ebf7fa4fa0ad4aed5"}},{"branch":"8.14","label":"v8.14.3","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: christineweng <[email protected]>
  • Loading branch information
logeekal and christineweng committed Jul 8, 2024
1 parent 2f141d9 commit 465f500
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 465f500

Please sign in to comment.