diff --git a/src/fireedge/src/client/components/FormControl/AutocompleteController.js b/src/fireedge/src/client/components/FormControl/AutocompleteController.js index 2fe2ffcce7..3123e89038 100644 --- a/src/fireedge/src/client/components/FormControl/AutocompleteController.js +++ b/src/fireedge/src/client/components/FormControl/AutocompleteController.js @@ -82,7 +82,13 @@ const AutocompleteController = memo( InputProps={{ readOnly }} error={Boolean(error)} helperText={ - Boolean(error) && + Boolean(error) && ( + + ) } FormHelperTextProps={{ 'data-cy': `${cy}-error` }} {...inputParams} diff --git a/src/fireedge/src/client/components/FormControl/SliderController.js b/src/fireedge/src/client/components/FormControl/SliderController.js index e92e7dccef..6c820ba035 100644 --- a/src/fireedge/src/client/components/FormControl/SliderController.js +++ b/src/fireedge/src/client/components/FormControl/SliderController.js @@ -33,6 +33,8 @@ const SliderController = memo( fieldProps = {}, readOnly = false, }) => { + const { min, max, step } = fieldProps ?? {} + const { field: { value, onChange, ...inputProps }, fieldState: { error }, @@ -68,14 +70,14 @@ const SliderController = memo( inputProps={{ 'data-cy': inputId, 'aria-labelledby': sliderId, - ...fieldProps, + min, + max, + step, }} onChange={(evt) => onChange(!evt.target.value ? '0' : Number(evt.target.value)) } onBlur={() => { - const { min, max } = fieldProps ?? {} - if (min && value < min) { onChange(min) } else if (max && value > max) { diff --git a/src/fireedge/src/client/components/Forms/VmTemplate/CreateForm/Steps/General/capacityUtils.js b/src/fireedge/src/client/components/Forms/VmTemplate/CreateForm/Steps/General/capacityUtils.js index 2d7a130d83..43f8b2c1b4 100644 --- a/src/fireedge/src/client/components/Forms/VmTemplate/CreateForm/Steps/General/capacityUtils.js +++ b/src/fireedge/src/client/components/Forms/VmTemplate/CreateForm/Steps/General/capacityUtils.js @@ -173,13 +173,14 @@ const modificationOptionsInput = (fieldName, { type, options: optionsId }) => ({ .when(`$general.${type}`, { is: (modificationType) => modificationType === list, then: (schema) => schema.required().min(1), - otherwise: (schema) => schema.nullable(), + otherwise: (schema) => schema.notRequired().nullable(), }) .default(() => { const capacityUserInput = context.extra?.USER_INPUTS?.[fieldName] const { options = [] } = getUserInputParams(capacityUserInput) + const numberOpts = options?.filter((opt) => opt !== ' ' && !isNaN(+opt)) - return options + return numberOpts }) ), fieldProps: { freeSolo: true }, diff --git a/src/fireedge/src/client/components/Forms/VmTemplate/InstantiateForm/Steps/BasicConfiguration/capacitySchema.js b/src/fireedge/src/client/components/Forms/VmTemplate/InstantiateForm/Steps/BasicConfiguration/capacitySchema.js index 9457414b6e..5373675ff9 100644 --- a/src/fireedge/src/client/components/Forms/VmTemplate/InstantiateForm/Steps/BasicConfiguration/capacitySchema.js +++ b/src/fireedge/src/client/components/Forms/VmTemplate/InstantiateForm/Steps/BasicConfiguration/capacitySchema.js @@ -21,7 +21,9 @@ import { prettyBytes, isDivisibleBy, } from 'client/utils' -import { T, HYPERVISORS, VmTemplate } from 'client/constants' +import { T, HYPERVISORS, USER_INPUT_TYPES, VmTemplate } from 'client/constants' + +const { number, numberFloat } = USER_INPUT_TYPES const TRANSLATES = { MEMORY: { name: 'MEMORY', label: T.Memory, tooltip: T.MemoryConcept }, @@ -45,9 +47,9 @@ export const FIELDS = (vmTemplate) => { } = vmTemplate?.TEMPLATE || {} const { - MEMORY: memoryInput = `M|number|||${MEMORY}`, - CPU: cpuInput = `M|number-float|||${CPU}`, - VCPU: vcpuInput = `O|number|||${VCPU}`, + MEMORY: memoryInput = `M|${number}|| |${MEMORY}`, + CPU: cpuInput = `M|${numberFloat}|| |${CPU}`, + VCPU: vcpuInput = `O|${number}|| |${VCPU}`, } = USER_INPUTS return [ @@ -59,6 +61,9 @@ export const FIELDS = (vmTemplate) => { const isVCenter = HYPERVISOR === HYPERVISORS.vcenter const divisibleBy4 = isVCenter && isMemory + // set default type to number + userInput.type ??= name === 'CPU' ? numberFloat : number + const ensuredOptions = divisibleBy4 ? options?.filter((value) => isDivisibleBy(+value, 4)) : options