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

F #3951: Fix provider form with hide credentials (#1092)

(cherry picked from commit cefab36b1fb85094a57fda04b42b0dd4af4aec69)
This commit is contained in:
Sergio Betanzos 2021-04-12 14:18:00 +02:00 committed by Ruben S. Montero
parent b44d880f7f
commit 2384d48c7f
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
2 changed files with 21 additions and 17 deletions

View File

@ -8,7 +8,7 @@ import { yupResolver } from '@hookform/resolvers'
import FormStepper from 'client/components/FormStepper'
import Steps from 'client/containers/Providers/Form/Create/Steps'
import { useFetch, useProvision, useGeneral } from 'client/hooks'
import { useFetchAll, useGeneral, useProvision } from 'client/hooks'
import * as ProviderTemplateModel from 'client/models/ProviderTemplate'
import { PATH } from 'client/router/provision'
@ -19,11 +19,12 @@ function ProviderCreateForm () {
const {
getProvider,
getProviderConnection,
createProvider,
updateProvider
} = useProvision()
const { data, fetchRequest, loading, error } = useFetch(getProvider)
const { data, fetchRequestAll, loading, error } = useFetchAll()
const { steps, defaultValues, resolvers } = Steps({ isUpdate })
const { showError, changeLoading } = useGeneral()
@ -72,19 +73,19 @@ function ProviderCreateForm () {
const callUpdateProvider = formData => {
const { configuration, connection: connectionEditable } = formData
const { description } = configuration
const [provider = {}, connection = []] = data
const {
PLAIN: { location_key: locationKey } = {},
PROVISION_BODY: {
connection: { [locationKey]: connectionFixed },
registration_time: registrationTime
}
} = data?.TEMPLATE
PROVISION_BODY: currentBodyTemplate
} = provider?.TEMPLATE
const { [locationKey]: connectionFixed } = connection
const formatData = {
...currentBodyTemplate,
description,
connection: { ...connectionEditable, [locationKey]: connectionFixed },
registration_time: registrationTime
connection: { ...connectionEditable, [locationKey]: connectionFixed }
}
updateProvider({ id, data: formatData })
@ -97,19 +98,22 @@ function ProviderCreateForm () {
}
useEffect(() => {
isUpdate && fetchRequest({ id })
isUpdate && fetchRequestAll([
getProvider({ id }),
getProviderConnection({ id })
])
}, [isUpdate])
useEffect(() => {
if (data) {
const [provider = {}, connection = []] = data
const {
PLAIN: { location_key: locationKey } = {},
PROVISION_BODY: {
connection: { [locationKey]: _, ...connectionEditable },
description,
name
}
} = data?.TEMPLATE
PROVISION_BODY: { description, name }
} = provider?.TEMPLATE
const { [locationKey]: _, ...connectionEditable } = connection
methods.reset({
connection: connectionEditable,

View File

@ -36,7 +36,7 @@ const Info = memo(({ data }) => {
icon={<Visibility />}
cy='provider-connection'
handleClick={() => getProviderConnection({ id: ID })
.then(connection => setShowConnection(connection))}
.then(setShowConnection)}
/>
)