mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-26 06:50:09 +03:00
parent
3d5f29821e
commit
8fd3e9671e
@ -82,7 +82,13 @@ const AutocompleteController = memo(
|
||||
InputProps={{ readOnly }}
|
||||
error={Boolean(error)}
|
||||
helperText={
|
||||
Boolean(error) && <ErrorHelper label={error?.message} />
|
||||
Boolean(error) && (
|
||||
<ErrorHelper
|
||||
label={
|
||||
Array.isArray(error) ? error[0]?.message : error?.message
|
||||
}
|
||||
/>
|
||||
)
|
||||
}
|
||||
FormHelperTextProps={{ 'data-cy': `${cy}-error` }}
|
||||
{...inputParams}
|
||||
|
@ -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) {
|
||||
|
@ -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 },
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user