diff --git a/app/javascript/components/reconfigure-vm-form/reconfigure-form-fields.js b/app/javascript/components/reconfigure-vm-form/reconfigure-form-fields.js index a24a235811a..5cc178c6dac 100644 --- a/app/javascript/components/reconfigure-vm-form/reconfigure-form-fields.js +++ b/app/javascript/components/reconfigure-vm-form/reconfigure-form-fields.js @@ -149,19 +149,19 @@ const driveTable = (data, roles, setData, onCellClick) => ({ hideField: !data.dataTable.drives || data.dataTable.drives.length === 0, }); -const renderDatatables = (recordId, data, roles, setData, onCellClick, buttonClick) => { +const renderDatatables = (recordId, data, roles, setData, onCellClick, buttonClick) => [diskTable(data, roles, setData, onCellClick, buttonClick), + networkTable(data, roles, setData, onCellClick, buttonClick), + driveTable(data, roles, setData, onCellClick)]; + +export const reconfigureFormFields = (recordId, roles, memory, data, setData, options, onCellClick, buttonClick) => { + const formFields = [ + memoryField(roles), + memoryFormFields(memory), + processorField(roles), + processorFormFields(data, setData, options, memory.max_cpu), + ]; if (recordId.length === 1) { - return [diskTable(data, roles, setData, onCellClick, buttonClick), - networkTable(data, roles, setData, onCellClick, buttonClick), - driveTable(data, roles, setData, onCellClick)]; + formFields.push(renderDatatables(recordId, data, roles, setData, onCellClick, buttonClick)); } - return ''; + return formFields; }; - -export const reconfigureFormFields = (recordId, roles, memory, data, setData, options, onCellClick, buttonClick) => ([ - memoryField(roles), - memoryFormFields(memory), - processorField(roles), - processorFormFields(data, setData, options, memory.max_cpu), - renderDatatables(recordId, data, roles, setData, onCellClick, buttonClick), -]); diff --git a/app/javascript/spec/reconfigure-vm-form/__snapshots__/reconfigure-vm-form.spec.js.snap b/app/javascript/spec/reconfigure-vm-form/__snapshots__/reconfigure-vm-form.spec.js.snap index 9bcd926cd30..e05e4dad93b 100644 --- a/app/javascript/spec/reconfigure-vm-form/__snapshots__/reconfigure-vm-form.spec.js.snap +++ b/app/javascript/spec/reconfigure-vm-form/__snapshots__/reconfigure-vm-form.spec.js.snap @@ -20713,7 +20713,6 @@ exports[`Reconfigure VM form component should render reconfigure form and show h "id": "processor-sub-form", "name": "processor-sub-form", }, - "", ], ], "name": "BasicInformation", @@ -20946,7 +20945,6 @@ exports[`Reconfigure VM form component should render reconfigure form and show h "id": "processor-sub-form", "name": "processor-sub-form", }, - "", ], ], "name": "BasicInformation", @@ -21172,7 +21170,6 @@ exports[`Reconfigure VM form component should render reconfigure form and show h "id": "processor-sub-form", "name": "processor-sub-form", }, - "", ], ], "name": "BasicInformation", @@ -21195,257 +21192,4528 @@ exports[`Reconfigure VM form component should render reconfigure form and show h } } > - - - - Form could not be rendered, because of invalid form schema. - - - DefaultSchemaError - : - - - Each fields item must have "component" property! - - - If you don't know what this error means, please contact site administrator. - - - - - - - - -`; - -exports[`Reconfigure VM form component should render reconfigure form and show network add form 1`] = ` - - - + ", - "validate": Array [ - Object { - "hideField": false, - "type": "customRequired", - }, - ], - }, - Object { - "component": "select", - "hideField": true, - "id": "network", - "includeEmpty": true, - "initialValue": "", - "isRequired": true, - "label": "Network", - "name": "network", - "options": Array [], - "placeholder": "", - "validate": Array [ - Object { - "hideField": true, + , + , + ] + } + schema={ + Object { + "fields": Array [ + Object { + "className": "reconfigure_form", + "component": "sub-form", + "fields": Array [ + Array [ + Object { + "component": "switch", + "isDisabled": false, + "label": "Memory", + "name": "cb_memory", + "offText": "No", + "onText": "Yes", + }, + Object { + "className": "reconfigure-sub-form", + "component": "sub-form", + "condition": Object { + "is": true, + "when": "cb_memory", + }, + "fields": Array [ + Object { + "component": "text-field", + "condition": Object { + "is": true, + "when": "cb_memory", + }, + "initialValue": 16, + "isRequired": true, + "label": "Memory Size", + "name": "memory", + "validate": Array [ + Object { + "type": "memoryCheck", + }, + ], + }, + Object { + "component": "select", + "condition": Object { + "is": true, + "when": "cb_memory", + }, + "helperText": "Between 1024MB and 0.009765625GB", + "id": "memoryType", + "initialValue": "GB", + "label": "Unit", + "name": "mem_type", + "options": Array [ + Object { + "label": "GB", + "value": "GB", + }, + Object { + "label": "MB", + "value": "MB", + }, + ], + }, + ], + "id": "memory-sub-form", + "name": "memory-sub-form", + }, + Object { + "component": "switch", + "isDisabled": false, + "label": "Processor", + "name": "processor", + "offText": "No", + "onText": "Yes", + }, + Object { + "className": "reconfigure-sub-form", + "component": "sub-form", + "condition": Object { + "is": true, + "when": "processor", + }, + "fields": Array [ + Object { + "component": "select", + "hideField": false, + "id": "socket", + "label": "Sockets", + "name": "socket_count", + "onChange": [Function], + "options": Array [ + Object { + "label": "1", + "value": 1, + }, + Object { + "label": "2", + "value": 2, + }, + Object { + "label": "3", + "value": 3, + }, + Object { + "label": "4", + "value": 4, + }, + ], + "validate": Array [ + Object { + "field": "socket", + "type": "cpuCheck", + }, + ], + }, + Object { + "component": "select", + "hideField": false, + "id": "cores", + "label": "Cores Per Socket", + "name": "cores_per_socket_count", + "onChange": [Function], + "options": Array [ + Object { + "label": "1", + "value": 1, + }, + Object { + "label": "2", + "value": 2, + }, + Object { + "label": "3", + "value": 3, + }, + Object { + "label": "4", + "value": 4, + }, + ], + "validate": Array [ + Object { + "field": "cores", + "type": "cpuCheck", + }, + ], + }, + Object { + "component": "text-field", + "id": "total_cpus", + "initialValue": 3, + "isReadOnly": true, + "label": "Total Processors", + "name": "total_cpus", + "type": "number", + }, + ], + "id": "processor-sub-form", + "name": "processor-sub-form", + }, + ], + ], + "name": "BasicInformation", + "title": "Options", + }, + Object { + "component": "spy-field", + "initialize": undefined, + "name": "spy-field", + }, + ], + } + } + > + , + , + ] + } + hideButtons={false} + schema={ + Object { + "fields": Array [ + Object { + "className": "reconfigure_form", + "component": "sub-form", + "fields": Array [ + Array [ + Object { + "component": "switch", + "isDisabled": false, + "label": "Memory", + "name": "cb_memory", + "offText": "No", + "onText": "Yes", + }, + Object { + "className": "reconfigure-sub-form", + "component": "sub-form", + "condition": Object { + "is": true, + "when": "cb_memory", + }, + "fields": Array [ + Object { + "component": "text-field", + "condition": Object { + "is": true, + "when": "cb_memory", + }, + "initialValue": 16, + "isRequired": true, + "label": "Memory Size", + "name": "memory", + "validate": Array [ + Object { + "type": "memoryCheck", + }, + ], + }, + Object { + "component": "select", + "condition": Object { + "is": true, + "when": "cb_memory", + }, + "helperText": "Between 1024MB and 0.009765625GB", + "id": "memoryType", + "initialValue": "GB", + "label": "Unit", + "name": "mem_type", + "options": Array [ + Object { + "label": "GB", + "value": "GB", + }, + Object { + "label": "MB", + "value": "MB", + }, + ], + }, + ], + "id": "memory-sub-form", + "name": "memory-sub-form", + }, + Object { + "component": "switch", + "isDisabled": false, + "label": "Processor", + "name": "processor", + "offText": "No", + "onText": "Yes", + }, + Object { + "className": "reconfigure-sub-form", + "component": "sub-form", + "condition": Object { + "is": true, + "when": "processor", + }, + "fields": Array [ + Object { + "component": "select", + "hideField": false, + "id": "socket", + "label": "Sockets", + "name": "socket_count", + "onChange": [Function], + "options": Array [ + Object { + "label": "1", + "value": 1, + }, + Object { + "label": "2", + "value": 2, + }, + Object { + "label": "3", + "value": 3, + }, + Object { + "label": "4", + "value": 4, + }, + ], + "validate": Array [ + Object { + "field": "socket", + "type": "cpuCheck", + }, + ], + }, + Object { + "component": "select", + "hideField": false, + "id": "cores", + "label": "Cores Per Socket", + "name": "cores_per_socket_count", + "onChange": [Function], + "options": Array [ + Object { + "label": "1", + "value": 1, + }, + Object { + "label": "2", + "value": 2, + }, + Object { + "label": "3", + "value": 3, + }, + Object { + "label": "4", + "value": 4, + }, + ], + "validate": Array [ + Object { + "field": "cores", + "type": "cpuCheck", + }, + ], + }, + Object { + "component": "text-field", + "id": "total_cpus", + "initialValue": 3, + "isReadOnly": true, + "label": "Total Processors", + "name": "total_cpus", + "type": "number", + }, + ], + "id": "processor-sub-form", + "name": "processor-sub-form", + }, + ], + ], + "name": "BasicInformation", + "title": "Options", + }, + Object { + "component": "spy-field", + "initialize": undefined, + "name": "spy-field", + }, + ], + } + } + > + + + + + + + + + Options + + + + + + + + + + + + + Memory + + + No + + + Yes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Memory Size + + } + name="memory" + onBlur={[Function]} + onChange={[Function]} + onFocus={[Function]} + value="4" + warn={false} + warnText="" + > + + + + + * + + Memory Size + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Unit + + + + + + GB + + + + + MB + + + + + + + + + + + + + Between 1024MB and 0.009765625GB + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Processor + + + No + + + Yes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Sockets + + + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Cores Per Socket + + + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Total Processors + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Save + + + Reset + + + Cancel + + + + + + + + + + + +`; + +exports[`Reconfigure VM form component should render reconfigure form and show network add form 1`] = ` + + + ", + "validate": Array [ + Object { + "hideField": false, + "type": "customRequired", + }, + ], + }, + Object { + "component": "select", + "hideField": true, + "id": "network", + "includeEmpty": true, + "initialValue": "", + "isRequired": true, + "label": "Network", + "name": "network", + "options": Array [], + "placeholder": "", + "validate": Array [ + Object { + "hideField": true, "type": "customRequired", }, ], @@ -34962,744 +39230,5012 @@ exports[`Reconfigure VM form component should render reconfigure form without da "isVmwareCloud": false, "isVmwareInfra": true, } - } - > - + + + + + - , + , + ] + } + schema={ + Object { + "fields": Array [ Object { - "className": "reconfigure-sub-form", + "className": "reconfigure_form", "component": "sub-form", - "condition": Object { - "is": true, - "when": "cb_memory", - }, "fields": Array [ - Object { - "component": "text-field", - "condition": Object { - "is": true, - "when": "cb_memory", - }, - "initialValue": 16, - "isRequired": true, - "label": "Memory Size", - "name": "memory", - "validate": Array [ - Object { - "type": "memoryCheck", - }, - ], - }, - Object { - "component": "select", - "condition": Object { - "is": true, - "when": "cb_memory", + Array [ + Object { + "component": "switch", + "isDisabled": false, + "label": "Memory", + "name": "cb_memory", + "offText": "No", + "onText": "Yes", }, - "helperText": "Between 1024MB and 0.009765625GB", - "id": "memoryType", - "initialValue": "GB", - "label": "Unit", - "name": "mem_type", - "options": Array [ - Object { - "label": "GB", - "value": "GB", + Object { + "className": "reconfigure-sub-form", + "component": "sub-form", + "condition": Object { + "is": true, + "when": "cb_memory", }, - Object { - "label": "MB", - "value": "MB", + "fields": Array [ + Object { + "component": "text-field", + "condition": Object { + "is": true, + "when": "cb_memory", + }, + "initialValue": 16, + "isRequired": true, + "label": "Memory Size", + "name": "memory", + "validate": Array [ + Object { + "type": "memoryCheck", + }, + ], + }, + Object { + "component": "select", + "condition": Object { + "is": true, + "when": "cb_memory", + }, + "helperText": "Between 1024MB and 0.009765625GB", + "id": "memoryType", + "initialValue": "GB", + "label": "Unit", + "name": "mem_type", + "options": Array [ + Object { + "label": "GB", + "value": "GB", + }, + Object { + "label": "MB", + "value": "MB", + }, + ], + }, + ], + "id": "memory-sub-form", + "name": "memory-sub-form", + }, + Object { + "component": "switch", + "isDisabled": false, + "label": "Processor", + "name": "processor", + "offText": "No", + "onText": "Yes", + }, + Object { + "className": "reconfigure-sub-form", + "component": "sub-form", + "condition": Object { + "is": true, + "when": "processor", }, - ], - }, + "fields": Array [ + Object { + "component": "select", + "hideField": false, + "id": "socket", + "label": "Sockets", + "name": "socket_count", + "onChange": [Function], + "options": Array [ + Object { + "label": "1", + "value": 1, + }, + Object { + "label": "2", + "value": 2, + }, + Object { + "label": "3", + "value": 3, + }, + Object { + "label": "4", + "value": 4, + }, + ], + "validate": Array [ + Object { + "field": "socket", + "type": "cpuCheck", + }, + ], + }, + Object { + "component": "select", + "hideField": false, + "id": "cores", + "label": "Cores Per Socket", + "name": "cores_per_socket_count", + "onChange": [Function], + "options": Array [ + Object { + "label": "1", + "value": 1, + }, + Object { + "label": "2", + "value": 2, + }, + Object { + "label": "3", + "value": 3, + }, + Object { + "label": "4", + "value": 4, + }, + ], + "validate": Array [ + Object { + "field": "cores", + "type": "cpuCheck", + }, + ], + }, + Object { + "component": "text-field", + "id": "total_cpus", + "initialValue": 3, + "isReadOnly": true, + "label": "Total Processors", + "name": "total_cpus", + "type": "number", + }, + ], + "id": "processor-sub-form", + "name": "processor-sub-form", + }, + ], ], - "id": "memory-sub-form", - "name": "memory-sub-form", + "name": "BasicInformation", + "title": "Options", }, Object { - "component": "switch", - "isDisabled": false, - "label": "Processor", - "name": "processor", - "offText": "No", - "onText": "Yes", + "component": "spy-field", + "initialize": undefined, + "name": "spy-field", }, - Object { - "className": "reconfigure-sub-form", - "component": "sub-form", - "condition": Object { - "is": true, - "when": "processor", - }, - "fields": Array [ - Object { - "component": "select", - "hideField": false, - "id": "socket", - "label": "Sockets", - "name": "socket_count", - "onChange": [Function], - "options": Array [ - Object { - "label": "1", - "value": 1, - }, + ], + } + } + > + , + , + ] + } + hideButtons={false} + schema={ + Object { + "fields": Array [ + Object { + "className": "reconfigure_form", + "component": "sub-form", + "fields": Array [ + Array [ Object { - "label": "2", - "value": 2, + "component": "switch", + "isDisabled": false, + "label": "Memory", + "name": "cb_memory", + "offText": "No", + "onText": "Yes", }, Object { - "label": "3", - "value": 3, + "className": "reconfigure-sub-form", + "component": "sub-form", + "condition": Object { + "is": true, + "when": "cb_memory", + }, + "fields": Array [ + Object { + "component": "text-field", + "condition": Object { + "is": true, + "when": "cb_memory", + }, + "initialValue": 16, + "isRequired": true, + "label": "Memory Size", + "name": "memory", + "validate": Array [ + Object { + "type": "memoryCheck", + }, + ], + }, + Object { + "component": "select", + "condition": Object { + "is": true, + "when": "cb_memory", + }, + "helperText": "Between 1024MB and 0.009765625GB", + "id": "memoryType", + "initialValue": "GB", + "label": "Unit", + "name": "mem_type", + "options": Array [ + Object { + "label": "GB", + "value": "GB", + }, + Object { + "label": "MB", + "value": "MB", + }, + ], + }, + ], + "id": "memory-sub-form", + "name": "memory-sub-form", }, Object { - "label": "4", - "value": 4, + "component": "switch", + "isDisabled": false, + "label": "Processor", + "name": "processor", + "offText": "No", + "onText": "Yes", }, - ], - "validate": Array [ Object { - "field": "cores", - "type": "cpuCheck", + "className": "reconfigure-sub-form", + "component": "sub-form", + "condition": Object { + "is": true, + "when": "processor", + }, + "fields": Array [ + Object { + "component": "select", + "hideField": false, + "id": "socket", + "label": "Sockets", + "name": "socket_count", + "onChange": [Function], + "options": Array [ + Object { + "label": "1", + "value": 1, + }, + Object { + "label": "2", + "value": 2, + }, + Object { + "label": "3", + "value": 3, + }, + Object { + "label": "4", + "value": 4, + }, + ], + "validate": Array [ + Object { + "field": "socket", + "type": "cpuCheck", + }, + ], + }, + Object { + "component": "select", + "hideField": false, + "id": "cores", + "label": "Cores Per Socket", + "name": "cores_per_socket_count", + "onChange": [Function], + "options": Array [ + Object { + "label": "1", + "value": 1, + }, + Object { + "label": "2", + "value": 2, + }, + Object { + "label": "3", + "value": 3, + }, + Object { + "label": "4", + "value": 4, + }, + ], + "validate": Array [ + Object { + "field": "cores", + "type": "cpuCheck", + }, + ], + }, + Object { + "component": "text-field", + "id": "total_cpus", + "initialValue": 3, + "isReadOnly": true, + "label": "Total Processors", + "name": "total_cpus", + "type": "number", + }, + ], + "id": "processor-sub-form", + "name": "processor-sub-form", }, ], - }, - Object { - "component": "text-field", - "id": "total_cpus", - "initialValue": 3, - "isReadOnly": true, - "label": "Total Processors", - "name": "total_cpus", - "type": "number", - }, - ], - "id": "processor-sub-form", - "name": "processor-sub-form", - }, - "", - ], - ], - "name": "BasicInformation", - "title": "Options", - }, - ], - } - } - showFormControls={true} - validatorMapper={ - Object { - "cpuCheck": [Function], - "customRequired": [Function], - "diskMemoryCheck": [Function], - "memoryCheck": [Function], - } - } - > - + + + + + + + + + Options + + + + + + + + + + + + + Memory + + + No + + + Yes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Memory Size + + } + name="memory" + onBlur={[Function]} + onChange={[Function]} + onFocus={[Function]} + value="4" + warn={false} + warnText="" + > + + + + + * + + Memory Size + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Unit + + + + + + GB + + + + + MB + + + + + + + + + + + + + Between 1024MB and 0.009765625GB + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Processor + + + No + + + Yes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Sockets + + + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Cores Per Socket + + + + + + 1 + + + + + 2 + + + + + 3 + + + + + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Total Processors + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - Form could not be rendered, because of invalid form schema. - - - DefaultSchemaError - : - - - Each fields item must have "component" property! - - - If you don't know what this error means, please contact site administrator. - - - + "pristine": true, + "valid": true, + } + } + /> + + + + + + + Save + + + Reset + + + Cancel + + + + + +
- Each fields item must have "component" property! -
- If you don't know what this error means, please contact site administrator. -