From d88be4349b529bd308f1e1b90e82b29276872857 Mon Sep 17 00:00:00 2001 From: Dominik Csapak Date: Wed, 18 Jan 2023 14:13:02 +0100 Subject: [PATCH] ui: storage: ZFS panel: modernize & cleanup code using cbind + pmxDisplayEditField, getting rid of initComponent Signed-off-by: Dominik Csapak Signed-off-by: Thomas Lamprecht --- www/manager6/storage/ZFSPoolEdit.js | 77 +++++++++++++---------------- 1 file changed, 35 insertions(+), 42 deletions(-) diff --git a/www/manager6/storage/ZFSPoolEdit.js b/www/manager6/storage/ZFSPoolEdit.js index df12fbbc..1cbdc1ca 100644 --- a/www/manager6/storage/ZFSPoolEdit.js +++ b/www/manager6/storage/ZFSPoolEdit.js @@ -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, + }, + ], }); -- 2.39.5