Skip to content

Commit

Permalink
M #-: Delete all graphics connection type except VNC (#3140)
Browse files Browse the repository at this point in the history
Signed-off-by: dcarracedo <dcarracedo@opennebula.io>
Co-authored-by: Tino Vázquez <cvazquez@opennebula.io>
  • Loading branch information
dcarracedo and tinova authored Jul 4, 2024
1 parent cd4388b commit 7310494
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
getObjectSchemaFromFields,
} from 'client/utils'

const { vcenter, lxc, kvm } = HYPERVISORS
const { lxc } = HYPERVISORS
const CUSTOM_KEYMAP_VALUE = 'custom'
const KEYMAP_VALUES = {
ar: T.Arabic,
Expand Down Expand Up @@ -68,21 +68,13 @@ const KEYMAP_VALUES = {
/** @type {Field} Type field */
export const TYPE = (isUpdate) => ({
name: 'GRAPHICS.TYPE',
type: INPUT_TYPES.TOGGLE,
type: INPUT_TYPES.SWITCH,
label: T.Vnc,
dependOf: ['HYPERVISOR', '$general.HYPERVISOR'],
values: ([templateHyperv = kvm, hypervisor = templateHyperv] = []) => {
const types = {
[vcenter]: [T.Vmrc],
[lxc]: [T.Vnc],
}[hypervisor] ?? [T.Vnc, T.Sdl, T.Spice]

return arrayToOptions(types)
},
validation: string()
.trim()
validation: boolean()
.notRequired()
.uppercase()
.default(() => (isUpdate ? undefined : T.Vnc)),
.afterSubmit((value, { context }) => (value ? 'VNC' : undefined))
.default(() => (isUpdate ? undefined : true)),
grid: { md: 12 },
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ const Steps = createSteps([General, ExtraConfiguration, CustomVariables], {
}
}

// Init GRPAHICS.TYPE
const type = vmTemplate?.TEMPLATE?.GRAPHICS?.TYPE === 'VNC'
if (type) {
objectSchema[EXTRA_ID].GRAPHICS = {
...vmTemplate?.GRAPHICS,
TYPE: type,
}
}

const knownTemplate = schema.cast(objectSchema, {
stripUnknown: true,
context: { ...vmTemplate, [EXTRA_ID]: vmTemplate.TEMPLATE },
Expand Down

0 comments on commit 7310494

Please sign in to comment.