mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
M #-: Fix fireedge func (#3172)
* Fix oneflow cardinality parsing * Fix VNC validation Signed-off-by: Victor Hansson <vhansson@opennebula.io>
This commit is contained in:
parent
1ae1de46dc
commit
3eef17868c
@ -42,7 +42,7 @@ const RoleVmVmPanel = ({ roles, onChange, selectedRoleIndex }) => {
|
||||
|
||||
const handleTextFieldChange = (event) => {
|
||||
const { name, value } = event.target
|
||||
handleInputChange(name, value)
|
||||
handleInputChange(name, parseInt(value, 10))
|
||||
}
|
||||
|
||||
const handleAutocompleteChange = (event, value) => {
|
||||
|
@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and *
|
||||
* limitations under the License. *
|
||||
* ------------------------------------------------------------------------- */
|
||||
import { ObjectSchema, boolean, lazy, string } from 'yup'
|
||||
import { ObjectSchema, boolean, lazy, string, mixed } from 'yup'
|
||||
|
||||
import { HYPERVISORS, INPUT_TYPES, T } from 'client/constants'
|
||||
import {
|
||||
@ -71,10 +71,21 @@ export const TYPE = (isUpdate) => ({
|
||||
type: INPUT_TYPES.SWITCH,
|
||||
label: T.Vnc,
|
||||
dependOf: ['HYPERVISOR', '$general.HYPERVISOR'],
|
||||
validation: boolean()
|
||||
.notRequired()
|
||||
validation: mixed()
|
||||
.default(() => (isUpdate ? undefined : true))
|
||||
.afterSubmit((value, { context }) => (value ? 'VNC' : undefined))
|
||||
.default(() => (isUpdate ? undefined : true)),
|
||||
.test('is-valid-type', 'Invalid value', function (value) {
|
||||
if (
|
||||
typeof value === 'boolean' ||
|
||||
value === 'VNC' ||
|
||||
value === undefined
|
||||
) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}),
|
||||
|
||||
grid: { md: 12 },
|
||||
})
|
||||
|
||||
|
@ -20,6 +20,7 @@ import {
|
||||
number,
|
||||
string,
|
||||
boolean,
|
||||
mixed,
|
||||
object,
|
||||
array,
|
||||
date,
|
||||
@ -29,26 +30,28 @@ import { T } from 'client/constants'
|
||||
import { isDivisibleBy, isBase64 } from 'client/utils/number'
|
||||
|
||||
const buildMethods = () => {
|
||||
;[number, string, boolean, object, array, date].forEach((schemaType) => {
|
||||
addMethod(schemaType, 'afterSubmit', function (fn) {
|
||||
this._mutate = true // allows to mutate the initial schema
|
||||
this.submit = (...args) =>
|
||||
typeof fn === 'function' ? fn(...args) : args[0]
|
||||
;[number, string, boolean, mixed, object, array, date].forEach(
|
||||
(schemaType) => {
|
||||
addMethod(schemaType, 'afterSubmit', function (fn) {
|
||||
this._mutate = true // allows to mutate the initial schema
|
||||
this.submit = (...args) =>
|
||||
typeof fn === 'function' ? fn(...args) : args[0]
|
||||
|
||||
return this
|
||||
})
|
||||
addMethod(schemaType, 'cast', function (value, options = {}) {
|
||||
const resolvedSchema = this.resolve({ value, ...options })
|
||||
let result = resolvedSchema._cast(value, options)
|
||||
return this
|
||||
})
|
||||
addMethod(schemaType, 'cast', function (value, options = {}) {
|
||||
const resolvedSchema = this.resolve({ value, ...options })
|
||||
let result = resolvedSchema._cast(value, options)
|
||||
|
||||
if (options.isSubmit) {
|
||||
const needChangeAfterSubmit = typeof this.submit === 'function'
|
||||
needChangeAfterSubmit && (result = this.submit(result, options))
|
||||
}
|
||||
if (options.isSubmit) {
|
||||
const needChangeAfterSubmit = typeof this.submit === 'function'
|
||||
needChangeAfterSubmit && (result = this.submit(result, options))
|
||||
}
|
||||
|
||||
return result
|
||||
})
|
||||
})
|
||||
return result
|
||||
})
|
||||
}
|
||||
)
|
||||
addMethod(boolean, 'yesOrNo', function (addAfterSubmit = true) {
|
||||
const schema = this.transform(function (value) {
|
||||
return !this.isType(value) ? String(value).toUpperCase() === 'YES' : value
|
||||
|
Loading…
x
Reference in New Issue
Block a user