-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce VM description editing page
- Loading branch information
Showing
7 changed files
with
149 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
173 changes: 91 additions & 82 deletions
173
app/javascript/components/vm-edit-form/vm-edit-form.schema.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,91 +1,100 @@ | ||
import { componentTypes } from '@@ddf'; | ||
|
||
function createSchema(emsId, parentOptions) { | ||
const fields = [ | ||
{ | ||
component: componentTypes.SUB_FORM, | ||
name: 'BasicInformation', | ||
title: __('Basic Information'), | ||
fields: [ | ||
{ | ||
component: componentTypes.TEXT_FIELD, | ||
name: 'custom_1', | ||
label: __('Custom Identifier'), | ||
maxLength: 50, | ||
autoFocus: true, | ||
/** Function to return the description field schema. */ | ||
const descriptionField = () => ([{ | ||
component: componentTypes.TEXTAREA, | ||
name: 'description', | ||
label: __('Description'), | ||
maxLength: 100, | ||
}]); | ||
|
||
/** Function to return the form schema. */ | ||
const defaultFields = (emsId, parentOptions) => ([ | ||
{ | ||
component: componentTypes.SUB_FORM, | ||
name: 'BasicInformation', | ||
title: __('Basic Information'), | ||
fields: [ | ||
{ | ||
component: componentTypes.TEXT_FIELD, | ||
name: 'custom_1', | ||
label: __('Custom Identifier'), | ||
maxLength: 50, | ||
autoFocus: true, | ||
}, | ||
descriptionField(), | ||
], | ||
}, | ||
{ | ||
component: componentTypes.SUB_FORM, | ||
name: 'ParentVmSelection', | ||
title: __('Parent VM Selection'), | ||
fields: [ | ||
{ | ||
component: componentTypes.SELECT, | ||
label: __('Parent VM'), | ||
name: 'parent_vm', | ||
id: 'parent_vm', | ||
placeholder: __('No Parent'), | ||
includeEmpty: true, | ||
validateOnMount: true, | ||
options: parentOptions, | ||
}, | ||
], | ||
}, | ||
{ | ||
component: componentTypes.SUB_FORM, | ||
name: 'ChildVMSelection', | ||
fields: [ | ||
{ | ||
component: 'dual-list-select', | ||
id: 'child_vms', | ||
name: 'child_vms', | ||
key: `alerts-${emsId}`, | ||
label: __('Child VM Selection'), | ||
rightTitle: __('Child VMs:'), | ||
leftTitle: __('Available VMs:'), | ||
allToRight: true, | ||
moveLeftTitle: __('Move selected VMs to left'), | ||
moveRightTitle: __('Move selected VMs to right'), | ||
moveAllRightTitle: __('Move all VMs to right'), | ||
moveAllLeftTitle: __('Remove All'), | ||
noValueTitle: __('No option selected'), | ||
noOptionsTitle: __('No available options'), | ||
filterOptionsTitle: __('Filter options'), | ||
filterValuesTitle: __('Filter values'), | ||
AddButtonProps: { | ||
id: 'addButtonProps', | ||
className: 'addButtonProps', | ||
size: 'small', | ||
iconDescription: 'Add Selected', | ||
}, | ||
{ | ||
component: componentTypes.TEXTAREA, | ||
name: 'description', | ||
label: __('Description'), | ||
maxLength: 100, | ||
AddAllButtonProps: { | ||
size: 'small', | ||
iconDescription: 'Add All', | ||
}, | ||
], | ||
}, | ||
{ | ||
component: componentTypes.SUB_FORM, | ||
name: 'ParentVmSelection', | ||
title: __('Parent VM Selection'), | ||
fields: [ | ||
{ | ||
component: componentTypes.SELECT, | ||
label: __('Parent VM'), | ||
name: 'parent_vm', | ||
id: 'parent_vm', | ||
placeholder: __('No Parent'), | ||
includeEmpty: true, | ||
validateOnMount: true, | ||
options: parentOptions, | ||
RemoveButtonProps: { | ||
id: 'removeButtonProps', | ||
className: 'removeButtonProps', | ||
size: 'small', | ||
iconDescription: 'Remove Selected', | ||
}, | ||
], | ||
}, | ||
{ | ||
component: componentTypes.SUB_FORM, | ||
name: 'ChildVMSelection', | ||
fields: [ | ||
{ | ||
component: 'dual-list-select', | ||
id: 'child_vms', | ||
name: 'child_vms', | ||
key: `alerts-${emsId}`, | ||
label: __('Child VM Selection'), | ||
rightTitle: __('Child VMs:'), | ||
leftTitle: __('Available VMs:'), | ||
allToRight: true, | ||
moveLeftTitle: __('Move selected VMs to left'), | ||
moveRightTitle: __('Move selected VMs to right'), | ||
moveAllRightTitle: __('Move all VMs to right'), | ||
moveAllLeftTitle: __('Remove All'), | ||
noValueTitle: __('No option selected'), | ||
noOptionsTitle: __('No available options'), | ||
filterOptionsTitle: __('Filter options'), | ||
filterValuesTitle: __('Filter values'), | ||
AddButtonProps: { | ||
id: 'addButtonProps', | ||
className: 'addButtonProps', | ||
size: 'small', | ||
iconDescription: "Add Selected", | ||
}, | ||
AddAllButtonProps: { | ||
size: 'small', | ||
iconDescription: "Add All", | ||
}, | ||
RemoveButtonProps: { | ||
id: 'removeButtonProps', | ||
className: 'removeButtonProps', | ||
size: 'small', | ||
iconDescription: "Remove Selected", | ||
}, | ||
RemoveAllButtonProps: { | ||
size: 'small', | ||
iconDescription: "Remove All", | ||
}, | ||
options: parentOptions, | ||
RemoveAllButtonProps: { | ||
size: 'small', | ||
iconDescription: 'Remove All', | ||
}, | ||
], | ||
}, | ||
]; | ||
return { fields }; | ||
options: parentOptions, | ||
}, | ||
], | ||
}, | ||
]); | ||
|
||
function createSchema(emsId, parentOptions, editDescription) { | ||
console.log(editDescription); | ||
if (editDescription) { | ||
return { fields: descriptionField(emsId, parentOptions) }; | ||
} | ||
return { fields: defaultFields(emsId, parentOptions) }; | ||
} | ||
|
||
export default createSchema; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
#main_div | ||
= render :partial => "layouts/flash_msg" | ||
= react('VmEditForm', {:recordId => @record.id&.to_s, | ||
:emsId => @record.ems_id&.to_s, | ||
:showTitle => !@edit[:explorer], | ||
:isTemplate => @record.kind_of?(::MiqTemplate), | ||
:displayName => model_for_vm(@record).display_name}) | ||
= react('VmEditForm', {:recordId => @record.id&.to_s, | ||
:emsId => @record.ems_id&.to_s, | ||
:showTitle => !@edit[:explorer], | ||
:isTemplate => @record.kind_of?(::MiqTemplate), | ||
:displayName => model_for_vm(@record).display_name, | ||
:editDescription => @edit_description || false}) |