[pve-devel] [PATCH manager v2 3/4] ui: form: add hideFormatWhenStorageEmpty option to DiskStorageSelector
Fiona Ebner
f.ebner at proxmox.com
Wed Mar 5 13:49:57 CET 2025
"form:" by itself doesn't provide much information as a prefix
Am 12.02.25 um 14:02 schrieb Markus Frank:
> Prerequisite for "ui: window: add diskformat option to restore window"
>
> The hide condition is copied from the format selector item in the same
> file.
>
> Signed-off-by: Markus Frank <m.frank at proxmox.com>
> ---
> www/manager6/form/DiskStorageSelector.js | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/www/manager6/form/DiskStorageSelector.js b/www/manager6/form/DiskStorageSelector.js
> index 0ef48f51..e2064934 100644
> --- a/www/manager6/form/DiskStorageSelector.js
> +++ b/www/manager6/form/DiskStorageSelector.js
> @@ -30,6 +30,7 @@ Ext.define('PVE.form.DiskStorageSelector', {
>
> // hides the format field (e.g. for TPM state)
> hideFormat: false,
> + hideFormatWhenStorageEmpty: false,
>
> // sets the initial size value
> // string because else we get a type confusion
> @@ -41,12 +42,20 @@ Ext.define('PVE.form.DiskStorageSelector', {
> var hdfilesel = me.getComponent('hdimage');
> var hdsizesel = me.getComponent('disksize');
>
> + // This is needed to make the format selector visible
> + // after it has been hidden because of hideFormatWhenStorageEmpty.
> + let hideFormatCondition = me.hideFormat || me.storageContent === 'rootdir';
> + formatsel.setVisible(!hideFormatCondition);
Nit: could be moved further down in the code for better grouping things
to here:
> formatsel.setDisabled(me.hideFormat || Ext.Object.getSize(validFormats) <= 1);
> formatsel.setValue(selectFormat);
or is there a reason that wouldn't work?
Looking at the next patch, it seems like you manually hide it at first
from the use-site. Maybe we should do it in initComponent() instead?
I.e. also hide if me.hideFormatWhenStorageEmpty && !me.autoSelect.
Going for a view model and bindings might be best to modernize the
component a bit and make such things easier, but not a blocker from my side.
More information about the pve-devel
mailing list