From 615242d8b1ca18b8070294791219db036638df58 Mon Sep 17 00:00:00 2001 From: oatkiller Date: Wed, 15 Apr 2020 08:32:04 -0400 Subject: [PATCH] Revert "adding useMemo (#63504)" This reverts commit 0abbb1d9c4b22904eed969b28778715eb3ea33fa. --- .../view/policy/policy_forms/events/linux.tsx | 26 +++++++++---------- .../view/policy/policy_forms/events/mac.tsx | 26 +++++++++---------- .../policy/policy_forms/events/windows.tsx | 7 +++-- 3 files changed, 27 insertions(+), 32 deletions(-) diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/events/linux.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/events/linux.tsx index ca2215d3d0a59..9d2ce03c20462 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/events/linux.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/events/linux.tsx @@ -8,19 +8,18 @@ import React, { useMemo } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiTitle, EuiText, EuiSpacer } from '@elastic/eui'; -import { ImmutableArray } from '../../../../../../../common/types'; -import { getIn, setIn } from '../../../../models/policy_details_config'; import { EventsCheckbox } from './checkbox'; import { OS, UIPolicyConfig } from '../../../../types'; import { usePolicyDetailsSelector } from '../../policy_hooks'; import { selectedLinuxEvents, totalLinuxEvents } from '../../../../store/policy_details/selectors'; import { ConfigForm } from '../config_form'; +import { getIn, setIn } from '../../../../models/policy_details_config'; export const LinuxEvents = React.memo(() => { const selected = usePolicyDetailsSelector(selectedLinuxEvents); const total = usePolicyDetailsSelector(totalLinuxEvents); - const checkboxes: ImmutableArray<{ + const checkboxes: Array<{ name: string; os: 'linux'; protectionField: keyof UIPolicyConfig['linux']['events']; @@ -51,7 +50,7 @@ export const LinuxEvents = React.memo(() => { [] ); - const renderCheckboxes = useMemo(() => { + const renderCheckboxes = () => { return ( <> @@ -77,9 +76,9 @@ export const LinuxEvents = React.memo(() => { })} ); - }, [checkboxes]); + }; - const collectionsEnabled = useMemo(() => { + const collectionsEnabled = () => { return ( { /> ); - }, [selected, total]); + }; return ( [i18n.translate('xpack.endpoint.policy.details.linux', { defaultMessage: 'Linux' })], - [] - )} - id="linuxEventsForm" - rightCorner={collectionsEnabled} - children={renderCheckboxes} + supportedOss={[ + i18n.translate('xpack.endpoint.policy.details.linux', { defaultMessage: 'Linux' }), + ]} + id="linuxEventingForm" + rightCorner={collectionsEnabled()} + children={renderCheckboxes()} /> ); }); diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/events/mac.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/events/mac.tsx index 5024d02603d77..3b69c21d2b150 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/events/mac.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/events/mac.tsx @@ -8,19 +8,18 @@ import React, { useMemo } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiTitle, EuiText, EuiSpacer } from '@elastic/eui'; -import { ImmutableArray } from '../../../../../../../common/types'; -import { getIn, setIn } from '../../../../models/policy_details_config'; import { EventsCheckbox } from './checkbox'; import { OS, UIPolicyConfig } from '../../../../types'; import { usePolicyDetailsSelector } from '../../policy_hooks'; import { selectedMacEvents, totalMacEvents } from '../../../../store/policy_details/selectors'; import { ConfigForm } from '../config_form'; +import { getIn, setIn } from '../../../../models/policy_details_config'; export const MacEvents = React.memo(() => { const selected = usePolicyDetailsSelector(selectedMacEvents); const total = usePolicyDetailsSelector(totalMacEvents); - const checkboxes: ImmutableArray<{ + const checkboxes: Array<{ name: string; os: 'mac'; protectionField: keyof UIPolicyConfig['mac']['events']; @@ -51,7 +50,7 @@ export const MacEvents = React.memo(() => { [] ); - const renderCheckboxes = useMemo(() => { + const renderCheckboxes = () => { return ( <> @@ -77,9 +76,9 @@ export const MacEvents = React.memo(() => { })} ); - }, [checkboxes]); + }; - const collectionsEnabled = useMemo(() => { + const collectionsEnabled = () => { return ( { /> ); - }, [selected, total]); + }; return ( [i18n.translate('xpack.endpoint.policy.details.mac', { defaultMessage: 'Mac' })], - [] - )} - id="macEventsForm" - rightCorner={collectionsEnabled} - children={renderCheckboxes} + supportedOss={[ + i18n.translate('xpack.endpoint.policy.details.mac', { defaultMessage: 'Mac' }), + ]} + id="macEventingForm" + rightCorner={collectionsEnabled()} + children={renderCheckboxes()} /> ); }); diff --git a/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/events/windows.tsx b/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/events/windows.tsx index 5b347ec387f48..da675dc1e2393 100644 --- a/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/events/windows.tsx +++ b/x-pack/plugins/endpoint/public/applications/endpoint/view/policy/policy_forms/events/windows.tsx @@ -8,8 +8,6 @@ import React, { useMemo } from 'react'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiTitle, EuiText, EuiSpacer } from '@elastic/eui'; -import { ImmutableArray } from '../../../../../../../common/types'; -import { setIn, getIn } from '../../../../models/policy_details_config'; import { EventsCheckbox } from './checkbox'; import { OS, UIPolicyConfig } from '../../../../types'; import { usePolicyDetailsSelector } from '../../policy_hooks'; @@ -18,12 +16,13 @@ import { totalWindowsEvents, } from '../../../../store/policy_details/selectors'; import { ConfigForm } from '../config_form'; +import { setIn, getIn } from '../../../../models/policy_details_config'; export const WindowsEvents = React.memo(() => { const selected = usePolicyDetailsSelector(selectedWindowsEvents); const total = usePolicyDetailsSelector(totalWindowsEvents); - const checkboxes: ImmutableArray<{ + const checkboxes: Array<{ name: string; os: 'windows'; protectionField: keyof UIPolicyConfig['windows']['events']; @@ -133,7 +132,7 @@ export const WindowsEvents = React.memo(() => { ], [] )} - id="windowsEventsForm" + id="windowsEventingForm" rightCorner={collectionsEnabled} children={renderCheckboxes} />