Skip to content

Commit 494aa9c

Browse files
[Security Solution][Analyzer] Fix graph overlay persist despite filter group changes (elastic#144291)
* [Security Solution][Resolver] bug fix - added filter status check to disable graph overlay * update reference to existing status type
1 parent 0ed0065 commit 494aa9c

File tree

3 files changed

+33
-6
lines changed
  • x-pack/plugins/timelines

3 files changed

+33
-6
lines changed

x-pack/plugins/timelines/common/search_strategy/timeline/events/all/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import type { IEsSearchResponse } from '@kbn/data-plugin/common';
1212
import type { Ecs } from '../../../../ecs';
1313
import type { CursorType, Inspect, Maybe, PaginationInputPaginated } from '../../../common';
1414
import type { TimelineRequestOptionsPaginated } from '../..';
15-
15+
import type { AlertStatus } from '../../../../types/timeline';
1616
export interface TimelineEdges {
1717
node: TimelineItem;
1818
cursor: CursorType;
@@ -45,4 +45,5 @@ export interface TimelineEventsAllRequestOptions extends TimelineRequestOptionsP
4545
fields: string[] | Array<{ field: string; include_unmapped: boolean }>;
4646
language: 'eql' | 'kuery' | 'lucene';
4747
runtimeMappings: MappingRuntimeFields;
48+
filterStatus?: AlertStatus;
4849
}

x-pack/plugins/timelines/public/components/t_grid/integrated/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ const TGridIntegratedComponent: React.FC<TGridIntegratedProps> = ({
263263
skip: !canQueryTimeline,
264264
sort: sortField,
265265
startDate: start,
266+
filterStatus,
266267
});
267268

268269
useEffect(() => {

x-pack/plugins/timelines/public/container/index.tsx

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
* 2.0; you may not use this file except in compliance with the Elastic License
55
* 2.0.
66
*/
7-
87
import type { AlertConsumers } from '@kbn/rule-data-utils';
98
import deepEqual from 'fast-deep-equal';
109
import { isEmpty, isString, noop } from 'lodash/fp';
@@ -13,10 +12,15 @@ import { useDispatch } from 'react-redux';
1312
import { Subscription } from 'rxjs';
1413
import { MappingRuntimeFields } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
1514
import type { DataView } from '@kbn/data-views-plugin/public';
16-
1715
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
1816
import { 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';
2024
import {
2125
Direction,
2226
TimelineFactoryQueryTypes,
@@ -34,7 +38,7 @@ import type {
3438
TimelineRequestSortField,
3539
} from '../../common/search_strategy';
3640
import type { ESQuery } from '../../common/typed_json';
37-
import type { KueryFilterQueryKind } from '../../common/types/timeline';
41+
import type { KueryFilterQueryKind, AlertStatus } from '../../common/types/timeline';
3842
import { useAppToasts } from '../hooks/use_app_toasts';
3943
import { TableId } from '../store/t_grid/types';
4044
import * 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

8792
const 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

Comments
 (0)