[pve-devel] [RFC manager 3/6] ui: storage edit: retention: add max-protected-backups setting

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


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

Not sure if it's worth exposing this in the UI at all.

 www/manager6/panel/BackupJobPrune.js | 47 ++++++++++++++++++++++------
 www/manager6/storage/Base.js         |  1 +
 2 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/www/manager6/panel/BackupJobPrune.js b/www/manager6/panel/BackupJobPrune.js
index a58fe1fe..555bccf2 100644
--- a/www/manager6/panel/BackupJobPrune.js
+++ b/www/manager6/panel/BackupJobPrune.js
@@ -15,21 +15,32 @@ Ext.define('PVE.panel.BackupJobPrune', {
 	} else if (this.isCreate && !this.rendered) {
 	    return this.keepAllDefaultForCreate ? { 'prune-backups': 'keep-all=1' } : {};
 	}
+
+	let options = { 'delete': [] };
+
+	if ('max-protected-backups' in formValues) {
+	    options['max-protected-backups'] = formValues['max-protected-backups'];
+	} else if (this.hasMaxProtected) {
+	    options.delete.push('max-protected-backups');
+	}
+
+	delete formValues['max-protected-backups'];
 	delete formValues.delete;
+
 	let retention = PVE.Parser.printPropertyString(formValues);
 	if (retention === '') {
-	    if (this.isCreate) {
-		return {};
-	    }
-	    // always delete old 'maxfiles' on edit, we map it to keep-last on window load
-	    return {
-		'delete': ['prune-backups', 'maxfiles'],
-	    };
+	    options.delete.push('prune-backups');
+	} else {
+	    options['prune-backups'] = retention;
 	}
-	let options = { 'prune-backups': retention };
+
 	if (!this.isCreate) {
-	    options.delete = 'maxfiles';
+	    // always delete old 'maxfiles' on edit, we map it to keep-last on window load
+	    options.delete.push('maxfiles');
+	} else {
+	    delete options.delete;
 	}
+
 	return options;
     },
 
@@ -57,6 +68,10 @@ Ext.define('PVE.panel.BackupJobPrune', {
 	    }
 	    panel.down('component[name=pbs-hint]').setHidden(!panel.showPBSHint);
 
+	    let maxProtected = panel.down('proxmoxintegerfield[name=max-protected-backups]');
+	    maxProtected.setDisabled(!panel.hasMaxProtected);
+	    maxProtected.setHidden(!panel.hasMaxProtected);
+
 	    panel.query('pmxPruneKeepField').forEach(field => {
 		field.on('change', panel.updateComponents, panel);
 	    });
@@ -95,5 +110,19 @@ Ext.define('PVE.panel.BackupJobPrune', {
 	    padding: '5 1',
 	    html: gettext("It's preferred to configure backup retention directly on the Proxmox Backup Server."),
 	},
+	{
+	    xtype: 'proxmoxintegerfield',
+	    name: 'max-protected-backups',
+	    fieldLabel: gettext('Maximum Protected'),
+	    minValue: -1,
+	    hidden: true,
+	    disabled: true,
+	    emptyText: '5',
+	    deleteEmpty: true,
+	    autoEl: {
+		tag: 'div',
+		'data-qtip': Ext.String.format(gettext('Use {0} for unlimited'), -1),
+	    },
+	},
     ],
 });
diff --git a/www/manager6/storage/Base.js b/www/manager6/storage/Base.js
index 89dc2eff..7f6d7a09 100644
--- a/www/manager6/storage/Base.js
+++ b/www/manager6/storage/Base.js
@@ -120,6 +120,7 @@ Ext.define('PVE.storage.BaseEdit', {
 		    {
 			xtype: 'pveBackupJobPrunePanel',
 			title: gettext('Backup Retention'),
+			hasMaxProtected: true,
 			isCreate: me.isCreate,
 			keepAllDefaultForCreate: true,
 			showPBSHint: me.ipanel.isPBS,
-- 
2.30.2






More information about the pve-devel mailing list