From 584f92cc0637bca0023d6e70ce2c8aae32d0a854 Mon Sep 17 00:00:00 2001 From: Nicolas Chaulet Date: Wed, 15 Sep 2021 11:14:37 -0400 Subject: [PATCH] [Fleet] Wrap package policy editor errors in EuiErrorBoundary (#112263) --- .../create_package_policy_page/index.tsx | 134 +++++++------- .../edit_package_policy_page/index.tsx | 173 +++++++++--------- 2 files changed, 158 insertions(+), 149 deletions(-) diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.tsx index 1f7fa0ceb354..5e00bce5d6c6 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/create_package_policy_page/index.tsx @@ -20,6 +20,7 @@ import { EuiFlexItem, EuiSpacer, EuiLink, + EuiErrorBoundary, } from '@elastic/eui'; import type { EuiStepProps } from '@elastic/eui/src/components/steps/step'; import type { ApplicationStart } from 'kibana/public'; @@ -503,70 +504,75 @@ export const CreatePackagePolicyPage: React.FunctionComponent = () => { return ( - {formState === 'CONFIRM' && agentPolicy && ( - setFormState('VALID')} - /> - )} - {packageInfo && ( - - )} - - - - - - - {!isLoadingAgentPolicyStep && agentPolicy && packageInfo && formState === 'INVALID' ? ( - - ) : null} - - - - - {/* eslint-disable-next-line @elastic/eui/href-or-on-click */} - - - - - - - - - - - - - + + {formState === 'CONFIRM' && agentPolicy && ( + setFormState('VALID')} + /> + )} + {packageInfo && ( + + )} + + + + + + + {!isLoadingAgentPolicyStep && + agentPolicy && + packageInfo && + formState === 'INVALID' ? ( + + ) : null} + + + + + {/* eslint-disable-next-line @elastic/eui/href-or-on-click */} + + + + + + + + + + + + + + ); }; diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.tsx index a36bc988da89..040070bcff7c 100644 --- a/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.tsx +++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agent_policy/edit_package_policy_page/index.tsx @@ -25,6 +25,7 @@ import { EuiFlyoutBody, EuiFlyoutHeader, EuiTitle, + EuiErrorBoundary, } from '@elastic/eui'; import styled from 'styled-components'; @@ -510,93 +511,95 @@ export const EditPackagePolicyForm = memo<{ return ( - {isLoadingData ? ( - - ) : loadingError || !agentPolicy || !packageInfo ? ( - - } - error={ - loadingError || - i18n.translate('xpack.fleet.editPackagePolicy.errorLoadingDataMessage', { - defaultMessage: 'There was an error loading this integration information', - }) - } - /> - ) : ( - <> - + {isLoadingData ? ( + + ) : loadingError || !agentPolicy || !packageInfo ? ( + + } + error={ + loadingError || + i18n.translate('xpack.fleet.editPackagePolicy.errorLoadingDataMessage', { + defaultMessage: 'There was an error loading this integration information', + }) + } /> - {formState === 'CONFIRM' && ( - setFormState('VALID')} + ) : ( + <> + - )} - {isUpgrade && dryRunData && ( - <> - - - - )} - {configurePackage} - {/* Extra space to accomodate the EuiBottomBar height */} - - - - - - {agentPolicy && packageInfo && formState === 'INVALID' ? ( - - ) : null} - - - - - - - - - - - - - - - - - - - )} + {formState === 'CONFIRM' && ( + setFormState('VALID')} + /> + )} + {isUpgrade && dryRunData && ( + <> + + + + )} + {configurePackage} + {/* Extra space to accomodate the EuiBottomBar height */} + + + + + + {agentPolicy && packageInfo && formState === 'INVALID' ? ( + + ) : null} + + + + + + + + + + + + + + + + + + + )} + ); });