mirror of
https://github.com/OpenNebula/one.git
synced 2026-12-06 07:04:45 +09:00
1 parent
51ef176d5f
commit
4ad14daf2e
8 files changed
+31
-26
No files matched your search
@@ -23,7 +23,7 @@ const AutocompleteController = memo(
|
||||
onChange={(_, newValue) => {
|
||||
const newValueToChange = multiple
|
||||
? newValue?.map(value =>
|
||||
typeof value === 'string' ? ({ text: value, value }) : value
|
||||
typeof value === 'string' ? value : ({ text: value, value })
|
||||
)
|
||||
: newValue.value
|
||||
|
||||
@@ -33,12 +33,13 @@ const AutocompleteController = memo(
|
||||
value={selected}
|
||||
multiple={multiple}
|
||||
renderTags={(tags, getTagProps) =>
|
||||
// render when freesolo prop
|
||||
tags.map((tag, index) => (
|
||||
<Chip
|
||||
key={tag.value}
|
||||
key={tag}
|
||||
size="small"
|
||||
variant="outlined"
|
||||
label={tag.text}
|
||||
label={tag}
|
||||
{...getTagProps({ index })}
|
||||
/>
|
||||
))
|
||||
|
||||
@@ -18,7 +18,7 @@ const Datastores = memo(({ hidden, data }) => {
|
||||
|
||||
useEffect(() => {
|
||||
if (!list && !hidden) {
|
||||
const reqs = datastores?.map(({ id }) => getDatastore({ id }))
|
||||
const reqs = datastores?.map(({ id }) => getDatastore({ id })) ?? []
|
||||
fetchRequestAll(reqs)
|
||||
}
|
||||
}, [hidden])
|
||||
|
||||
@@ -19,7 +19,7 @@ const Hosts = memo(({ hidden, data }) => {
|
||||
|
||||
useEffect(() => {
|
||||
if (!list && !hidden) {
|
||||
const reqs = hosts?.map(({ id }) => getHost({ id }))
|
||||
const reqs = hosts?.map(({ id }) => getHost({ id })) ?? []
|
||||
fetchRequestAll(reqs)
|
||||
}
|
||||
}, [hidden])
|
||||
|
||||
@@ -18,7 +18,7 @@ const Networks = memo(({ hidden, data }) => {
|
||||
|
||||
useEffect(() => {
|
||||
if (!list && !hidden) {
|
||||
const reqs = networks?.map(({ id }) => getVNetwork({ id }))
|
||||
const reqs = networks?.map(({ id }) => getVNetwork({ id })) ?? []
|
||||
fetchRequestAll(reqs)
|
||||
}
|
||||
}, [hidden])
|
||||
|
||||
@@ -59,6 +59,7 @@ const Provider = () => ({
|
||||
isSelected ? handleUnselect(NAME) : handleSelect(NAME)
|
||||
}
|
||||
}}
|
||||
breakpoints={{ xs: 12, sm: 6, md: 4 }}
|
||||
/>
|
||||
)
|
||||
}, [])
|
||||
|
||||
@@ -18,3 +18,4 @@ export * from 'client/utils/request'
|
||||
export * from 'client/utils/helpers'
|
||||
export * from 'client/utils/polyfills'
|
||||
export * from 'client/utils/schema'
|
||||
export * from 'client/utils/merge'
|
||||
@@ -3,22 +3,7 @@ import { STEP_ID as NETWORKING_ID } from 'client/containers/ApplicationsTemplate
|
||||
import { STEP_ID as TIERS_ID } from 'client/containers/ApplicationsTemplates/Form/Deploy/Steps/Tiers'
|
||||
import { STEP_ID as CLUSTER_ID } from 'client/containers/ApplicationsTemplates/Form/Create/Steps/Clusters'
|
||||
|
||||
import { deepmerge } from 'client/utils/merge'
|
||||
|
||||
export const parseUserInputValue = value => {
|
||||
if (value === true) {
|
||||
return 'YES'
|
||||
} if (value === false) {
|
||||
return 'NO'
|
||||
} else if (Array.isArray(value)) {
|
||||
return value.join(',')
|
||||
} else return value
|
||||
}
|
||||
|
||||
export const mapUserInputs = userInputs =>
|
||||
Object.entries(userInputs)?.reduce((res, [key, value]) => ({
|
||||
...res, [key]: parseUserInputValue(value)
|
||||
}), {})
|
||||
import { mapUserInputs, deepmerge } from 'client/utils'
|
||||
|
||||
export const mapTiersToRoles = (tiers, networking, cluster) =>
|
||||
tiers?.map(data => {
|
||||
|
||||
@@ -9,6 +9,8 @@ const requiredSchema = (mandatory, name, schema) =>
|
||||
const getRange = (options) =>
|
||||
options.split('..').map(option => parseFloat(option))
|
||||
|
||||
const getValuesFromArray = (options, separator = ',') => options?.split(separator)
|
||||
|
||||
const getOptionsFromList = (options, separator = ',') =>
|
||||
options?.split(separator).map(value => ({ text: value, value }))
|
||||
|
||||
@@ -70,7 +72,7 @@ export const schemaUserInput = ({ mandatory, name, type, options, defaultValue }
|
||||
}
|
||||
}
|
||||
case 'array': {
|
||||
const defaultValues = getOptionsFromList(defaultValue)
|
||||
const defaultValues = getValuesFromArray(defaultValue)
|
||||
|
||||
return {
|
||||
type: INPUT_TYPES.AUTOCOMPLETE,
|
||||
@@ -78,9 +80,7 @@ export const schemaUserInput = ({ mandatory, name, type, options, defaultValue }
|
||||
validation: yup.array(yup.string().trim())
|
||||
.concat(requiredSchema(mandatory, name, yup.array()))
|
||||
.default(defaultValues),
|
||||
fieldProps: {
|
||||
freeSolo: true
|
||||
}
|
||||
fieldProps: { freeSolo: true }
|
||||
}
|
||||
}
|
||||
case 'list-multiple': {
|
||||
@@ -105,3 +105,20 @@ export const schemaUserInput = ({ mandatory, name, type, options, defaultValue }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Parser USER INPUTS
|
||||
|
||||
const parseUserInputValue = value => {
|
||||
if (value === true) {
|
||||
return 'YES'
|
||||
} if (value === false) {
|
||||
return 'NO'
|
||||
} else if (Array.isArray(value)) {
|
||||
return value.join(',')
|
||||
} else return value
|
||||
}
|
||||
|
||||
export const mapUserInputs = userInputs =>
|
||||
Object.entries(userInputs)?.reduce((res, [key, value]) => ({
|
||||
...res, [key]: parseUserInputValue(value)
|
||||
}), {})
|
||||
Reference in new issue
Block a user