From 2d2975fdf275287b710fccf77cea20b6342c18e8 Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Wed, 16 Aug 2023 12:49:59 -0600 Subject: [PATCH] [Security solution] Fixing console errors (#163119) --- .../select_system_prompt/index.tsx | 2 +- .../connector_selector/index.tsx | 2 +- .../landing_links_images_cards.tsx | 17 +++----------- .../events_viewer/use_timelines_events.tsx | 23 +++++++------------ .../components/fields_browser/index.tsx | 6 +++++ .../public/timelines/containers/index.tsx | 9 ++++++-- 6 files changed, 26 insertions(+), 33 deletions(-) diff --git a/x-pack/packages/kbn-elastic-assistant/impl/assistant/prompt_editor/system_prompt/select_system_prompt/index.tsx b/x-pack/packages/kbn-elastic-assistant/impl/assistant/prompt_editor/system_prompt/select_system_prompt/index.tsx index 1976586f64b7a..255cb59be0c20 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/assistant/prompt_editor/system_prompt/select_system_prompt/index.tsx +++ b/x-pack/packages/kbn-elastic-assistant/impl/assistant/prompt_editor/system_prompt/select_system_prompt/index.tsx @@ -91,7 +91,7 @@ const SelectSystemPromptComponent: React.FC = ({ dropdownDisplay: ( - + {i18n.ADD_NEW_SYSTEM_PROMPT} diff --git a/x-pack/packages/kbn-elastic-assistant/impl/connectorland/connector_selector/index.tsx b/x-pack/packages/kbn-elastic-assistant/impl/connectorland/connector_selector/index.tsx index 870952dde56b5..f0b47f31e9c27 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/connectorland/connector_selector/index.tsx +++ b/x-pack/packages/kbn-elastic-assistant/impl/connectorland/connector_selector/index.tsx @@ -76,7 +76,7 @@ export const ConnectorSelector: React.FC = React.memo( dropdownDisplay: ( - + {i18n.ADD_NEW_CONNECTOR} diff --git a/x-pack/packages/security-solution/navigation/src/landing_links/landing_links_images_cards.tsx b/x-pack/packages/security-solution/navigation/src/landing_links/landing_links_images_cards.tsx index b7faa54202c74..ac8598c427026 100644 --- a/x-pack/packages/security-solution/navigation/src/landing_links/landing_links_images_cards.tsx +++ b/x-pack/packages/security-solution/navigation/src/landing_links/landing_links_images_cards.tsx @@ -4,15 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import { - EuiCard, - EuiFlexGroup, - EuiFlexItem, - EuiImage, - EuiText, - EuiTitle, - useEuiTheme, -} from '@elastic/eui'; +import { EuiCard, EuiFlexGroup, EuiFlexItem, EuiImage, EuiTitle, useEuiTheme } from '@elastic/eui'; import React from 'react'; import { css } from '@emotion/react'; import { withLink } from '../links'; @@ -96,11 +88,8 @@ export const LandingLinksImageCards: React.FC = React.m {isBeta && } } - description={ - - {description} - - } + titleElement="span" + description={{description}} /> ); diff --git a/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx b/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx index 94d01bd7162ed..3a70ccebb9ca6 100644 --- a/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx +++ b/x-pack/plugins/security_solution/public/common/components/events_viewer/use_timelines_events.tsx @@ -261,8 +261,6 @@ export const useTimelineEventsHandler = ({ totalCount: response.totalCount, updatedAt: Date.now(), }; - setUpdated(newTimelineResponse.updatedAt); - setTotalCount(newTimelineResponse.totalCount); if (onNextHandler) onNextHandler(newTimelineResponse); return newTimelineResponse; }); @@ -294,19 +292,7 @@ export const useTimelineEventsHandler = ({ asyncSearch(); refetch.current = asyncSearch; }, - [ - skip, - data, - setTotalCount, - entityType, - dataViewId, - setUpdated, - addWarning, - startTracking, - dispatch, - id, - prevFilterStatus, - ] + [skip, data, entityType, dataViewId, addWarning, startTracking, dispatch, id, prevFilterStatus] ); useEffect(() => { @@ -392,6 +378,13 @@ export const useTimelineEventsHandler = ({ filterStatus, ]); + useEffect(() => { + if (timelineResponse.totalCount > -1) { + setUpdated(timelineResponse.updatedAt); + setTotalCount(timelineResponse.totalCount); + } + }, [setTotalCount, setUpdated, timelineResponse]); + const timelineEventsSearchHandler = useCallback( (onNextHandler?: OnNextResponseHandler) => { if (!deepEqual(prevTimelineRequest.current, timelineRequest)) { diff --git a/x-pack/plugins/security_solution/public/timelines/components/fields_browser/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/fields_browser/index.tsx index f1be0a3209ba1..8c070b6961b67 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/fields_browser/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/fields_browser/index.tsx @@ -63,13 +63,19 @@ export const useFieldBrowserOptions: UseFieldBrowserOptions = ({ scopeIdSelector(state, sourcererScope) ); useEffect(() => { + let ignore = false; const fetchAndSetDataView = async (dataViewId: string) => { const aDatView = await dataViews.get(dataViewId); + if (ignore) return; setDataView(aDatView); }; if (selectedDataViewId != null && !missingPatterns.length) { fetchAndSetDataView(selectedDataViewId); } + + return () => { + ignore = true; + }; }, [selectedDataViewId, missingPatterns, dataViews]); const openFieldEditor = useCallback( diff --git a/x-pack/plugins/security_solution/public/timelines/containers/index.tsx b/x-pack/plugins/security_solution/public/timelines/containers/index.tsx index 0bcd156b6829c..6d2837db0eddc 100644 --- a/x-pack/plugins/security_solution/public/timelines/containers/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/containers/index.tsx @@ -214,6 +214,13 @@ export const useTimelineEventsHandler = ({ loadPage: wrappedLoadPage, updatedAt: 0, }); + + useEffect(() => { + if (timelineResponse.updatedAt !== 0) { + setUpdated(timelineResponse.updatedAt); + } + }, [setUpdated, timelineResponse.updatedAt]); + const { addWarning } = useAppToasts(); const timelineSearch = useCallback( @@ -252,7 +259,6 @@ export const useTimelineEventsHandler = ({ totalCount: response.totalCount, updatedAt: Date.now(), }; - setUpdated(newTimelineResponse.updatedAt); if (id === TimelineId.active) { activeTimeline.setExpandedDetail({}); activeTimeline.setPageName(pageName); @@ -336,7 +342,6 @@ export const useTimelineEventsHandler = ({ startTracking, data.search, dataViewId, - setUpdated, addWarning, refetchGrid, wrappedLoadPage,