]> git.proxmox.com Git - pve-manager.git/commitdiff
ui: factor out input panel for editing prune settings
authorFabian Ebner <f.ebner@proxmox.com>
Mon, 6 Sep 2021 11:32:27 +0000 (13:32 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 7 Sep 2021 09:13:18 +0000 (11:13 +0200)
To be re-used for configuring job-specific retention options for
backups.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
www/manager6/Makefile
www/manager6/panel/EditPruneInputPanel.js [new file with mode: 0644]
www/manager6/storage/Base.js

index 75d355a598c702ef00c5bca857302d50caae4f7b..3f81d9c4519546d27c398139809e9f7de71a92e1 100644 (file)
@@ -79,6 +79,7 @@ JSSRC=                                                        \
        grid/Replication.js                             \
        grid/ResourceGrid.js                            \
        panel/ConfigPanel.js                            \
+       panel/EditPruneInputPanel.js                    \
        panel/HealthWidget.js                           \
        panel/IPSet.js                                  \
        panel/NotesView.js                              \
diff --git a/www/manager6/panel/EditPruneInputPanel.js b/www/manager6/panel/EditPruneInputPanel.js
new file mode 100644 (file)
index 0000000..d58db20
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Input panel for prune settings with a keep-all option intended to be used as
+ * part of an edit/create window.
+ */
+Ext.define('PVE.panel.EditPruneInputPanel', {
+    extend: 'Proxmox.panel.PruneInputPanel',
+    xtype: 'pveEditPruneInputPanel',
+    mixins: ['Proxmox.Mixin.CBind'],
+
+    onlineHelp: 'vzdump_retention',
+
+    onGetValues: function(formValues) {
+       if (this.needMask) { // isMasked() may not yet be true if not rendered once
+           return {};
+       } else if (this.isCreate && !this.rendered) {
+           return { 'prune-backups': 'keep-all=1' };
+       }
+       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'],
+           };
+       }
+       let options = { 'prune-backups': retention };
+       if (!this.isCreate) {
+           options.delete = 'maxfiles';
+       }
+       return options;
+    },
+
+    updateComponents: function() {
+       let me = this;
+
+       let keepAll = me.down('proxmoxcheckbox[name=keep-all]').getValue();
+       let anyValue = false;
+       me.query('pmxPruneKeepField').forEach(field => {
+           anyValue = anyValue || field.getValue() !== null;
+           field.setDisabled(keepAll);
+       });
+       me.down('component[name=no-keeps-hint]').setHidden(anyValue || keepAll);
+    },
+
+    listeners: {
+       afterrender: function(panel) {
+           if (panel.needMask) {
+               panel.down('component[name=no-keeps-hint]').setHtml('');
+               panel.mask(
+                   gettext('Backup content type not available for this storage.'),
+               );
+           } else if (panel.isCreate) {
+               panel.down('proxmoxcheckbox[name=keep-all]').setValue(true);
+           }
+           panel.down('component[name=pbs-hint]').setHidden(!panel.isPBS);
+
+           panel.query('pmxPruneKeepField').forEach(field => {
+               field.on('change', panel.updateComponents, panel);
+           });
+           panel.updateComponents();
+       },
+    },
+
+    columnT: {
+       xtype: 'proxmoxcheckbox',
+       name: 'keep-all',
+       boxLabel: gettext('Keep all backups'),
+       listeners: {
+           change: function(field, newValue) {
+               let panel = field.up('pveEditPruneInputPanel');
+               panel.updateComponents();
+           },
+       },
+    },
+
+    columnB: [
+       {
+           xtype: 'component',
+           userCls: 'pmx-hint',
+           name: 'no-keeps-hint',
+           hidden: true,
+           padding: '5 1',
+           html: gettext('Without any keep option, the node\'s vzdump.conf or `keep-all` is used as fallback for backup jobs'),
+       },
+       {
+           xtype: 'component',
+           userCls: 'pmx-hint',
+           name: 'pbs-hint',
+           hidden: true,
+           padding: '5 1',
+           html: gettext("It's preferred to configure backup retention directly on the Proxmox Backup Server."),
+       },
+    ],
+});
index ee8b54e8909afdbef8e739c5f37906b51370fe8f..862c981b5060a964d2f33d912f6bf1302a037e99 100644 (file)
@@ -55,100 +55,6 @@ Ext.define('PVE.panel.StorageBase', {
     },
 });
 
-Ext.define('PVE.panel.StoragePruneInputPanel', {
-    extend: 'Proxmox.panel.PruneInputPanel',
-    xtype: 'pveStoragePruneInputPanel',
-    mixins: ['Proxmox.Mixin.CBind'],
-
-    onlineHelp: 'vzdump_retention',
-
-    onGetValues: function(formValues) {
-       if (this.needMask) { // isMasked() may not yet be true if not rendered once
-           return {};
-       } else if (this.isCreate && !this.rendered) {
-           return { 'prune-backups': 'keep-all=1' };
-       }
-       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'],
-           };
-       }
-       let options = { 'prune-backups': retention };
-       if (!this.isCreate) {
-           options.delete = 'maxfiles';
-       }
-       return options;
-    },
-
-    updateComponents: function() {
-       let me = this;
-
-       let keepAll = me.down('proxmoxcheckbox[name=keep-all]').getValue();
-       let anyValue = false;
-       me.query('pmxPruneKeepField').forEach(field => {
-           anyValue = anyValue || field.getValue() !== null;
-           field.setDisabled(keepAll);
-       });
-       me.down('component[name=no-keeps-hint]').setHidden(anyValue || keepAll);
-    },
-
-    listeners: {
-       afterrender: function(panel) {
-           if (panel.needMask) {
-               panel.down('component[name=no-keeps-hint]').setHtml('');
-               panel.mask(
-                   gettext('Backup content type not available for this storage.'),
-               );
-           } else if (panel.isCreate) {
-               panel.down('proxmoxcheckbox[name=keep-all]').setValue(true);
-           }
-           panel.down('component[name=pbs-hint]').setHidden(!panel.isPBS);
-
-           panel.query('pmxPruneKeepField').forEach(field => {
-               field.on('change', panel.updateComponents, panel);
-           });
-           panel.updateComponents();
-       },
-    },
-
-    columnT: {
-       xtype: 'proxmoxcheckbox',
-       name: 'keep-all',
-       boxLabel: gettext('Keep all backups'),
-       listeners: {
-           change: function(field, newValue) {
-               let panel = field.up('pveStoragePruneInputPanel');
-               panel.updateComponents();
-           },
-       },
-    },
-
-    columnB: [
-       {
-           xtype: 'component',
-           userCls: 'pmx-hint',
-           name: 'no-keeps-hint',
-           hidden: true,
-           padding: '5 1',
-           html: gettext('Without any keep option, the node\'s vzdump.conf or `keep-all` is used as fallback for backup jobs'),
-       },
-       {
-           xtype: 'component',
-           userCls: 'pmx-hint',
-           name: 'pbs-hint',
-           hidden: true,
-           padding: '5 1',
-           html: gettext("It's preferred to configure backup retention directly on the Proxmox Backup Server."),
-       },
-    ],
-});
-
 Ext.define('PVE.storage.BaseEdit', {
     extend: 'Proxmox.window.Edit',
 
@@ -191,7 +97,7 @@ Ext.define('PVE.storage.BaseEdit', {
                items: [
                    me.ipanel,
                    {
-                       xtype: 'pveStoragePruneInputPanel',
+                       xtype: 'pveEditPruneInputPanel',
                        title: gettext('Backup Retention'),
                        isCreate: me.isCreate,
                        isPBS: me.ipanel.isPBS,