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

Fabian Ebner f.ebner at proxmox.com
Tue Sep 14 11:55:04 CEST 2021


Am 06.09.21 um 15:15 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 ++++++++++++++++++
>   2 files changed, 24 insertions(+)
> 
> 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 ee8b54e8..457576a3 100644
> --- a/www/manager6/storage/Base.js
> +++ b/www/manager6/storage/Base.js
> @@ -51,6 +51,24 @@ Ext.define('PVE.panel.StorageBase', {
>   	    },
>   	);
>   
> +	const fileBasedStorageTypes = ['dir', 'btrfs', 'nfs', 'cifs', 'glusterfs'];

Nit: CephFS is also file-based. What about using qemuImgStorageTypes or 
if (['dir',...].includes(me.type)) directly?

> +
> +	if (fileBasedStorageTypes.includes(me.type)) {
> +	    const preallocSelector = {
> +		xtype: 'pvePreallocationSelector',
> +		name: 'preallocation',
> +		fieldLabel: gettext('Preallocation'),
> +		allowBlank: false,
> +		value: 'default',
> +	    };
> +
> +	    // ensures, that the PreallocationSelector is always on the left side
> +	    if (me.advancedColumn1) {
> +		me.advancedColumn2 = me.advancedColumn1;

Why does it need to be on the left side? What if there already is an 
advancedColumn2?

> +	    }
> +	    me.advancedColumn1 = [preallocSelector];
> +	}
> +
>   	me.callParent();
>       },
>   });
> 





More information about the pve-devel mailing list