ui: storage edit: retention: add max-protected-backups setting

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
Fabian Ebner 2022-03-29 14:53:16 +02:00 committed by Fabian Grünbichler
parent 725c0555d2
commit 4981660f2a
2 changed files with 39 additions and 9 deletions

View File

@ -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: 'unlimited with Datastore.Allocate privilege, 5 otherwise',
deleteEmpty: true,
autoEl: {
tag: 'div',
'data-qtip': Ext.String.format(gettext('Use {0} for unlimited'), -1),
},
},
],
});

View File

@ -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,