From df225731ee5684719f4d14923df85a264a5685ee Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 18 Oct 2024 08:14:37 +1100 Subject: [PATCH] [8.x] [Security Solution] Document details flyout - fix session view alerts error (#196422) (#196759) # Backport This will backport the following commits from `main` to `8.x`: - [[Security Solution] Document details flyout - fix session view alerts error (#196422)](https://github.com/elastic/kibana/pull/196422) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: christineweng <18648970+christineweng@users.noreply.github.com> --- .../tabs/session/use_session_view.tsx | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/session/use_session_view.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/session/use_session_view.tsx index e2aa8c42511d7..eae2eec549dfe 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/session/use_session_view.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/session/use_session_view.tsx @@ -10,7 +10,6 @@ import { EuiButtonEmpty, EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiToolTip } import styled from 'styled-components'; import { useDispatch } from 'react-redux'; import { dataTableSelectors, tableDefaults } from '@kbn/securitysolution-data-table'; -import type { TableId } from '@kbn/securitysolution-data-table'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; import { DocumentDetailsRightPanelKey } from '../../../../../flyout/document_details/shared/constants/panel_keys'; import { useSourcererDataView } from '../../../../../sourcerer/containers'; @@ -32,7 +31,6 @@ import { useTimelineFullScreen, useGlobalFullScreen, } from '../../../../../common/containers/use_full_screen'; -import { detectionsTimelineIds } from '../../../../containers/helpers'; import { useUserPrivileges } from '../../../../../common/components/user_privileges'; import { timelineActions, timelineSelectors } from '../../../../store'; import { timelineDefaults } from '../../../../store/defaults'; @@ -273,18 +271,8 @@ export const useSessionView = ({ scopeId, height }: { scopeId: string; height?: [globalFullScreen, scopeId, timelineFullScreen] ); - const sourcererScope = useMemo(() => { - if (isActiveTimeline(scopeId)) { - return SourcererScopeName.timeline; - } else if (detectionsTimelineIds.includes(scopeId as TableId)) { - return SourcererScopeName.detections; - } else { - return SourcererScopeName.default; - } - }, [scopeId]); - - const { selectedPatterns } = useSourcererDataView(sourcererScope); - const eventDetailsIndex = useMemo(() => selectedPatterns.join(','), [selectedPatterns]); + const { selectedPatterns } = useSourcererDataView(SourcererScopeName.detections); + const alertsIndex = useMemo(() => selectedPatterns.join(','), [selectedPatterns]); const { openFlyout } = useExpandableFlyoutApi(); const openAlertDetailsFlyout = useCallback( @@ -294,7 +282,7 @@ export const useSessionView = ({ scopeId, height }: { scopeId: string; height?: id: DocumentDetailsRightPanelKey, params: { id: eventId, - indexName: eventDetailsIndex, + indexName: alertsIndex, scopeId, }, }, @@ -304,7 +292,7 @@ export const useSessionView = ({ scopeId, height }: { scopeId: string; height?: panel: 'right', }); }, - [openFlyout, eventDetailsIndex, scopeId, telemetry] + [openFlyout, alertsIndex, scopeId, telemetry] ); const sessionViewComponent = useMemo(() => {