5
0
mirror of git://git.proxmox.com/git/proxmox-backup.git synced 2025-03-19 18:50:17 +03:00
proxmox-backup/www/panel/PrunePanel.js
Dominik Csapak 169ddf541d ui: prune: fix sending invalid parameters
the prune input panel is used in various contexts (add/editing a
prunejob, adding a datastore, executing a prune). These different api
calls don't all take the same parameters, so we have to correctly set
the `isCreate` to not send a `delete` paramter for those request if
there was an empty field.

Also set 'max-depth:0' only when recursive was not set *and* we can
set 'recursive', because for creating a datastore that is not supported
by the api, and for the prune job editing we override the whole
onGetValues anyway so that's not an issue there.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
2024-03-07 10:30:40 +01:00

130 lines
2.4 KiB
JavaScript

Ext.define('PBS.panel.PruneInputPanel', {
extend: 'Proxmox.panel.InputPanel',
xtype: 'pbsPruneInputPanel',
mixins: ['Proxmox.Mixin.CBind'],
onlineHelp: 'maintenance_pruning',
// show/hide dry-run field FIXME: rename to canDryrun, this is confusing..
dryrun: false,
canRecurse: false, // show a recursive/max-depth field
cbindData: function() {
let me = this;
me.isCreate = !!me.isCreate;
return {
ns: me.ns ?? '',
};
},
viewModel: {
data: { canRecurse: false },
},
onGetValues: function(values) {
let me = this;
if (me.ns && me.ns !== '') {
values.ns = me.ns;
}
if (!values.recursive && me.canRecurse) {
values['max-depth'] = 0;
}
delete values.recursive;
return values;
},
column1: [
{
xtype: 'pbsPruneKeepInput',
name: 'keep-last',
fieldLabel: gettext('Keep Last'),
cbind: {
deleteEmpty: '{!isCreate}',
},
},
{
xtype: 'pbsPruneKeepInput',
name: 'keep-daily',
fieldLabel: gettext('Keep Daily'),
cbind: {
deleteEmpty: '{!isCreate}',
},
},
{
xtype: 'pbsPruneKeepInput',
name: 'keep-monthly',
fieldLabel: gettext('Keep Monthly'),
cbind: {
deleteEmpty: '{!isCreate}',
},
},
{
xtype: 'proxmoxcheckbox',
name: 'dry-run',
fieldLabel: gettext('Dry Run'),
cbind: {
hidden: '{!dryrun}',
disabled: '{!dryrun}',
},
},
],
column2: [
{
xtype: 'pbsPruneKeepInput',
fieldLabel: gettext('Keep Hourly'),
name: 'keep-hourly',
cbind: {
deleteEmpty: '{!isCreate}',
},
},
{
xtype: 'pbsPruneKeepInput',
name: 'keep-weekly',
fieldLabel: gettext('Keep Weekly'),
cbind: {
deleteEmpty: '{!isCreate}',
},
},
{
xtype: 'pbsPruneKeepInput',
name: 'keep-yearly',
fieldLabel: gettext('Keep Yearly'),
cbind: {
deleteEmpty: '{!isCreate}',
},
},
{
xtype: 'fieldcontainer',
layout: 'hbox',
fieldLabel: gettext('Recursive'),
cbind: {
hidden: '{!canRecurse}',
disabled: '{!canRecurse}',
},
items: [
{
xtype: 'proxmoxcheckbox',
name: 'recursive',
uncheckedValue: false,
value: true,
bind: {
value: '{canRecurse}',
},
},
{
xtype: 'pbsNamespaceMaxDepth',
name: 'max-depth',
padding: '0 0 0 5',
labelWidth: 75,
deleteEmpty: false,
bind: {
disabled: '{!canRecurse}',
},
flex: 1,
},
],
},
],
});