ui: storage: ZFS panel: modernize & cleanup code

using cbind + pmxDisplayEditField, getting rid of initComponent

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Dominik Csapak 2023-01-18 14:13:02 +01:00 committed by Thomas Lamprecht
parent df60e210d7
commit d88be4349b

View File

@ -56,38 +56,32 @@ Ext.define('PVE.storage.ZFSPoolSelector', {
Ext.define('PVE.storage.ZFSPoolInputPanel', {
extend: 'PVE.panel.StorageBase',
mixins: ['Proxmox.Mixin.CBind'],
onlineHelp: 'storage_zfspool',
initComponent: function() {
let me = this;
column1: [
{
xtype: 'pmxDisplayEditField',
cbind: {
editable: '{isCreate}',
},
me.column1 = [];
name: 'pool',
fieldLabel: gettext('ZFS Pool'),
allowBlank: false,
if (me.isCreate) {
me.column1.push(Ext.create('PVE.storage.ZFSPoolSelector', {
name: 'pool',
fieldLabel: gettext('ZFS Pool'),
editConfig: {
xtype: 'pveZFSPoolSelector',
reference: 'zfsPoolSelector',
allowBlank: false,
listeners: {
nodechanged: function(value) {
me.lookup('storageNodeRestriction').setValue(value);
this.up('inputpanel').lookup('storageNodeRestriction').setValue(value);
},
},
}));
} else {
me.column1.push(Ext.createWidget('displayfield', {
name: 'pool',
value: '',
fieldLabel: gettext('ZFS Pool'),
allowBlank: false,
}));
}
// value is an array,
// while before it was a string
me.column1.push({
},
},
{
xtype: 'pveContentTypeSelector',
cts: ['images', 'rootdir'],
fieldLabel: gettext('Content'),
@ -95,24 +89,23 @@ Ext.define('PVE.storage.ZFSPoolInputPanel', {
value: ['images', 'rootdir'],
multiSelect: true,
allowBlank: false,
});
me.column2 = [
{
xtype: 'proxmoxcheckbox',
name: 'sparse',
checked: false,
uncheckedValue: 0,
fieldLabel: gettext('Thin provision'),
},
{
xtype: 'textfield',
name: 'blocksize',
emptyText: '8k',
fieldLabel: gettext('Block Size'),
allowBlank: true,
},
];
},
],
me.callParent();
},
column2: [
{
xtype: 'proxmoxcheckbox',
name: 'sparse',
checked: false,
uncheckedValue: 0,
fieldLabel: gettext('Thin provision'),
},
{
xtype: 'textfield',
name: 'blocksize',
emptyText: '8k',
fieldLabel: gettext('Block Size'),
allowBlank: true,
},
],
});