mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
parent
83df0dffee
commit
1d164984d4
@ -74,7 +74,7 @@ const DiskItem = memo(({
|
||||
<Translate word={T.VolatileDisk} />
|
||||
</>
|
||||
) : (
|
||||
<Stack component='span' alignItems='center' gap='0.5em'>
|
||||
<Stack component='span' direction='row' alignItems='center' gap='0.5em'>
|
||||
<StatusCircle color={state?.color} tooltip={state?.name} />
|
||||
{`${NAME}: ${IMAGE}`}
|
||||
{isPersistent && <StatusChip text='PERSISTENT' />}
|
||||
|
@ -56,7 +56,7 @@ export const MEMORY_MAX = {
|
||||
htmlType: enabledHr => enabledHr ? 'number' : INPUT_TYPES.HIDDEN,
|
||||
validation: commonValidation
|
||||
.when(ENABLE_HR_MEMORY.name, (enabledHr, schema) =>
|
||||
enabledHr ? schema.required() : schema.strip().notRequired()
|
||||
enabledHr ? schema.required() : schema.notRequired()
|
||||
),
|
||||
grid: { xs: 8, md: 6 }
|
||||
}
|
||||
@ -101,7 +101,7 @@ export const VCPU_MAX = {
|
||||
htmlType: enabledHr => enabledHr ? 'number' : INPUT_TYPES.HIDDEN,
|
||||
validation: commonValidation
|
||||
.when(ENABLE_HR_VCPU.name, (enabledHr, schema) =>
|
||||
enabledHr ? schema.required() : schema.strip().notRequired()
|
||||
enabledHr ? schema.required() : schema.notRequired()
|
||||
),
|
||||
grid: { xs: 8, md: 6 }
|
||||
}
|
||||
|
@ -65,12 +65,13 @@ const Content = ({ isUpdate }) => {
|
||||
|
||||
const General = initialValues => {
|
||||
const isUpdate = initialValues?.NAME
|
||||
const initialHypervisor = initialValues?.TEMPLATE?.HYPERVISOR
|
||||
|
||||
return {
|
||||
id: STEP_ID,
|
||||
label: T.General,
|
||||
resolver: formData => {
|
||||
const hypervisor = formData?.[STEP_ID]?.HYPERVISOR
|
||||
const hypervisor = formData?.[STEP_ID]?.HYPERVISOR ?? initialHypervisor
|
||||
return SCHEMA(hypervisor, isUpdate)
|
||||
},
|
||||
optionsValidate: { abortEarly: false },
|
||||
|
@ -20,9 +20,16 @@ import PropTypes from 'prop-types'
|
||||
import { useForm, FormProvider } from 'react-hook-form'
|
||||
import { yupResolver } from '@hookform/resolvers/yup'
|
||||
|
||||
import {
|
||||
useUserApi,
|
||||
useVmGroupApi,
|
||||
useVmTemplateApi,
|
||||
useHostApi,
|
||||
useImageApi,
|
||||
useDatastoreApi
|
||||
} from 'client/features/One'
|
||||
|
||||
import { useFetch } from 'client/hooks'
|
||||
// import { useUserApi, useVmGroupApi, useVmTemplateApi } from 'client/features/One'
|
||||
import { useVmTemplateApi, useHostApi, useImageApi, useDatastoreApi } from 'client/features/One'
|
||||
import FormStepper, { SkeletonStepsForm } from 'client/components/FormStepper'
|
||||
import Steps from 'client/components/Forms/VmTemplate/CreateForm/Steps'
|
||||
|
||||
@ -48,12 +55,13 @@ const CreateForm = ({ template, onSubmit }) => {
|
||||
}
|
||||
|
||||
const PreFetchingForm = ({ templateId, onSubmit }) => {
|
||||
// const { getUsers } = useUserApi()
|
||||
// const { getVmGroups } = useVmGroupApi()
|
||||
const { getUsers } = useUserApi()
|
||||
const { getVmGroups } = useVmGroupApi()
|
||||
const { getHosts } = useHostApi()
|
||||
const { getImages } = useImageApi()
|
||||
const { getDatastores } = useDatastoreApi()
|
||||
const { getVmTemplate } = useVmTemplateApi()
|
||||
|
||||
const { fetchRequest, data } = useFetch(
|
||||
() => getVmTemplate(templateId, { extended: true })
|
||||
)
|
||||
@ -63,8 +71,8 @@ const PreFetchingForm = ({ templateId, onSubmit }) => {
|
||||
getHosts()
|
||||
getImages()
|
||||
getDatastores()
|
||||
// getUsers()
|
||||
// getVmGroups()
|
||||
getUsers()
|
||||
getVmGroups()
|
||||
}, [])
|
||||
|
||||
return (templateId && !data)
|
||||
|
@ -38,7 +38,7 @@ const AttributeCreateForm = memo(({ handleAdd }) => {
|
||||
const nameInputKey = useMemo(() => `name-${key}`, [key])
|
||||
const valueInputKey = useMemo(() => `value-${key}`, [key])
|
||||
|
||||
const { handleSubmit, reset, control, formState } = useForm({
|
||||
const { handleSubmit, reset, control } = useForm({
|
||||
defaultValues: { [nameInputKey]: '', [valueInputKey]: '' }
|
||||
})
|
||||
|
||||
@ -59,8 +59,8 @@ const AttributeCreateForm = memo(({ handleAdd }) => {
|
||||
<Controller
|
||||
control={control}
|
||||
name={nameInputKey}
|
||||
render={fieldProps =>
|
||||
<Inputs.Text {...fieldProps} disabled={formState.isSubmitting} />
|
||||
render={({ field, formState }) =>
|
||||
<Inputs.Text {...field} disabled={formState.isSubmitting} />
|
||||
}
|
||||
/>
|
||||
|
||||
@ -69,8 +69,8 @@ const AttributeCreateForm = memo(({ handleAdd }) => {
|
||||
<Controller
|
||||
control={control}
|
||||
name={valueInputKey}
|
||||
render={fieldProps =>
|
||||
<Inputs.Text {...fieldProps} disabled={formState.isSubmitting} />
|
||||
render={({ field, formState }) =>
|
||||
<Inputs.Text {...field} disabled={formState.isSubmitting} />
|
||||
}
|
||||
/>
|
||||
<Actions.Add
|
||||
|
@ -295,7 +295,7 @@ export const getUserInputString = userInput => {
|
||||
* @param {object} userInputs - List of user inputs in string format
|
||||
* @returns {UserInputObject[]} User input object
|
||||
*/
|
||||
export const userInputsToArray = userInputs => {
|
||||
export const userInputsToArray = (userInputs = {}) => {
|
||||
return Object
|
||||
.entries(userInputs)
|
||||
.map(([name, ui]) => ({ name, ...getUserInputParams(ui) }))
|
||||
|
Loading…
x
Reference in New Issue
Block a user