Skip to content

Commit 0e2d4a3

Browse files
committed
fix: Retry checkbox unchecked unexpectedly; Sync up with YAML (argoproj#8682)
Signed-off-by: Keith Chong <kykchong@redhat.com>
1 parent 6d19813 commit 0e2d4a3

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

ui/src/app/applications/components/application-create-panel/application-create-panel.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export const ApplicationCreatePanel = (props: {
104104
const [yamlMode, setYamlMode] = React.useState(false);
105105
const [explicitPathType, setExplicitPathType] = React.useState<{path: string; type: models.AppSourceType}>(null);
106106
const [destFormat, setDestFormat] = React.useState('URL');
107+
const [retry, setRetry] = React.useState(false);
107108

108109
function normalizeTypeFields(formApi: FormApi, type: models.AppSourceType) {
109110
const app = formApi.getFormState().values;
@@ -221,7 +222,13 @@ export const ApplicationCreatePanel = (props: {
221222
<div className='argo-form-row'>
222223
<label>Sync Options</label>
223224
<FormField formApi={api} field='spec.syncPolicy.syncOptions' component={ApplicationSyncOptionsField} />
224-
<ApplicationRetryOptions formApi={api} field='spec.syncPolicy.retry' />
225+
<ApplicationRetryOptions
226+
formApi={api}
227+
field='spec.syncPolicy.retry'
228+
retry={retry || (api.getFormState().values.spec.syncPolicy && api.getFormState().values.spec.syncPolicy.retry)}
229+
setRetry={setRetry}
230+
initValues={api.getFormState().values.spec.syncPolicy ? api.getFormState().values.spec.syncPolicy.retry : null}
231+
/>
225232
</div>
226233
</div>
227234
);

ui/src/app/applications/components/application-retry-options/application-retry-options.tsx

+22-7
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,20 @@ export const ApplicationRetryForm = ({initValues, field = 'retryStrategy'}: {ini
7979
);
8080
};
8181

82-
export const ApplicationRetryOptions = ({formApi, initValues, field = 'retryStrategy'}: {formApi: FormApi; field?: string; initValues?: models.RetryStrategy}) => {
83-
const [retry, setRetry] = React.useState(!!initValues);
82+
export const ApplicationRetryOptions = ({
83+
formApi,
84+
initValues,
85+
field = 'retryStrategy',
86+
retry,
87+
setRetry
88+
}: {
89+
formApi: FormApi;
90+
field?: string;
91+
initValues?: models.RetryStrategy;
92+
retry?: boolean;
93+
setRetry?: (value: boolean) => any;
94+
}) => {
95+
const [retryInternal, setRetryInternal] = React.useState(!!initValues);
8496

8597
const toggleRetry = (value: boolean) => {
8698
if (!value) {
@@ -97,15 +109,18 @@ export const ApplicationRetryOptions = ({formApi, initValues, field = 'retryStra
97109
errors: newErrors
98110
});
99111
}
100-
101-
setRetry(value);
112+
if (setRetry != null) {
113+
setRetry(value);
114+
} else {
115+
setRetryInternal(value);
116+
}
102117
};
103-
118+
const isChecked = setRetry != null ? retry : retryInternal;
104119
return (
105120
<div className='application-retry-options'>
106-
<Checkbox id='retry' checked={retry} onChange={val => toggleRetry(val)} />
121+
<Checkbox id='retry' checked={isChecked} onChange={val => toggleRetry(val)} />
107122
<label htmlFor='retry'>Retry</label>
108-
{retry && <ApplicationRetryForm initValues={initValues} field={field} />}
123+
{isChecked && <ApplicationRetryForm initValues={initValues} field={field} />}
109124
</div>
110125
);
111126
};

0 commit comments

Comments
 (0)