1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-29 18:50:08 +03:00

F #3951: Fix warning in provider form (#538)

This commit is contained in:
Sergio Betanzos 2020-12-10 13:06:52 +01:00 committed by GitHub
parent 6df1cd1702
commit 7c748da499
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,15 +24,24 @@ const Connection = () => ({
content: useCallback(() => {
const [fields, setFields] = useState([])
const { providersTemplates } = useProvision()
const { watch } = useFormContext()
const { watch, reset } = useFormContext()
useEffect(() => {
const { [PROVIDER_ID]: provider } = watch()
const {
[PROVIDER_ID]: provider,
[STEP_ID]: currentConnections
} = watch()
const providerTemplate = providersTemplates
.find(({ name }) => name === provider?.[0])
connection = providerTemplate?.connection ?? {}
setFields(FORM_FIELDS(connection))
// set defaults connection values when first render
!currentConnections && reset({
...watch(),
[STEP_ID]: STEP_FORM_SCHEMA(connection).default()
})
}, [])
return (fields?.length === 0) ? (