From 2043a7f545e548d8a4669818c53c7939d31b3c74 Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Mon, 9 Jan 2023 10:15:54 -0700 Subject: [PATCH 1/9] fixing async side effects WIP --- .../containers/kpi_network/dns/index.tsx | 6 ++- .../kpi_network/network_events/index.tsx | 53 ++++++++++++------- 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/dns/index.tsx b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/dns/index.tsx index 806c8d67e0c8e..2ea032bfdcb7b 100644 --- a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/dns/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/dns/index.tsx @@ -55,6 +55,7 @@ export const useNetworkKpiDns = ({ const refetch = useRef(noop); const abortCtrl = useRef(new AbortController()); const searchSubscription$ = useRef(new Subscription()); + const canceled = useRef(false); const [loading, setLoading] = useState(false); const [networkKpiDnsRequest, setNetworkKpiDnsRequest] = useState(null); @@ -114,7 +115,9 @@ export const useNetworkKpiDns = ({ }; searchSubscription$.current.unsubscribe(); abortCtrl.current.abort(); - asyncSearch(); + if (!canceled.current) { + asyncSearch(); + } refetch.current = asyncSearch; }, [data.search, addError, addWarning, skip] @@ -143,6 +146,7 @@ export const useNetworkKpiDns = ({ useEffect(() => { networkKpiDnsSearch(networkKpiDnsRequest); return () => { + canceled.current = true; searchSubscription$.current.unsubscribe(); abortCtrl.current.abort(); }; diff --git a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/network_events/index.tsx b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/network_events/index.tsx index fe631b6b7e975..4e9e2dd1f37d5 100644 --- a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/network_events/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/network_events/index.tsx @@ -55,6 +55,7 @@ export const useNetworkKpiNetworkEvents = ({ const refetch = useRef(noop); const abortCtrl = useRef(new AbortController()); const searchSubscription$ = useRef(new Subscription()); + const canceled = useRef(false); const [loading, setLoading] = useState(false); const [networkKpiNetworkEventsRequest, setNetworkKpiNetworkEventsRequest] = useState(null); @@ -79,6 +80,7 @@ export const useNetworkKpiNetworkEvents = ({ } const asyncSearch = async () => { + console.log('1', canceled.current); abortCtrl.current = new AbortController(); setLoading(true); @@ -92,33 +94,46 @@ export const useNetworkKpiNetworkEvents = ({ ) .subscribe({ next: (response) => { - if (isCompleteResponse(response)) { - setLoading(false); - setNetworkKpiNetworkEventsResponse((prevResponse) => ({ - ...prevResponse, - networkEvents: response.networkEvents, - inspect: getInspectResponse(response, prevResponse.inspect), - refetch: refetch.current, - })); - searchSubscription$.current.unsubscribe(); - } else if (isErrorResponse(response)) { - setLoading(false); - addWarning(i18n.ERROR_NETWORK_KPI_NETWORK_EVENTS); - searchSubscription$.current.unsubscribe(); + console.log('2', { + canceled: canceled.current, + complete: isCompleteResponse(response), + error: isErrorResponse(response), + }); + if (!canceled.current) { + if (isCompleteResponse(response)) { + setLoading(false); + setNetworkKpiNetworkEventsResponse((prevResponse) => ({ + ...prevResponse, + networkEvents: response.networkEvents, + inspect: getInspectResponse(response, prevResponse.inspect), + refetch: refetch.current, + })); + searchSubscription$.current.unsubscribe(); + } else if (isErrorResponse(response)) { + setLoading(false); + addWarning(i18n.ERROR_NETWORK_KPI_NETWORK_EVENTS); + searchSubscription$.current.unsubscribe(); + } } }, error: (msg) => { - setLoading(false); - addError(msg, { - title: i18n.FAIL_NETWORK_KPI_NETWORK_EVENTS, - }); + console.log('3 err', { msg, canceled: canceled.current }); + + if (!canceled.current) { + setLoading(false); + addError(msg, { + title: i18n.FAIL_NETWORK_KPI_NETWORK_EVENTS, + }); + } searchSubscription$.current.unsubscribe(); }, }); }; searchSubscription$.current.unsubscribe(); abortCtrl.current.abort(); - asyncSearch(); + if (!canceled.current) { + asyncSearch(); + } refetch.current = asyncSearch; }, [data.search, addError, addWarning, skip] @@ -147,6 +162,8 @@ export const useNetworkKpiNetworkEvents = ({ useEffect(() => { networkKpiNetworkEventsSearch(networkKpiNetworkEventsRequest); return () => { + canceled.current = true; + console.log('unmounted!!!', canceled.current); searchSubscription$.current.unsubscribe(); abortCtrl.current.abort(); }; From fdabf91ba57763952212a4ee28c99cb7504f179c Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Mon, 9 Jan 2023 11:59:05 -0700 Subject: [PATCH 2/9] fixing async side effects --- .../page/use_refetch_by_session.tsx | 13 +++-- .../containers/kpi_network/dns/index.tsx | 6 +- .../kpi_network/network_events/index.tsx | 55 +++++++------------ 3 files changed, 29 insertions(+), 45 deletions(-) diff --git a/x-pack/plugins/security_solution/public/common/components/page/use_refetch_by_session.tsx b/x-pack/plugins/security_solution/public/common/components/page/use_refetch_by_session.tsx index d1bd6020fb131..9baf58e5222d5 100644 --- a/x-pack/plugins/security_solution/public/common/components/page/use_refetch_by_session.tsx +++ b/x-pack/plugins/security_solution/public/common/components/page/use_refetch_by_session.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import { useCallback, useRef, useEffect, useMemo } from 'react'; +import { useCallback, useRef, useEffect, useState } from 'react'; import { useDispatch } from 'react-redux'; import { useDeepEqualSelector } from '../../hooks/use_selector'; import { useKibana } from '../../lib/kibana'; @@ -24,14 +24,15 @@ export const useRefetchByRestartingSession = ({ inputId, queryId, }: UseRefetchByRestartingSessionProps): { - searchSessionId: string; + searchSessionId: string | null; refetchByRestartingSession: Refetch; } => { const dispatch = useDispatch(); const { data } = useKibana().services; const session = useRef(data.search.session); - const searchSessionId = useMemo(() => session.current.start(), [session]); + const [searchSessionId, setSearchSessionId] = useState(null); + const getGlobalQuery = inputsSelectors.globalQueryByIdSelector(); const getTimelineQuery = inputsSelectors.timelineQueryByIdSelector(); const { selectedInspectIndex } = useDeepEqualSelector((state) => @@ -57,10 +58,12 @@ export const useRefetchByRestartingSession = ({ }, [dispatch, queryId, selectedInspectIndex]); useEffect(() => { + setSearchSessionId(session.current.start()); + const currentSession = session.current; return () => { - data.search.session.clear(); + currentSession.clear(); }; - }); + }, []); return { searchSessionId, refetchByRestartingSession }; }; diff --git a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/dns/index.tsx b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/dns/index.tsx index 2ea032bfdcb7b..806c8d67e0c8e 100644 --- a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/dns/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/dns/index.tsx @@ -55,7 +55,6 @@ export const useNetworkKpiDns = ({ const refetch = useRef(noop); const abortCtrl = useRef(new AbortController()); const searchSubscription$ = useRef(new Subscription()); - const canceled = useRef(false); const [loading, setLoading] = useState(false); const [networkKpiDnsRequest, setNetworkKpiDnsRequest] = useState(null); @@ -115,9 +114,7 @@ export const useNetworkKpiDns = ({ }; searchSubscription$.current.unsubscribe(); abortCtrl.current.abort(); - if (!canceled.current) { - asyncSearch(); - } + asyncSearch(); refetch.current = asyncSearch; }, [data.search, addError, addWarning, skip] @@ -146,7 +143,6 @@ export const useNetworkKpiDns = ({ useEffect(() => { networkKpiDnsSearch(networkKpiDnsRequest); return () => { - canceled.current = true; searchSubscription$.current.unsubscribe(); abortCtrl.current.abort(); }; diff --git a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/network_events/index.tsx b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/network_events/index.tsx index 4e9e2dd1f37d5..d9d65b64b63a7 100644 --- a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/network_events/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/network_events/index.tsx @@ -55,7 +55,6 @@ export const useNetworkKpiNetworkEvents = ({ const refetch = useRef(noop); const abortCtrl = useRef(new AbortController()); const searchSubscription$ = useRef(new Subscription()); - const canceled = useRef(false); const [loading, setLoading] = useState(false); const [networkKpiNetworkEventsRequest, setNetworkKpiNetworkEventsRequest] = useState(null); @@ -80,7 +79,6 @@ export const useNetworkKpiNetworkEvents = ({ } const asyncSearch = async () => { - console.log('1', canceled.current); abortCtrl.current = new AbortController(); setLoading(true); @@ -94,46 +92,35 @@ export const useNetworkKpiNetworkEvents = ({ ) .subscribe({ next: (response) => { - console.log('2', { - canceled: canceled.current, - complete: isCompleteResponse(response), - error: isErrorResponse(response), - }); - if (!canceled.current) { - if (isCompleteResponse(response)) { - setLoading(false); - setNetworkKpiNetworkEventsResponse((prevResponse) => ({ - ...prevResponse, - networkEvents: response.networkEvents, - inspect: getInspectResponse(response, prevResponse.inspect), - refetch: refetch.current, - })); - searchSubscription$.current.unsubscribe(); - } else if (isErrorResponse(response)) { - setLoading(false); - addWarning(i18n.ERROR_NETWORK_KPI_NETWORK_EVENTS); - searchSubscription$.current.unsubscribe(); - } + if (isCompleteResponse(response)) { + setLoading(false); + setNetworkKpiNetworkEventsResponse((prevResponse) => ({ + ...prevResponse, + networkEvents: response.networkEvents, + inspect: getInspectResponse(response, prevResponse.inspect), + refetch: refetch.current, + })); + searchSubscription$.current.unsubscribe(); + } else if (isErrorResponse(response)) { + setLoading(false); + addWarning(i18n.ERROR_NETWORK_KPI_NETWORK_EVENTS); + searchSubscription$.current.unsubscribe(); } }, error: (msg) => { - console.log('3 err', { msg, canceled: canceled.current }); - - if (!canceled.current) { - setLoading(false); - addError(msg, { - title: i18n.FAIL_NETWORK_KPI_NETWORK_EVENTS, - }); - } + setLoading(false); + addError(msg, { + title: i18n.FAIL_NETWORK_KPI_NETWORK_EVENTS, + }); searchSubscription$.current.unsubscribe(); }, }); }; searchSubscription$.current.unsubscribe(); abortCtrl.current.abort(); - if (!canceled.current) { - asyncSearch(); - } + + asyncSearch(); + refetch.current = asyncSearch; }, [data.search, addError, addWarning, skip] @@ -162,8 +149,6 @@ export const useNetworkKpiNetworkEvents = ({ useEffect(() => { networkKpiNetworkEventsSearch(networkKpiNetworkEventsRequest); return () => { - canceled.current = true; - console.log('unmounted!!!', canceled.current); searchSubscription$.current.unsubscribe(); abortCtrl.current.abort(); }; From 4ca23623763f0744a913ed053249fcdec8fe35a9 Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Mon, 9 Jan 2023 12:13:35 -0700 Subject: [PATCH 3/9] Update index.tsx --- .../network/containers/kpi_network/network_events/index.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/network_events/index.tsx b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/network_events/index.tsx index d9d65b64b63a7..fe631b6b7e975 100644 --- a/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/network_events/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/containers/kpi_network/network_events/index.tsx @@ -118,9 +118,7 @@ export const useNetworkKpiNetworkEvents = ({ }; searchSubscription$.current.unsubscribe(); abortCtrl.current.abort(); - asyncSearch(); - refetch.current = asyncSearch; }, [data.search, addError, addWarning, skip] From 4af8501e5ecf1885a1f7d2bffb8d2ad881e6a664 Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Mon, 9 Jan 2023 12:28:03 -0700 Subject: [PATCH 4/9] null > undefined to fix TS --- .../common/components/page/use_refetch_by_session.test.tsx | 2 +- .../public/common/components/page/use_refetch_by_session.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/security_solution/public/common/components/page/use_refetch_by_session.test.tsx b/x-pack/plugins/security_solution/public/common/components/page/use_refetch_by_session.test.tsx index 8611a9a43c67e..b11d385591dc5 100644 --- a/x-pack/plugins/security_solution/public/common/components/page/use_refetch_by_session.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/page/use_refetch_by_session.test.tsx @@ -60,7 +60,7 @@ describe(`useRefetchByRestartingSession`, () => { children: React.ReactNode; }, { - searchSessionId: string; + searchSessionId?: string; refetchByRestartingSession: Refetch; } >; diff --git a/x-pack/plugins/security_solution/public/common/components/page/use_refetch_by_session.tsx b/x-pack/plugins/security_solution/public/common/components/page/use_refetch_by_session.tsx index 9baf58e5222d5..88052d80d5520 100644 --- a/x-pack/plugins/security_solution/public/common/components/page/use_refetch_by_session.tsx +++ b/x-pack/plugins/security_solution/public/common/components/page/use_refetch_by_session.tsx @@ -24,14 +24,14 @@ export const useRefetchByRestartingSession = ({ inputId, queryId, }: UseRefetchByRestartingSessionProps): { - searchSessionId: string | null; + searchSessionId?: string; refetchByRestartingSession: Refetch; } => { const dispatch = useDispatch(); const { data } = useKibana().services; const session = useRef(data.search.session); - const [searchSessionId, setSearchSessionId] = useState(null); + const [searchSessionId, setSearchSessionId] = useState(undefined); const getGlobalQuery = inputsSelectors.globalQueryByIdSelector(); const getTimelineQuery = inputsSelectors.timelineQueryByIdSelector(); From 5711fa8d73410c1bb08e187c851774f633aa5818 Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Mon, 9 Jan 2023 12:32:51 -0700 Subject: [PATCH 5/9] move files to explore dir --- .../containers}/use_refetch_by_session.test.tsx | 14 +++++++------- .../containers}/use_refetch_by_session.tsx | 12 ++++++------ 2 files changed, 13 insertions(+), 13 deletions(-) rename x-pack/plugins/security_solution/public/{common/components/page => explore/containers}/use_refetch_by_session.test.tsx (88%) rename x-pack/plugins/security_solution/public/{common/components/page => explore/containers}/use_refetch_by_session.tsx (84%) diff --git a/x-pack/plugins/security_solution/public/common/components/page/use_refetch_by_session.test.tsx b/x-pack/plugins/security_solution/public/explore/containers/use_refetch_by_session.test.tsx similarity index 88% rename from x-pack/plugins/security_solution/public/common/components/page/use_refetch_by_session.test.tsx rename to x-pack/plugins/security_solution/public/explore/containers/use_refetch_by_session.test.tsx index b11d385591dc5..2c6df424f0877 100644 --- a/x-pack/plugins/security_solution/public/common/components/page/use_refetch_by_session.test.tsx +++ b/x-pack/plugins/security_solution/public/explore/containers/use_refetch_by_session.test.tsx @@ -13,14 +13,14 @@ import { mockGlobalState, SUB_PLUGINS_REDUCER, TestProviders, -} from '../../mock'; -import type { State } from '../../store'; -import { createStore } from '../../store'; -import { useKibana } from '../../lib/kibana'; -import { InputsModelId } from '../../store/inputs/constants'; +} from '../../common/mock'; +import type { State } from '../../common/store'; +import { createStore } from '../../common/store'; +import { useKibana } from '../../common/lib/kibana'; +import { InputsModelId } from '../../common/store/inputs/constants'; import { useRefetchByRestartingSession } from './use_refetch_by_session'; -import { inputsActions } from '../../store/actions'; -import type { Refetch } from '../../store/inputs/model'; +import { inputsActions } from '../../common/store/actions'; +import type { Refetch } from '../../common/store/inputs/model'; const state: State = mockGlobalState; diff --git a/x-pack/plugins/security_solution/public/common/components/page/use_refetch_by_session.tsx b/x-pack/plugins/security_solution/public/explore/containers/use_refetch_by_session.tsx similarity index 84% rename from x-pack/plugins/security_solution/public/common/components/page/use_refetch_by_session.tsx rename to x-pack/plugins/security_solution/public/explore/containers/use_refetch_by_session.tsx index 88052d80d5520..eb7d11362d486 100644 --- a/x-pack/plugins/security_solution/public/common/components/page/use_refetch_by_session.tsx +++ b/x-pack/plugins/security_solution/public/explore/containers/use_refetch_by_session.tsx @@ -7,12 +7,12 @@ import { useCallback, useRef, useEffect, useState } from 'react'; import { useDispatch } from 'react-redux'; -import { useDeepEqualSelector } from '../../hooks/use_selector'; -import { useKibana } from '../../lib/kibana'; -import { inputsSelectors } from '../../store'; -import { inputsActions } from '../../store/actions'; -import { InputsModelId } from '../../store/inputs/constants'; -import type { Refetch } from '../../store/inputs/model'; +import { useDeepEqualSelector } from '../../common/hooks/use_selector'; +import { useKibana } from '../../common/lib/kibana'; +import { inputsSelectors } from '../../common/store'; +import { inputsActions } from '../../common/store/actions'; +import { InputsModelId } from '../../common/store/inputs/constants'; +import type { Refetch } from '../../common/store/inputs/model'; interface UseRefetchByRestartingSessionProps { inputId?: InputsModelId; From 36a92d05d4fef1f27b73fc675c3c865ff83f7e44 Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Mon, 9 Jan 2023 12:39:43 -0700 Subject: [PATCH 6/9] i think this should be here? --- .../users/components/kpi_users/authentications/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/security_solution/public/explore/users/components/kpi_users/authentications/index.tsx b/x-pack/plugins/security_solution/public/explore/users/components/kpi_users/authentications/index.tsx index 743d07bfa32f0..293904aa8e770 100644 --- a/x-pack/plugins/security_solution/public/explore/users/components/kpi_users/authentications/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/users/components/kpi_users/authentications/index.tsx @@ -79,7 +79,7 @@ const UsersKpiAuthenticationsComponent: React.FC = ({ endDate: to, indexNames, startDate: from, - skip: querySkip, + skip: querySkip || isChartEmbeddablesEnabled, }); const { searchSessionId, refetchByRestartingSession } = useRefetchByRestartingSession({ From f181923c3cfed7266f14b7b5d39f9be08ce23088 Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Mon, 9 Jan 2023 12:47:20 -0700 Subject: [PATCH 7/9] fix more imports --- .../public/explore/containers/use_refetch_by_session.test.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/security_solution/public/explore/containers/use_refetch_by_session.test.tsx b/x-pack/plugins/security_solution/public/explore/containers/use_refetch_by_session.test.tsx index 2c6df424f0877..2d84d77b753fb 100644 --- a/x-pack/plugins/security_solution/public/explore/containers/use_refetch_by_session.test.tsx +++ b/x-pack/plugins/security_solution/public/explore/containers/use_refetch_by_session.test.tsx @@ -40,13 +40,13 @@ jest.mock('react-redux', () => { }; }); -jest.mock('../../lib/kibana', () => { +jest.mock('../../common/lib/kibana', () => { return { useKibana: jest.fn(), }; }); -jest.mock('../../store/actions', () => { +jest.mock('../../common/store/actions', () => { return { inputsActions: { setInspectionParameter: jest.fn(), From eac05542ac50a2c078396f7d333f887696a0cfda Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Mon, 9 Jan 2023 13:13:26 -0700 Subject: [PATCH 8/9] fix more imports! --- .../public/explore/hosts/components/kpi_hosts/hosts/index.tsx | 2 +- .../explore/hosts/components/kpi_hosts/unique_ips/index.tsx | 2 +- .../public/explore/network/components/kpi_network/dns/index.tsx | 2 +- .../network/components/kpi_network/network_events/index.tsx | 2 +- .../network/components/kpi_network/tls_handshakes/index.tsx | 2 +- .../network/components/kpi_network/unique_flows/index.tsx | 2 +- .../network/components/kpi_network/unique_private_ips/index.tsx | 2 +- .../users/components/kpi_users/authentications/index.tsx | 2 +- .../explore/users/components/kpi_users/total_users/index.tsx | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/security_solution/public/explore/hosts/components/kpi_hosts/hosts/index.tsx b/x-pack/plugins/security_solution/public/explore/hosts/components/kpi_hosts/hosts/index.tsx index 4cf9bd91f6c35..997d8d10ec091 100644 --- a/x-pack/plugins/security_solution/public/explore/hosts/components/kpi_hosts/hosts/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/hosts/components/kpi_hosts/hosts/index.tsx @@ -18,7 +18,7 @@ import * as i18n from './translations'; import { useQueryToggle } from '../../../../../common/containers/query_toggle'; import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; import { InputsModelId } from '../../../../../common/store/inputs/constants'; -import { useRefetchByRestartingSession } from '../../../../../common/components/page/use_refetch_by_session'; +import { useRefetchByRestartingSession } from '../../../../containers/use_refetch_by_session'; export const fieldsMapping: Readonly = [ { diff --git a/x-pack/plugins/security_solution/public/explore/hosts/components/kpi_hosts/unique_ips/index.tsx b/x-pack/plugins/security_solution/public/explore/hosts/components/kpi_hosts/unique_ips/index.tsx index 3cb0122d5687d..85a7b5eb7fb94 100644 --- a/x-pack/plugins/security_solution/public/explore/hosts/components/kpi_hosts/unique_ips/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/hosts/components/kpi_hosts/unique_ips/index.tsx @@ -20,7 +20,7 @@ import * as i18n from './translations'; import { useQueryToggle } from '../../../../../common/containers/query_toggle'; import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; import { InputsModelId } from '../../../../../common/store/inputs/constants'; -import { useRefetchByRestartingSession } from '../../../../../common/components/page/use_refetch_by_session'; +import { useRefetchByRestartingSession } from '../../../../containers/use_refetch_by_session'; export const fieldsMapping: Readonly = [ { diff --git a/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/dns/index.tsx b/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/dns/index.tsx index bea6ef43de363..e579c943ae895 100644 --- a/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/dns/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/dns/index.tsx @@ -17,7 +17,7 @@ import * as i18n from './translations'; import { useQueryToggle } from '../../../../../common/containers/query_toggle'; import { InputsModelId } from '../../../../../common/store/inputs/constants'; import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; -import { useRefetchByRestartingSession } from '../../../../../common/components/page/use_refetch_by_session'; +import { useRefetchByRestartingSession } from '../../../../containers/use_refetch_by_session'; export const fieldsMapping: Readonly = [ { diff --git a/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/network_events/index.tsx b/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/network_events/index.tsx index 5aa792fd7c220..756476b54d495 100644 --- a/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/network_events/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/network_events/index.tsx @@ -16,7 +16,7 @@ import { kpiNetworkEventsLensAttributes } from '../../../../../common/components import { KpiBaseComponentManage } from '../../../../hosts/components/kpi_hosts/common'; import { useQueryToggle } from '../../../../../common/containers/query_toggle'; import { InputsModelId } from '../../../../../common/store/inputs/constants'; -import { useRefetchByRestartingSession } from '../../../../../common/components/page/use_refetch_by_session'; +import { useRefetchByRestartingSession } from '../../../../containers/use_refetch_by_session'; import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; const euiVisColorPalette = euiPaletteColorBlind(); diff --git a/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/tls_handshakes/index.tsx b/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/tls_handshakes/index.tsx index 53eb79d88e3fa..822cd4fdb0a10 100644 --- a/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/tls_handshakes/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/tls_handshakes/index.tsx @@ -16,7 +16,7 @@ import * as i18n from './translations'; import { useQueryToggle } from '../../../../../common/containers/query_toggle'; import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; import { InputsModelId } from '../../../../../common/store/inputs/constants'; -import { useRefetchByRestartingSession } from '../../../../../common/components/page/use_refetch_by_session'; +import { useRefetchByRestartingSession } from '../../../../containers/use_refetch_by_session'; export const fieldsMapping: Readonly = [ { diff --git a/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/unique_flows/index.tsx b/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/unique_flows/index.tsx index 6df7b9a2798a4..929d86f2e1266 100644 --- a/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/unique_flows/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/unique_flows/index.tsx @@ -15,7 +15,7 @@ import type { NetworkKpiProps } from '../types'; import * as i18n from './translations'; import { useQueryToggle } from '../../../../../common/containers/query_toggle'; import { InputsModelId } from '../../../../../common/store/inputs/constants'; -import { useRefetchByRestartingSession } from '../../../../../common/components/page/use_refetch_by_session'; +import { useRefetchByRestartingSession } from '../../../../containers/use_refetch_by_session'; import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; export const fieldsMapping: Readonly = [ diff --git a/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/unique_private_ips/index.tsx b/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/unique_private_ips/index.tsx index 8f8e5e5df620f..4228e4d1e5e98 100644 --- a/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/unique_private_ips/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/unique_private_ips/index.tsx @@ -23,7 +23,7 @@ import { KpiBaseComponentManage } from '../../../../hosts/components/kpi_hosts/c import { useQueryToggle } from '../../../../../common/containers/query_toggle'; import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; import { InputsModelId } from '../../../../../common/store/inputs/constants'; -import { useRefetchByRestartingSession } from '../../../../../common/components/page/use_refetch_by_session'; +import { useRefetchByRestartingSession } from '../../../../containers/use_refetch_by_session'; const euiVisColorPalette = euiPaletteColorBlind(); const euiColorVis2 = euiVisColorPalette[2]; diff --git a/x-pack/plugins/security_solution/public/explore/users/components/kpi_users/authentications/index.tsx b/x-pack/plugins/security_solution/public/explore/users/components/kpi_users/authentications/index.tsx index 293904aa8e770..6c49cd2202e6d 100644 --- a/x-pack/plugins/security_solution/public/explore/users/components/kpi_users/authentications/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/users/components/kpi_users/authentications/index.tsx @@ -18,7 +18,7 @@ import * as i18n from './translations'; import { useQueryToggle } from '../../../../../common/containers/query_toggle'; import type { UsersKpiProps } from '../types'; import { InputsModelId } from '../../../../../common/store/inputs/constants'; -import { useRefetchByRestartingSession } from '../../../../../common/components/page/use_refetch_by_session'; +import { useRefetchByRestartingSession } from '../../../../containers/use_refetch_by_session'; import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; enum ChartColors { diff --git a/x-pack/plugins/security_solution/public/explore/users/components/kpi_users/total_users/index.tsx b/x-pack/plugins/security_solution/public/explore/users/components/kpi_users/total_users/index.tsx index 930eb25b8a429..10da15c38f979 100644 --- a/x-pack/plugins/security_solution/public/explore/users/components/kpi_users/total_users/index.tsx +++ b/x-pack/plugins/security_solution/public/explore/users/components/kpi_users/total_users/index.tsx @@ -17,7 +17,7 @@ import * as i18n from './translations'; import { useQueryToggle } from '../../../../../common/containers/query_toggle'; import type { UsersKpiProps } from '../types'; import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; -import { useRefetchByRestartingSession } from '../../../../../common/components/page/use_refetch_by_session'; +import { useRefetchByRestartingSession } from '../../../../containers/use_refetch_by_session'; import { InputsModelId } from '../../../../../common/store/inputs/constants'; const euiVisColorPalette = euiPaletteColorBlind(); From 71637edd927fa90931420ed7939da54c296d5486 Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Mon, 9 Jan 2023 13:15:53 -0700 Subject: [PATCH 9/9] fix test imports --- .../explore/hosts/components/kpi_hosts/hosts/index.test.tsx | 4 ++-- .../hosts/components/kpi_hosts/unique_ips/index.test.tsx | 4 ++-- .../explore/network/components/kpi_network/dns/index.test.tsx | 4 ++-- .../components/kpi_network/network_events/index.test.tsx | 4 ++-- .../components/kpi_network/tls_handshakes/index.test.tsx | 4 ++-- .../components/kpi_network/unique_flows/index.test.tsx | 4 ++-- .../components/kpi_network/unique_private_ips/index.test.tsx | 4 ++-- .../users/components/kpi_users/authentications/index.test.tsx | 4 ++-- .../users/components/kpi_users/total_users/index.test.tsx | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/x-pack/plugins/security_solution/public/explore/hosts/components/kpi_hosts/hosts/index.test.tsx b/x-pack/plugins/security_solution/public/explore/hosts/components/kpi_hosts/hosts/index.test.tsx index 44e8fce95725b..01f650a356353 100644 --- a/x-pack/plugins/security_solution/public/explore/hosts/components/kpi_hosts/hosts/index.test.tsx +++ b/x-pack/plugins/security_solution/public/explore/hosts/components/kpi_hosts/hosts/index.test.tsx @@ -12,7 +12,7 @@ import { TestProviders } from '../../../../../common/mock'; import React from 'react'; import { HostsKpiHosts } from '.'; import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; -import { useRefetchByRestartingSession } from '../../../../../common/components/page/use_refetch_by_session'; +import { useRefetchByRestartingSession } from '../../../../containers/use_refetch_by_session'; import { KpiBaseComponentManage } from '../common'; jest.mock('../../../../../common/containers/query_toggle'); @@ -25,7 +25,7 @@ jest.mock('../common', () => ({ jest.mock('../../../../../common/hooks/use_experimental_features', () => ({ useIsExperimentalFeatureEnabled: jest.fn(), })); -jest.mock('../../../../../common/components/page/use_refetch_by_session', () => ({ +jest.mock('../../../../containers/use_refetch_by_session', () => ({ useRefetchByRestartingSession: jest.fn(), })); diff --git a/x-pack/plugins/security_solution/public/explore/hosts/components/kpi_hosts/unique_ips/index.test.tsx b/x-pack/plugins/security_solution/public/explore/hosts/components/kpi_hosts/unique_ips/index.test.tsx index 17e5ebd5e1306..10b53f863491a 100644 --- a/x-pack/plugins/security_solution/public/explore/hosts/components/kpi_hosts/unique_ips/index.test.tsx +++ b/x-pack/plugins/security_solution/public/explore/hosts/components/kpi_hosts/unique_ips/index.test.tsx @@ -12,7 +12,7 @@ import { TestProviders } from '../../../../../common/mock'; import React from 'react'; import { HostsKpiUniqueIps } from '.'; import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; -import { useRefetchByRestartingSession } from '../../../../../common/components/page/use_refetch_by_session'; +import { useRefetchByRestartingSession } from '../../../../containers/use_refetch_by_session'; import { KpiBaseComponentManage } from '../common'; jest.mock('../../../../../common/containers/query_toggle'); @@ -25,7 +25,7 @@ jest.mock('../common', () => ({ jest.mock('../../../../../common/hooks/use_experimental_features', () => ({ useIsExperimentalFeatureEnabled: jest.fn(), })); -jest.mock('../../../../../common/components/page/use_refetch_by_session', () => ({ +jest.mock('../../../../containers/use_refetch_by_session', () => ({ useRefetchByRestartingSession: jest.fn(), })); diff --git a/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/dns/index.test.tsx b/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/dns/index.test.tsx index 46c26543ab862..0f370c501df89 100644 --- a/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/dns/index.test.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/dns/index.test.tsx @@ -12,7 +12,7 @@ import { TestProviders } from '../../../../../common/mock'; import React from 'react'; import { NetworkKpiDns } from '.'; import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; -import { useRefetchByRestartingSession } from '../../../../../common/components/page/use_refetch_by_session'; +import { useRefetchByRestartingSession } from '../../../../containers/use_refetch_by_session'; import { KpiBaseComponentManage } from '../../../../hosts/components/kpi_hosts/common'; jest.mock('../../../../../common/containers/query_toggle'); @@ -25,7 +25,7 @@ jest.mock('../../../../hosts/components/kpi_hosts/common', () => ({ jest.mock('../../../../../common/hooks/use_experimental_features', () => ({ useIsExperimentalFeatureEnabled: jest.fn(), })); -jest.mock('../../../../../common/components/page/use_refetch_by_session', () => ({ +jest.mock('../../../../containers/use_refetch_by_session', () => ({ useRefetchByRestartingSession: jest.fn(), })); diff --git a/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/network_events/index.test.tsx b/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/network_events/index.test.tsx index bb894d795e16c..58a42833e34e0 100644 --- a/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/network_events/index.test.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/network_events/index.test.tsx @@ -12,7 +12,7 @@ import { TestProviders } from '../../../../../common/mock'; import React from 'react'; import { NetworkKpiNetworkEvents } from '.'; import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; -import { useRefetchByRestartingSession } from '../../../../../common/components/page/use_refetch_by_session'; +import { useRefetchByRestartingSession } from '../../../../containers/use_refetch_by_session'; import { KpiBaseComponentManage } from '../../../../hosts/components/kpi_hosts/common'; jest.mock('../../../../../common/containers/query_toggle'); @@ -25,7 +25,7 @@ jest.mock('../../../../hosts/components/kpi_hosts/common', () => ({ jest.mock('../../../../../common/hooks/use_experimental_features', () => ({ useIsExperimentalFeatureEnabled: jest.fn(), })); -jest.mock('../../../../../common/components/page/use_refetch_by_session', () => ({ +jest.mock('../../../../containers/use_refetch_by_session', () => ({ useRefetchByRestartingSession: jest.fn(), })); diff --git a/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/tls_handshakes/index.test.tsx b/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/tls_handshakes/index.test.tsx index f3d6192536ad4..716f149b14cc0 100644 --- a/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/tls_handshakes/index.test.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/tls_handshakes/index.test.tsx @@ -12,7 +12,7 @@ import { TestProviders } from '../../../../../common/mock'; import React from 'react'; import { NetworkKpiTlsHandshakes } from '.'; import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; -import { useRefetchByRestartingSession } from '../../../../../common/components/page/use_refetch_by_session'; +import { useRefetchByRestartingSession } from '../../../../containers/use_refetch_by_session'; import { KpiBaseComponentManage } from '../../../../hosts/components/kpi_hosts/common'; jest.mock('../../../../../common/containers/query_toggle'); @@ -25,7 +25,7 @@ jest.mock('../../../../hosts/components/kpi_hosts/common', () => ({ jest.mock('../../../../../common/hooks/use_experimental_features', () => ({ useIsExperimentalFeatureEnabled: jest.fn(), })); -jest.mock('../../../../../common/components/page/use_refetch_by_session', () => ({ +jest.mock('../../../../containers/use_refetch_by_session', () => ({ useRefetchByRestartingSession: jest.fn(), })); diff --git a/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/unique_flows/index.test.tsx b/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/unique_flows/index.test.tsx index 39bbe9a2968c2..122a296d1691d 100644 --- a/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/unique_flows/index.test.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/unique_flows/index.test.tsx @@ -12,7 +12,7 @@ import { TestProviders } from '../../../../../common/mock'; import React from 'react'; import { NetworkKpiUniqueFlows } from '.'; import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; -import { useRefetchByRestartingSession } from '../../../../../common/components/page/use_refetch_by_session'; +import { useRefetchByRestartingSession } from '../../../../containers/use_refetch_by_session'; import { KpiBaseComponentManage } from '../../../../hosts/components/kpi_hosts/common'; jest.mock('../../../../../common/containers/query_toggle'); @@ -25,7 +25,7 @@ jest.mock('../../../../hosts/components/kpi_hosts/common', () => ({ jest.mock('../../../../../common/hooks/use_experimental_features', () => ({ useIsExperimentalFeatureEnabled: jest.fn(), })); -jest.mock('../../../../../common/components/page/use_refetch_by_session', () => ({ +jest.mock('../../../../containers/use_refetch_by_session', () => ({ useRefetchByRestartingSession: jest.fn(), })); diff --git a/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/unique_private_ips/index.test.tsx b/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/unique_private_ips/index.test.tsx index 9d7cfdf128bd5..101483068c851 100644 --- a/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/unique_private_ips/index.test.tsx +++ b/x-pack/plugins/security_solution/public/explore/network/components/kpi_network/unique_private_ips/index.test.tsx @@ -12,7 +12,7 @@ import { TestProviders } from '../../../../../common/mock'; import React from 'react'; import { NetworkKpiUniquePrivateIps } from '.'; import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; -import { useRefetchByRestartingSession } from '../../../../../common/components/page/use_refetch_by_session'; +import { useRefetchByRestartingSession } from '../../../../containers/use_refetch_by_session'; import { KpiBaseComponentManage } from '../../../../hosts/components/kpi_hosts/common'; jest.mock('../../../../../common/containers/query_toggle'); @@ -25,7 +25,7 @@ jest.mock('../../../../hosts/components/kpi_hosts/common', () => ({ jest.mock('../../../../../common/hooks/use_experimental_features', () => ({ useIsExperimentalFeatureEnabled: jest.fn(), })); -jest.mock('../../../../../common/components/page/use_refetch_by_session', () => ({ +jest.mock('../../../../containers/use_refetch_by_session', () => ({ useRefetchByRestartingSession: jest.fn(), })); diff --git a/x-pack/plugins/security_solution/public/explore/users/components/kpi_users/authentications/index.test.tsx b/x-pack/plugins/security_solution/public/explore/users/components/kpi_users/authentications/index.test.tsx index 0ca07a48d03ca..e6a39c1b0cf35 100644 --- a/x-pack/plugins/security_solution/public/explore/users/components/kpi_users/authentications/index.test.tsx +++ b/x-pack/plugins/security_solution/public/explore/users/components/kpi_users/authentications/index.test.tsx @@ -12,7 +12,7 @@ import { TestProviders } from '../../../../../common/mock'; import React from 'react'; import { UsersKpiAuthentications } from '.'; import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; -import { useRefetchByRestartingSession } from '../../../../../common/components/page/use_refetch_by_session'; +import { useRefetchByRestartingSession } from '../../../../containers/use_refetch_by_session'; import { KpiBaseComponentManage } from '../../../../hosts/components/kpi_hosts/common'; jest.mock('../../../../../common/containers/query_toggle'); @@ -25,7 +25,7 @@ jest.mock('../../../../hosts/components/kpi_hosts/common', () => ({ jest.mock('../../../../../common/hooks/use_experimental_features', () => ({ useIsExperimentalFeatureEnabled: jest.fn(), })); -jest.mock('../../../../../common/components/page/use_refetch_by_session', () => ({ +jest.mock('../../../../containers/use_refetch_by_session', () => ({ useRefetchByRestartingSession: jest.fn(), })); describe('Authentications KPI', () => { diff --git a/x-pack/plugins/security_solution/public/explore/users/components/kpi_users/total_users/index.test.tsx b/x-pack/plugins/security_solution/public/explore/users/components/kpi_users/total_users/index.test.tsx index 0adcd5e628761..3380225943dc8 100644 --- a/x-pack/plugins/security_solution/public/explore/users/components/kpi_users/total_users/index.test.tsx +++ b/x-pack/plugins/security_solution/public/explore/users/components/kpi_users/total_users/index.test.tsx @@ -12,7 +12,7 @@ import React from 'react'; import { TotalUsersKpi } from '.'; import { useSearchStrategy } from '../../../../../common/containers/use_search_strategy'; import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; -import { useRefetchByRestartingSession } from '../../../../../common/components/page/use_refetch_by_session'; +import { useRefetchByRestartingSession } from '../../../../containers/use_refetch_by_session'; import { KpiBaseComponentManage } from '../../../../hosts/components/kpi_hosts/common'; jest.mock('../../../../../common/containers/query_toggle'); @@ -25,7 +25,7 @@ jest.mock('../../../../hosts/components/kpi_hosts/common', () => ({ jest.mock('../../../../../common/hooks/use_experimental_features', () => ({ useIsExperimentalFeatureEnabled: jest.fn(), })); -jest.mock('../../../../../common/components/page/use_refetch_by_session', () => ({ +jest.mock('../../../../containers/use_refetch_by_session', () => ({ useRefetchByRestartingSession: jest.fn(), }));