Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solutions] Reverts PR 124310 #124736

Merged
merged 4 commits into from
Feb 5, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ interface InvestigateInTimelineActionProps {
alertIds?: string[];
buttonType?: 'text' | 'icon';
onInvestigateInTimelineAlertClick?: () => void;
timelineId?: string;
}

const InvestigateInTimelineActionComponent: React.FC<InvestigateInTimelineActionProps> = ({
Expand All @@ -31,13 +30,11 @@ const InvestigateInTimelineActionComponent: React.FC<InvestigateInTimelineAction
ecsRowData,
buttonType,
onInvestigateInTimelineAlertClick,
timelineId,
}) => {
const { investigateInTimelineAlertClick } = useInvestigateInTimeline({
ecsRowData,
alertIds,
onInvestigateInTimelineAlertClick,
timelineId,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,12 @@ interface UseInvestigateInTimelineActionProps {
nonEcsRowData?: TimelineNonEcsData[];
alertIds?: string[] | null | undefined;
onInvestigateInTimelineAlertClick?: () => void;
timelineId?: string;
}

export const useInvestigateInTimeline = ({
ecsRowData,
alertIds,
onInvestigateInTimelineAlertClick,
timelineId,
}: UseInvestigateInTimelineActionProps) => {
const {
data: { search: searchStrategyClient, query },
Expand Down Expand Up @@ -80,7 +78,7 @@ export const useInvestigateInTimeline = ({
const showInvestigateInTimelineAction = alertIds != null;
const { isLoading: isFetchingAlertEcs, alertsEcsData } = useFetchEcsAlertsData({
alertIds,
skip: alertIds == null || timelineId !== undefined,
skip: alertIds == null,
});

const investigateInTimelineAlertClick = useCallback(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { useEffect, useState, useRef } from 'react';
import { useEffect, useState } from 'react';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { isEmpty } from 'lodash';

Expand All @@ -25,11 +25,10 @@ export const useFetchEcsAlertsData = ({
}): { isLoading: boolean | null; alertsEcsData: Ecs[] | null } => {
const [isLoading, setIsLoading] = useState<boolean | null>(null);
const [alertsEcsData, setAlertEcsData] = useState<Ecs[] | null>(null);
const abortCtrl = useRef(new AbortController());

useEffect(() => {
let isSubscribed = true;
const controller = abortCtrl.current;
const abortCtrl = new AbortController();

const fetchAlert = async () => {
try {
Expand Down Expand Up @@ -73,7 +72,7 @@ export const useFetchEcsAlertsData = ({

return (): void => {
isSubscribed = false;
controller.abort();
abortCtrl.abort();
};
}, [alertIds, onError, skip]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ const ActionsComponent: React.FC<ActionProps> = ({
key="investigate-in-timeline"
alertIds={alertIds}
ecsRowData={ecsData}
timelineId={timelineId}
/>
)}

Expand Down