[pve-devel] [RFC manager 4/6] ui: storage creation: retention: dynamically adapt max-protected-backups

Fabian Ebner f.ebner at proxmox.com
Thu Dec 16 13:12:28 CET 2021


depending on the other retention settings and as long as it isn't
dirty (other than from the updating itself). Allow an unlimited number
when keep-all=1 and use the default fall-back to 5 when pruning or
fall-back for retention is configured.

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---

Might be too much automagic, maybe just setting -1 in afterrender and
the never-rendered scenario is also enough? That is, if we even want
the GUI default for creation to be unlimited. Just thought that it
would better fit the keep-all default.

 www/manager6/panel/BackupJobPrune.js | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/www/manager6/panel/BackupJobPrune.js b/www/manager6/panel/BackupJobPrune.js
index 555bccf2..880f0234 100644
--- a/www/manager6/panel/BackupJobPrune.js
+++ b/www/manager6/panel/BackupJobPrune.js
@@ -13,7 +13,14 @@ Ext.define('PVE.panel.BackupJobPrune', {
 	if (this.needMask) { // isMasked() may not yet be true if not rendered once
 	    return {};
 	} else if (this.isCreate && !this.rendered) {
-	    return this.keepAllDefaultForCreate ? { 'prune-backups': 'keep-all=1' } : {};
+	    let options = {};
+	    if (this.keepAllDefaultForCreate) {
+		options['prune-backups'] = 'keep-all=1';
+		if (this.hasMaxProtected) {
+		    options['max-protected-backups'] = -1;
+		}
+	    }
+	    return options;
 	}
 
 	let options = { 'delete': [] };
@@ -54,6 +61,17 @@ Ext.define('PVE.panel.BackupJobPrune', {
 	    field.setDisabled(keepAll);
 	});
 	me.down('component[name=no-keeps-hint]').setHidden(anyValue || keepAll);
+
+	let maxProtected = me.down('proxmoxintegerfield[name=max-protected-backups]');
+	if (me.isCreate && me.hasMaxProtected && !maxProtected.isDirty()) {
+	    if (keepAll) {
+		maxProtected.setValue(-1);
+		maxProtected.resetOriginalValue();
+	    } else {
+		maxProtected.setValue('');
+		maxProtected.resetOriginalValue();
+	    }
+	}
     },
 
     listeners: {
@@ -71,6 +89,10 @@ Ext.define('PVE.panel.BackupJobPrune', {
 	    let maxProtected = panel.down('proxmoxintegerfield[name=max-protected-backups]');
 	    maxProtected.setDisabled(!panel.hasMaxProtected);
 	    maxProtected.setHidden(!panel.hasMaxProtected);
+	    if (panel.isCreate && panel.hasMaxProtected) {
+		maxProtected.setValue(-1);
+		maxProtected.resetOriginalValue();
+	    }
 
 	    panel.query('pmxPruneKeepField').forEach(field => {
 		field.on('change', panel.updateComponents, panel);
-- 
2.30.2






More information about the pve-devel mailing list