mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-29 18:50:08 +03:00
parent
6df1cd1702
commit
7c748da499
@ -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) ? (
|
||||
|
Loading…
x
Reference in New Issue
Block a user