[pve-devel] [PATCH v2 manager 2/2] fix 3850: ui: storage: using PreallocationSelector for file based storage types

Fabian Ebner f.ebner at proxmox.com
Thu Oct 7 14:45:18 CEST 2021


Am 28.09.21 um 15:07 schrieb Lorenz Stechauner:
> Signed-off-by: Lorenz Stechauner <l.stechauner at proxmox.com>
> ---
>   www/manager6/controller/StorageEdit.js |  6 ++++++
>   www/manager6/storage/Base.js           | 18 ++++++++++++++++++
>   www/manager6/storage/NFSEdit.js        |  2 +-
>   3 files changed, 25 insertions(+), 1 deletion(-)
> 
> diff --git a/www/manager6/controller/StorageEdit.js b/www/manager6/controller/StorageEdit.js
> index 4246d363..cb73b776 100644
> --- a/www/manager6/controller/StorageEdit.js
> +++ b/www/manager6/controller/StorageEdit.js
> @@ -4,6 +4,12 @@ Ext.define('PVE.controller.StorageEdit', {
>       control: {
>   	'field[name=content]': {
>   	    change: function(field, value) {
> +		const hasImages = Ext.Array.contains(value, 'images');
> +		const prealloc = field.up('form').getForm().findField('preallocation');
> +		if (prealloc) {
> +		    prealloc.setDisabled(!hasImages);
> +		}
> +
>   		var hasBackups = Ext.Array.contains(value, 'backup');
>   		var maxfiles = this.lookupReference('maxfiles');
>   		if (!maxfiles) {
> diff --git a/www/manager6/storage/Base.js b/www/manager6/storage/Base.js
> index f339e8cd..404a90f5 100644
> --- a/www/manager6/storage/Base.js
> +++ b/www/manager6/storage/Base.js
> @@ -51,6 +51,24 @@ Ext.define('PVE.panel.StorageBase', {
>   	    },
>   	);
>   
> +	const qemuImgStorageTypes = ['dir', 'btrfs', 'nfs', 'cifs'];
> +
> +	if (qemuImgStorageTypes.includes(me.type)) {
> +	    const preallocSelector = {
> +		xtype: 'pvePreallocationSelector',
> +		name: 'preallocation',
> +		fieldLabel: gettext('Preallocation'),
> +		allowBlank: false,
> +		value: '__default__',
> +	    };
> +
> +	    if (me.advancedColumn1) {
> +		me.advancedColumn1.unshift(preallocSelector);
> +	    } else {
> +		me.advancedColumn1 = [preallocSelector];
> +	    }

Nit: Pushing (or unshifting) the selector onto the advanced column with 
fewer elements seems a bit more future-proof to me:

me.advancedColumn1 = me.advancedColumn1 || [];
me.advancedColumn2 = me.advancedColumn2 || [];
if (me.advancedColumn2.length < me.advancedColumn1.length) {
     me.advancedColumn2.push(preallocSelector);
} else {
     me.advancedColumn1.push(preallocSelector);
}

Then the change for NFS below wouldn't be necessary either, but of 
course no big deal.

> +	}
> +
>   	me.callParent();
>       },
>   });
> diff --git a/www/manager6/storage/NFSEdit.js b/www/manager6/storage/NFSEdit.js
> index faa41732..202c7de0 100644
> --- a/www/manager6/storage/NFSEdit.js
> +++ b/www/manager6/storage/NFSEdit.js
> @@ -143,7 +143,7 @@ Ext.define('PVE.storage.NFSInputPanel', {
>   	    },
>   	];
>   
> -	me.advancedColumn1 = [
> +	me.advancedColumn2 = [
>   	    {
>   		xtype: 'proxmoxKVComboBox',
>   		fieldLabel: gettext('NFS Version'),
> 





More information about the pve-devel mailing list