44 * 2.0; you may not use this file except in compliance with the Elastic License
55 * 2.0.
66 */
7-
87import type { AlertConsumers } from '@kbn/rule-data-utils' ;
98import deepEqual from 'fast-deep-equal' ;
109import { isEmpty , isString , noop } from 'lodash/fp' ;
@@ -13,10 +12,15 @@ import { useDispatch } from 'react-redux';
1312import { Subscription } from 'rxjs' ;
1413import { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/typesWithBodyKey' ;
1514import type { DataView } from '@kbn/data-views-plugin/public' ;
16-
1715import type { DataPublicPluginStart } from '@kbn/data-plugin/public' ;
1816import { isCompleteResponse , isErrorResponse } from '@kbn/data-plugin/common' ;
19- import { clearEventsLoading , clearEventsDeleted , setTableUpdatedAt } from '../store/t_grid/actions' ;
17+
18+ import {
19+ clearEventsLoading ,
20+ clearEventsDeleted ,
21+ setTableUpdatedAt ,
22+ updateGraphEventId ,
23+ } from '../store/t_grid/actions' ;
2024import {
2125 Direction ,
2226 TimelineFactoryQueryTypes ,
@@ -34,7 +38,7 @@ import type {
3438 TimelineRequestSortField ,
3539} from '../../common/search_strategy' ;
3640import type { ESQuery } from '../../common/typed_json' ;
37- import type { KueryFilterQueryKind } from '../../common/types/timeline' ;
41+ import type { KueryFilterQueryKind , AlertStatus } from '../../common/types/timeline' ;
3842import { useAppToasts } from '../hooks/use_app_toasts' ;
3943import { TableId } from '../store/t_grid/types' ;
4044import * as i18n from './translations' ;
@@ -82,6 +86,7 @@ export interface UseTimelineEventsProps {
8286 sort ?: TimelineRequestSortField [ ] ;
8387 startDate : string ;
8488 timerangeKind ?: 'absolute' | 'relative' ;
89+ filterStatus ?: AlertStatus ;
8590}
8691
8792const createFilter = ( filterQuery : ESQuery | string | undefined ) =>
@@ -154,6 +159,7 @@ export const useTimelineEvents = ({
154159 skip = false ,
155160 timerangeKind,
156161 data,
162+ filterStatus,
157163} : UseTimelineEventsProps ) : [ boolean , TimelineArgs ] => {
158164 const dispatch = useDispatch ( ) ;
159165 const { startTracking } = useApmTracking ( id ) ;
@@ -165,6 +171,7 @@ export const useTimelineEvents = ({
165171 const [ timelineRequest , setTimelineRequest ] = useState < TimelineRequest < typeof language > | null > (
166172 null
167173 ) ;
174+ const [ prevFilterStatus , setFilterStatus ] = useState ( filterStatus ) ;
168175 const prevTimelineRequest = useRef < TimelineRequest < typeof language > | null > ( null ) ;
169176
170177 const clearSignalsState = useCallback ( ( ) => {
@@ -259,6 +266,10 @@ export const useTimelineEvents = ({
259266 setUpdated ( newTimelineResponse . updatedAt ) ;
260267 return newTimelineResponse ;
261268 } ) ;
269+ if ( prevFilterStatus !== request . filterStatus ) {
270+ dispatch ( updateGraphEventId ( { id, graphEventId : '' } ) ) ;
271+ }
272+ setFilterStatus ( request . filterStatus ) ;
262273 setLoading ( false ) ;
263274
264275 searchSubscription$ . current . unsubscribe ( ) ;
@@ -284,7 +295,18 @@ export const useTimelineEvents = ({
284295 asyncSearch ( ) ;
285296 refetch . current = asyncSearch ;
286297 } ,
287- [ skip , data , entityType , dataViewId , setUpdated , addWarning , startTracking ]
298+ [
299+ skip ,
300+ data ,
301+ entityType ,
302+ dataViewId ,
303+ setUpdated ,
304+ addWarning ,
305+ startTracking ,
306+ dispatch ,
307+ id ,
308+ prevFilterStatus ,
309+ ]
288310 ) ;
289311
290312 useEffect ( ( ) => {
@@ -300,6 +322,7 @@ export const useTimelineEvents = ({
300322 sort : prevRequest ?. sort ?? initSortDefault ,
301323 timerange : prevRequest ?. timerange ?? { } ,
302324 runtimeMappings : prevRequest ?. runtimeMappings ?? { } ,
325+ filterStatus : prevRequest ?. filterStatus ,
303326 } ;
304327
305328 const currentSearchParameters = {
@@ -339,6 +362,7 @@ export const useTimelineEvents = ({
339362 from : startDate ,
340363 to : endDate ,
341364 } ,
365+ filterStatus,
342366 } ;
343367
344368 if ( activePage !== newActivePage ) {
@@ -364,6 +388,7 @@ export const useTimelineEvents = ({
364388 sort ,
365389 fields ,
366390 runtimeMappings ,
391+ filterStatus ,
367392 ] ) ;
368393
369394 useEffect ( ( ) => {
0 commit comments