From bca190bd0c96c6cfc4020350361b719cc5a007f6 Mon Sep 17 00:00:00 2001 From: Keith Chong Date: Wed, 9 Mar 2022 01:38:08 -0500 Subject: [PATCH] fix: Retry checkbox unchecked unexpectedly; Sync up with YAML (#8682) (#8720) Signed-off-by: Keith Chong --- .../application-create-panel.tsx | 9 +++++- .../application-retry-options.tsx | 29 ++++++++++++++----- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/ui/src/app/applications/components/application-create-panel/application-create-panel.tsx b/ui/src/app/applications/components/application-create-panel/application-create-panel.tsx index cd60efbe3edb6..8ec019dc59cde 100644 --- a/ui/src/app/applications/components/application-create-panel/application-create-panel.tsx +++ b/ui/src/app/applications/components/application-create-panel/application-create-panel.tsx @@ -105,6 +105,7 @@ export const ApplicationCreatePanel = (props: { const [yamlMode, setYamlMode] = React.useState(false); const [explicitPathType, setExplicitPathType] = React.useState<{path: string; type: models.AppSourceType}>(null); const [destFormat, setDestFormat] = React.useState('URL'); + const [retry, setRetry] = React.useState(false); function normalizeTypeFields(formApi: FormApi, type: models.AppSourceType) { const app = formApi.getFormState().values; @@ -222,7 +223,13 @@ export const ApplicationCreatePanel = (props: {
- +
); diff --git a/ui/src/app/applications/components/application-retry-options/application-retry-options.tsx b/ui/src/app/applications/components/application-retry-options/application-retry-options.tsx index cbf165e1389f5..0d621138edfbe 100644 --- a/ui/src/app/applications/components/application-retry-options/application-retry-options.tsx +++ b/ui/src/app/applications/components/application-retry-options/application-retry-options.tsx @@ -79,8 +79,20 @@ export const ApplicationRetryForm = ({initValues, field = 'retryStrategy'}: {ini ); }; -export const ApplicationRetryOptions = ({formApi, initValues, field = 'retryStrategy'}: {formApi: FormApi; field?: string; initValues?: models.RetryStrategy}) => { - const [retry, setRetry] = React.useState(!!initValues); +export const ApplicationRetryOptions = ({ + formApi, + initValues, + field = 'retryStrategy', + retry, + setRetry +}: { + formApi: FormApi; + field?: string; + initValues?: models.RetryStrategy; + retry?: boolean; + setRetry?: (value: boolean) => any; +}) => { + const [retryInternal, setRetryInternal] = React.useState(!!initValues); const toggleRetry = (value: boolean) => { if (!value) { @@ -97,15 +109,18 @@ export const ApplicationRetryOptions = ({formApi, initValues, field = 'retryStra errors: newErrors }); } - - setRetry(value); + if (setRetry != null) { + setRetry(value); + } else { + setRetryInternal(value); + } }; - + const isChecked = setRetry != null ? retry : retryInternal; return (
- toggleRetry(val)} /> + toggleRetry(val)} /> - {retry && } + {isChecked && }
); };