mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-25 02:50:08 +03:00
M #~: Fix test api component (#1759)
(cherry picked from commit 8a25fc46d2c322159f060134f2e5cc2c13af2ffc)
This commit is contained in:
parent
1422b19626
commit
f5d00c97bf
@ -76,76 +76,75 @@ const ResponseForm = ({
|
||||
onSubmit={handleSubmit(onSubmit)}
|
||||
autoComplete="off"
|
||||
>
|
||||
{memoParams?.map(([paramName, { default: defaultValue }]) => {
|
||||
const { message: errorMessage } = formState.errors[paramName] ?? {}
|
||||
|
||||
return (
|
||||
<Grid item xs={12} key={`param-${paramName}`}>
|
||||
<Controller
|
||||
render={({ value, onChange, ...controllerProps }) =>
|
||||
({
|
||||
boolean: (
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
color="primary"
|
||||
onChange={(e) => onChange(e.target.checked)}
|
||||
/>
|
||||
}
|
||||
label={paramName}
|
||||
labelPlacement="end"
|
||||
/>
|
||||
),
|
||||
object: (
|
||||
<Autocomplete
|
||||
fullWidth
|
||||
multiple
|
||||
color="secondary"
|
||||
freeSolo
|
||||
options={[]}
|
||||
onChange={(_, newValue) => onChange(newValue ?? '')}
|
||||
renderTags={(tags, getTagProps) =>
|
||||
tags.map((tag, index) => (
|
||||
<Chip
|
||||
key={`${index}-${tag}`}
|
||||
variant="outlined"
|
||||
label={tag}
|
||||
{...getTagProps({ index })}
|
||||
/>
|
||||
))
|
||||
}
|
||||
renderInput={(inputProps) => (
|
||||
<TextField
|
||||
{...inputProps}
|
||||
fullWidth
|
||||
label={paramName}
|
||||
color="secondary"
|
||||
error={Boolean(errorMessage)}
|
||||
helperText={errorMessage}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
),
|
||||
}[typeof defaultValue] ?? (
|
||||
<TextField
|
||||
error={Boolean(errorMessage)}
|
||||
helperText={errorMessage}
|
||||
fullWidth
|
||||
value={value ?? ''}
|
||||
{memoParams?.map(([paramName, { default: defaultValue }]) => (
|
||||
<Grid item xs={12} key={`param-${paramName}`}>
|
||||
<Controller
|
||||
render={({
|
||||
field: { value = '', onChange, ...controllerProps },
|
||||
fieldState: { error },
|
||||
}) =>
|
||||
({
|
||||
boolean: (
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
color="primary"
|
||||
onChange={(e) => onChange(e.target.checked)}
|
||||
/>
|
||||
}
|
||||
label={paramName}
|
||||
color="secondary"
|
||||
onChange={onChange}
|
||||
{...controllerProps}
|
||||
labelPlacement="end"
|
||||
/>
|
||||
))
|
||||
}
|
||||
control={control}
|
||||
name={`${paramName}`}
|
||||
defaultValue={defaultValue}
|
||||
/>
|
||||
</Grid>
|
||||
)
|
||||
})}
|
||||
),
|
||||
object: (
|
||||
<Autocomplete
|
||||
fullWidth
|
||||
multiple
|
||||
color="secondary"
|
||||
freeSolo
|
||||
options={[]}
|
||||
onChange={(_, newValue) => onChange(newValue ?? '')}
|
||||
renderTags={(tags, getTagProps) =>
|
||||
tags.map((tag, index) => (
|
||||
<Chip
|
||||
key={`${index}-${tag}`}
|
||||
variant="outlined"
|
||||
label={tag}
|
||||
{...getTagProps({ index })}
|
||||
/>
|
||||
))
|
||||
}
|
||||
renderInput={(inputProps) => (
|
||||
<TextField
|
||||
{...inputProps}
|
||||
fullWidth
|
||||
label={paramName}
|
||||
color="secondary"
|
||||
error={Boolean(error?.message)}
|
||||
helperText={error?.message}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
),
|
||||
}[typeof defaultValue] ?? (
|
||||
<TextField
|
||||
error={Boolean(error?.message)}
|
||||
helperText={error?.message}
|
||||
fullWidth
|
||||
value={value ?? ''}
|
||||
label={paramName}
|
||||
color="secondary"
|
||||
onChange={onChange}
|
||||
{...controllerProps}
|
||||
/>
|
||||
))
|
||||
}
|
||||
control={control}
|
||||
name={`${paramName}`}
|
||||
defaultValue={defaultValue}
|
||||
/>
|
||||
</Grid>
|
||||
))}
|
||||
<Grid item xs={12}>
|
||||
<SubmitButton
|
||||
color="secondary"
|
||||
|
Loading…
x
Reference in New Issue
Block a user