From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id BC20BAE5D for ; Wed, 6 Apr 2022 10:04:43 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8EF512726A for ; Wed, 6 Apr 2022 10:04:41 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 6854D270C7 for ; Wed, 6 Apr 2022 10:04:37 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 409AB42949 for ; Wed, 6 Apr 2022 10:04:37 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Wed, 6 Apr 2022 10:04:01 +0200 Message-Id: <20220406080416.66227-5-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220406080416.66227-1-f.ebner@proxmox.com> References: <20220406080416.66227-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.112 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH v10 manager 04/19] ui: disk storage selector: add setSize function X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Apr 2022 08:04:43 -0000 In preparation for disk import from an existing volume. Signed-off-by: Fabian Ebner --- www/manager6/form/DiskStorageSelector.js | 25 +++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/www/manager6/form/DiskStorageSelector.js b/www/manager6/form/DiskStorageSelector.js index ac6b064f..9699938e 100644 --- a/www/manager6/form/DiskStorageSelector.js +++ b/www/manager6/form/DiskStorageSelector.js @@ -25,8 +25,10 @@ Ext.define('PVE.form.DiskStorageSelector', { // hideSelection is not true hideSelection: undefined, - // hides the size field (e.g, for the efi disk dialog) + // hides and disables the size field (e.g, for the efi disk dialog) hideSize: false, + // disables the size field (e.g. when importing from existing volume) + disableSize: false, // hides the format field (e.g. for TPM state), always assumes 'raw' hideFormat: false, @@ -75,7 +77,7 @@ Ext.define('PVE.form.DiskStorageSelector', { hdfilesel.setStorage(value); } - hdsizesel.setDisabled(select || me.hideSize); + hdsizesel.setDisabled(select || me.hideSize || me.disableSize); hdsizesel.setVisible(!select && !me.hideSize); }, @@ -103,6 +105,23 @@ Ext.define('PVE.form.DiskStorageSelector', { hdstorage.fireEvent('validitychange'); }, + setSize: function(size, fixed) { + let me = this; + let sizeField = me.getComponent('disksize'); + + me.disableSize = fixed; + // For import, size 0 shouldn't show as invalid, so disable first. + sizeField.setDisabled(fixed); + + if (size === undefined || size === null) { + size = me.defaultSize; + } else { + size = size / Proxmox.Utils.SizeUnits.GiB; + } + + sizeField.setValue(size); + }, + initComponent: function() { var me = this; @@ -143,7 +162,7 @@ Ext.define('PVE.form.DiskStorageSelector', { name: 'disksize', fieldLabel: gettext('Disk size') + ' (GiB)', hidden: me.hideSize, - disabled: me.hideSize, + disabled: me.hideSize || me.disableSize, minValue: 0.001, maxValue: 128*1024, decimalPrecision: 3, -- 2.30.2