Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui): sync option label doesn't check corresponding box #10876

Merged
merged 2 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ export const ApplicationRetryOptions = ({
initValues,
field = 'retryStrategy',
retry,
setRetry
setRetry,
id
}: {
formApi: FormApi;
field?: string;
initValues?: models.RetryStrategy;
retry?: boolean;
setRetry?: (value: boolean) => any;
id?: string;
}) => {
const [retryInternal, setRetryInternal] = React.useState(!!initValues);

Expand Down Expand Up @@ -118,8 +120,8 @@ export const ApplicationRetryOptions = ({
const isChecked = setRetry != null ? retry : retryInternal;
return (
<div className='application-retry-options'>
<Checkbox id='retry' checked={isChecked} onChange={val => toggleRetry(val)} />
<label htmlFor='retry'>Retry</label>
<Checkbox id={`retry-${id}`} checked={isChecked} onChange={val => toggleRetry(val)} />
<label htmlFor={`retry-${id}`}>Retry</label>
{isChecked && <ApplicationRetryForm initValues={initValues} field={field} />}
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const FORCE_WARNING = `The resources will be synced using '--force' that
export interface ApplicationSyncOptionProps {
options: string[];
onChanged: (updatedOptions: string[]) => any;
id?: string;
}

function selectOption(name: string, label: string, defaultVal: string, values: string[], props: ApplicationSyncOptionProps) {
Expand Down Expand Up @@ -47,7 +48,7 @@ function booleanOption(name: string, label: string, defaultVal: boolean, props:
return (
<React.Fragment>
<Checkbox
id={`sync-option-${name}`}
id={`sync-option-${name}-${props.id}`}
checked={checked}
onChange={(val: boolean) => {
if (index < 0) {
Expand All @@ -58,7 +59,7 @@ function booleanOption(name: string, label: string, defaultVal: boolean, props:
}
}}
/>
<label htmlFor={`sync-option-${name}`}>{label}</label>{' '}
<label htmlFor={`sync-option-${name}-${props.id}`}>{label}</label>{' '}
{warning && (
<>
<Tooltip content={warning}>
Expand Down Expand Up @@ -115,7 +116,7 @@ export const ApplicationSyncOptions = (props: ApplicationSyncOptionProps) => (
</div>
);

export const ApplicationManualSyncFlags = ReactForm.FormField((props: {fieldApi: ReactForm.FieldApi}) => {
export const ApplicationManualSyncFlags = ReactForm.FormField((props: {fieldApi: ReactForm.FieldApi; id?: string}) => {
const {
fieldApi: {getValue, setValue, setTouched}
} = props;
Expand All @@ -125,7 +126,7 @@ export const ApplicationManualSyncFlags = ReactForm.FormField((props: {fieldApi:
{Object.keys(ManualSyncFlags).map(flag => (
<React.Fragment key={flag}>
<Checkbox
id={`sync-option-${flag}`}
id={`sync-option-${flag}-${props.id}`}
checked={val[flag]}
onChange={(newVal: boolean) => {
setTouched(true);
Expand All @@ -134,7 +135,7 @@ export const ApplicationManualSyncFlags = ReactForm.FormField((props: {fieldApi:
setValue(update);
}}
/>
<label htmlFor={`sync-option-${flag}`}>{ManualSyncFlags[flag as keyof typeof ManualSyncFlags]}</label>{' '}
<label htmlFor={`sync-option-${flag}-${props.id}`}>{ManualSyncFlags[flag as keyof typeof ManualSyncFlags]}</label>{' '}
</React.Fragment>
))}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,15 @@ export const ApplicationSyncPanel = ({application, selectedResource, hide}: {app
formApi.setTouched('syncOptions', true);
formApi.setValue('syncOptions', opts);
}}
id='application-sync-panel'
/>
</div>

<ApplicationRetryOptions formApi={formApi} initValues={application.spec.syncPolicy ? application.spec.syncPolicy.retry : null} />
<ApplicationRetryOptions
id='application-sync-panel'
formApi={formApi}
initValues={application.spec.syncPolicy ? application.spec.syncPolicy.retry : null}
/>

<label>Synchronize resources:</label>
<div style={{float: 'right'}}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ export const ApplicationsSyncPanel = ({show, apps, hide}: {show: boolean; apps:
formApi.setTouched('syncOptions', true);
formApi.setValue('syncOptions', opts);
}}
id='applications-sync-panel'
/>
</div>

<ApplicationRetryOptions formApi={formApi} />
<ApplicationRetryOptions id='applications-sync-panel' formApi={formApi} />

<ApplicationSelector apps={apps} formApi={formApi} />
</div>
Expand Down