From 4fe83a37d3341e6e40604aef1933850e29b5dffa Mon Sep 17 00:00:00 2001 From: Michael Olorunnisola Date: Tue, 4 Mar 2025 09:23:44 -0500 Subject: [PATCH] [8.x] [Performance][Security Solution][4/4] - General Performance changes (#212488) (#212987) # Backport This will backport the following commits from `main` to `8.x`: - [[Performance][Security Solution][4/4] - General Performance changes (#212488)](https://github.com/elastic/kibana/pull/212488) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) --- .../plugin_template_wrapper.tsx | 24 +++++++------ .../detection_engine/detection_engine.tsx | 34 +++++++++---------- ...urity_solution_plugin_template_wrapper.tsx | 27 ++++++++------- 3 files changed, 44 insertions(+), 41 deletions(-) diff --git a/x-pack/solutions/security/plugins/security_solution/public/common/components/plugin_template_wrapper/plugin_template_wrapper.tsx b/x-pack/solutions/security/plugins/security_solution/public/common/components/plugin_template_wrapper/plugin_template_wrapper.tsx index 9808cb864f800..ebc4fe82304b4 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/common/components/plugin_template_wrapper/plugin_template_wrapper.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/common/components/plugin_template_wrapper/plugin_template_wrapper.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React from 'react'; +import React, { useMemo } from 'react'; import type { FC } from 'react'; import type { KibanaPageTemplateProps } from '@kbn/shared-ux-page-kibana-template'; import { useKibana } from '../../lib/kibana'; @@ -15,14 +15,18 @@ import { useKibana } from '../../lib/kibana'; * * The `template` prop can be used to alter the page layout for a given plugin route / all routes within a plugin - depending on the nesting. */ -export const PluginTemplateWrapper: FC = ({ children, ...rest }) => { - const { - services: { - securityLayout: { getPluginWrapper }, - }, - } = useKibana(); +export const PluginTemplateWrapper: FC = React.memo( + ({ children, ...rest }) => { + const { + services: { + securityLayout: { getPluginWrapper }, + }, + } = useKibana(); - const Wrapper = getPluginWrapper(); + const Wrapper = useMemo(() => getPluginWrapper(), [getPluginWrapper]); - return {children}; -}; + return {children}; + } +); + +PluginTemplateWrapper.displayName = 'PluginTemplateWrapper'; diff --git a/x-pack/solutions/security/plugins/security_solution/public/detections/pages/detection_engine/detection_engine.tsx b/x-pack/solutions/security/plugins/security_solution/public/detections/pages/detection_engine/detection_engine.tsx index 6c74da49a2da6..1a19e1621fb91 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/detections/pages/detection_engine/detection_engine.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/detections/pages/detection_engine/detection_engine.tsx @@ -23,7 +23,7 @@ import type { ConnectedProps } from 'react-redux'; import { connect, useDispatch } from 'react-redux'; import type { Dispatch } from 'redux'; import { isTab } from '@kbn/timelines-plugin/public'; -import type { Filter } from '@kbn/es-query'; +import type { Filter, TimeRange } from '@kbn/es-query'; import type { DocLinks } from '@kbn/doc-links'; import { dataTableActions, @@ -301,22 +301,13 @@ const DetectionEnginePageComponent: React.FC = () [isLoadingIndexPattern, areDetectionPageFiltersLoading] ); - const AlertPageFilters = useMemo( - () => ( - - ), - [from, indexPattern, onFilterControlsChange, query, to, topLevelFilters] + const pageFiltersTimerange = useMemo( + () => ({ + from, + to, + mode: 'absolute', + }), + [from, to] ); const renderAlertTable = useCallback( @@ -410,7 +401,14 @@ const DetectionEnginePageComponent: React.FC = () - {AlertPageFilters} + = ({ - children, - ...rest -}) => { - const { - services: { - securityLayout: { getPluginWrapper }, - }, - } = useKibana(); +export const SecuritySolutionPluginTemplateWrapper: FC = React.memo( + ({ children, ...rest }) => { + const { + services: { + securityLayout: { getPluginWrapper }, + }, + } = useKibana(); - const Wrapper = getPluginWrapper(); + const Wrapper = useMemo(() => getPluginWrapper(), [getPluginWrapper]); - return {children}; -}; + return {children}; + } +); + +SecuritySolutionPluginTemplateWrapper.displayName = 'SecuritySolutionPluginTemplateWrapper';