public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH manager v2] storage: base edit: Use the GUI keep-all default value
@ 2020-11-25 13:42 Dominic Jäger
  2020-11-25 13:51 ` Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Dominic Jäger @ 2020-11-25 13:42 UTC (permalink / raw)
  To: pve-devel

... if the user hasn't seen the prune panel yet.
The GUI has as default value a ticked keep-all checkbox => keep-all=1.
Previously we sent nothing in this case which led to the no-keeps default of
keep-last=1.

Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
---
v2: Move the keep-all=1 default up

@Thomas: Or did you mean to keep only that part that I now moved up? I can try to find a nicer way
tomorrow.

 www/manager6/storage/Base.js | 26 +++++++++++++++++---------
 1 file changed, 17 insertions(+), 9 deletions(-)

diff --git a/www/manager6/storage/Base.js b/www/manager6/storage/Base.js
index 70e18a81..e8a76fe0 100644
--- a/www/manager6/storage/Base.js
+++ b/www/manager6/storage/Base.js
@@ -65,23 +65,31 @@ Ext.define('PVE.panel.StoragePruneInputPanel', {
     keepLastEmptyText: gettext('1'),
 
     onGetValues: function(formValues) {
+	let checkbox = this.down('proxmoxcheckbox[name=keep-all]');
 	if (this.needMask) { // isMasked() may not yet be true if not rendered once
 	    return {};
+	} else if (this.isCreate && !checkbox.rendered) {
+	    // User has not seen the checkbox yet => Use default
+	    // keep-all has no value yet => Hardcoded
+	    return { 'prune-backups': 'keep-all=1' };
 	}
 	delete formValues.delete;
-	let retention = PVE.Parser.printPropertyString(formValues)
+	let retention = PVE.Parser.printPropertyString(formValues);
+	let options = { };
 	if (retention === '') {
-	    if (this.isCreate) {
-		return {};
+	    if (!this.isCreate) {
+		options.delete = 'prune-backups';
 	    }
-	    // always delete old 'maxfiles' on edit, we map it to keep-last on window load
-	    return {
-		delete: ['prune-backups','maxfiles'],
-	    };
+	} else {
+	    options['prune-backups'] = retention;
 	}
-	let options = { 'prune-backups': retention };
+	// always delete old 'maxfiles' on edit, we map it to keep-last on window load
 	if (!this.isCreate) {
-	    options.delete = 'maxfiles';
+	    if (options.delete) {
+		options.delete = [options.delete].concat('maxfiles');
+	    } else {
+		options.delete = 'maxfiles';
+	    }
 	}
 	return options;
     },
-- 
2.20.1




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [pve-devel] [PATCH manager v2] storage: base edit: Use the GUI keep-all default value
  2020-11-25 13:42 [pve-devel] [PATCH manager v2] storage: base edit: Use the GUI keep-all default value Dominic Jäger
@ 2020-11-25 13:51 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2020-11-25 13:51 UTC (permalink / raw)
  To: Proxmox VE development discussion, Dominic Jäger

On 25.11.20 14:42, Dominic Jäger wrote:
> ... if the user hasn't seen the prune panel yet.
> The GUI has as default value a ticked keep-all checkbox => keep-all=1.
> Previously we sent nothing in this case which led to the no-keeps default of
> keep-last=1.
> 
> Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
> ---
> v2: Move the keep-all=1 default up
> 
> @Thomas: Or did you mean to keep only that part that I now moved up? I can try to find a nicer way
> tomorrow.
> 

missed that patch, sorry, I applied another variant - it's shorter, but
I hope it caught also all edge cases now.

https://git.proxmox.com/?p=pve-manager.git;a=commitdiff;h=85fa613431167358e5441f10c4247aa24e14421a

>  www/manager6/storage/Base.js | 26 +++++++++++++++++---------
>  1 file changed, 17 insertions(+), 9 deletions(-)
> 
> diff --git a/www/manager6/storage/Base.js b/www/manager6/storage/Base.js
> index 70e18a81..e8a76fe0 100644
> --- a/www/manager6/storage/Base.js
> +++ b/www/manager6/storage/Base.js
> @@ -65,23 +65,31 @@ Ext.define('PVE.panel.StoragePruneInputPanel', {
>      keepLastEmptyText: gettext('1'),
>  
>      onGetValues: function(formValues) {
> +	let checkbox = this.down('proxmoxcheckbox[name=keep-all]');
>  	if (this.needMask) { // isMasked() may not yet be true if not rendered once
>  	    return {};
> +	} else if (this.isCreate && !checkbox.rendered) {
> +	    // User has not seen the checkbox yet => Use default
> +	    // keep-all has no value yet => Hardcoded
> +	    return { 'prune-backups': 'keep-all=1' };
>  	}
>  	delete formValues.delete;
> -	let retention = PVE.Parser.printPropertyString(formValues)
> +	let retention = PVE.Parser.printPropertyString(formValues);
> +	let options = { };
>  	if (retention === '') {
> -	    if (this.isCreate) {
> -		return {};
> +	    if (!this.isCreate) {
> +		options.delete = 'prune-backups';
>  	    }
> -	    // always delete old 'maxfiles' on edit, we map it to keep-last on window load
> -	    return {
> -		delete: ['prune-backups','maxfiles'],
> -	    };
> +	} else {
> +	    options['prune-backups'] = retention;
>  	}
> -	let options = { 'prune-backups': retention };
> +	// always delete old 'maxfiles' on edit, we map it to keep-last on window load
>  	if (!this.isCreate) {
> -	    options.delete = 'maxfiles';
> +	    if (options.delete) {
> +		options.delete = [options.delete].concat('maxfiles');
> +	    } else {
> +		options.delete = 'maxfiles';
> +	    }
>  	}
>  	return options;
>      },
> 






^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-25 13:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-25 13:42 [pve-devel] [PATCH manager v2] storage: base edit: Use the GUI keep-all default value Dominic Jäger
2020-11-25 13:51 ` Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal