[pve-devel] [PATCH manager] fix #4873: use last used backup storage for the storage selector

Fiona Ebner f.ebner at proxmox.com
Fri Jan 26 14:27:43 CET 2024


Am 20.11.23 um 15:18 schrieb Dominik Csapak:
> for this, we invent the 'storageStateId' parameter that is undeifned by
> default, but if set, the storage selector saves it's value on every
> change there and on initial load (when no value is set from outside)
> loads it from there and uses that as its value.
> 
> for now only use it for the selection of backup storages namely in:
> * backup grid
> * "backup now" edit window
> * backup job edit window
> 
> in the future we could use that to have a 'last used disk image' or
> 'last used iso' storage too if this approach fits
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>

Tested-by: Fiona Ebner <f.ebner at proxmox.com>
Reviewed-by: Fiona Ebner <f.ebner at proxmox.com>

> ---
> 
> the backup job edit is a bit weird and probably warrants a bit of
> discussion, since the interaction when editing an existing job is imho
> unexpected:
> 
>  1. select backup storage X in backup grid
>  2. edit a backup job where storage Y is selected (that happens
>     correctly) but don't touch the storage field
>  3. now storage Y is the last used and selected on the grids
> 

Agreed, but it's still more convenient with the patch than without.

Could we maybe only enable the state update from the second change event
onward? AFAIU, there will always be one change event to set the initial
value and for that we could simply not update the state.

> diff --git a/www/manager6/form/StorageSelector.js b/www/manager6/form/StorageSelector.js
> index 872bc1ab..0a43712f 100644
> --- a/www/manager6/form/StorageSelector.js
> +++ b/www/manager6/form/StorageSelector.js
> @@ -147,6 +147,15 @@ Ext.define('PVE.form.StorageSelector', {
>  	me.reloadStorageList();
>      },
>  
> +    listeners: {
> +	change: function(selector, storage) {
> +	    if (selector.storageStateId){

eslint complains here because of missing space

> +		let sp = Ext.state.Manager.getProvider();
> +		sp.set(selector.storageStateId, storage);

Is this state fully global? If yes, is limiting it to instances of the
'PVE.form.StorageSelector' xtype possible/feasible?

> +	    }
> +	},
> +    },
> +
>      initComponent: function() {
>  	var me = this;
>  




More information about the pve-devel mailing list