[Security Solution] Timeline uses existing filter manager (#111143)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
c7394591cc
commit
5bc6239630
|
@ -4,7 +4,7 @@
|
|||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
import React, { useCallback } from 'react';
|
||||
import React, { useCallback, useMemo } from 'react';
|
||||
import { useDispatch } from 'react-redux';
|
||||
|
||||
import { EuiContextMenuItem } from '@elastic/eui';
|
||||
|
@ -13,11 +13,12 @@ import { useKibana } from '../../../../common/lib/kibana';
|
|||
import { TimelineId } from '../../../../../common/types/timeline';
|
||||
import { Ecs } from '../../../../../common/ecs';
|
||||
import { TimelineNonEcsData } from '../../../../../common/search_strategy/timeline';
|
||||
import { timelineActions } from '../../../../timelines/store/timeline';
|
||||
import { timelineActions, timelineSelectors } from '../../../../timelines/store/timeline';
|
||||
import { sendAlertToTimelineAction } from '../actions';
|
||||
import { dispatchUpdateTimeline } from '../../../../timelines/components/open_timeline/helpers';
|
||||
import { CreateTimelineProps } from '../types';
|
||||
import { ACTION_INVESTIGATE_IN_TIMELINE } from '../translations';
|
||||
import { useDeepEqualSelector } from '../../../../common/hooks/use_selector';
|
||||
import { useFetchEcsAlertsData } from '../../../containers/detection_engine/alerts/use_fetch_ecs_alerts_data';
|
||||
|
||||
interface UseInvestigateInTimelineActionProps {
|
||||
|
@ -34,10 +35,20 @@ export const useInvestigateInTimeline = ({
|
|||
onInvestigateInTimelineAlertClick,
|
||||
}: UseInvestigateInTimelineActionProps) => {
|
||||
const {
|
||||
data: { search: searchStrategyClient },
|
||||
data: { search: searchStrategyClient, query },
|
||||
} = useKibana().services;
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const filterManagerBackup = useMemo(() => query.filterManager, [query.filterManager]);
|
||||
const getManageTimeline = useMemo(() => timelineSelectors.getManageTimelineById(), []);
|
||||
const { filterManager: activeFilterManager } = useDeepEqualSelector((state) =>
|
||||
getManageTimeline(state, TimelineId.active ?? '')
|
||||
);
|
||||
const filterManager = useMemo(() => activeFilterManager ?? filterManagerBackup, [
|
||||
activeFilterManager,
|
||||
filterManagerBackup,
|
||||
]);
|
||||
|
||||
const updateTimelineIsLoading = useCallback(
|
||||
(payload) => dispatch(timelineActions.updateIsLoading(payload)),
|
||||
[dispatch]
|
||||
|
@ -53,6 +64,7 @@ export const useInvestigateInTimeline = ({
|
|||
notes: [],
|
||||
timeline: {
|
||||
...timeline,
|
||||
filterManager,
|
||||
// by setting as an empty array, it will default to all in the reducer because of the event type
|
||||
indexNames: [],
|
||||
show: true,
|
||||
|
@ -61,7 +73,7 @@ export const useInvestigateInTimeline = ({
|
|||
ruleNote,
|
||||
})();
|
||||
},
|
||||
[dispatch, updateTimelineIsLoading]
|
||||
[dispatch, filterManager, updateTimelineIsLoading]
|
||||
);
|
||||
|
||||
const showInvestigateInTimelineAction = alertIds != null;
|
||||
|
|
Loading…
Reference in a new issue