From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 2/6] ui: factor out input panel for editing prune settings
Date: Mon, 6 Sep 2021 13:32:27 +0200 [thread overview]
Message-ID: <20210906113231.61790-3-f.ebner@proxmox.com> (raw)
In-Reply-To: <20210906113231.61790-1-f.ebner@proxmox.com>
To be re-used for configuring job-specific retention options for
backups.
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
www/manager6/Makefile | 1 +
www/manager6/panel/EditPruneInputPanel.js | 97 +++++++++++++++++++++++
www/manager6/storage/Base.js | 96 +---------------------
3 files changed, 99 insertions(+), 95 deletions(-)
create mode 100644 www/manager6/panel/EditPruneInputPanel.js
diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 75d355a5..3f81d9c4 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -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
index 00000000..d58db208
--- /dev/null
+++ b/www/manager6/panel/EditPruneInputPanel.js
@@ -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."),
+ },
+ ],
+});
diff --git a/www/manager6/storage/Base.js b/www/manager6/storage/Base.js
index ee8b54e8..862c981b 100644
--- a/www/manager6/storage/Base.js
+++ b/www/manager6/storage/Base.js
@@ -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,
--
2.30.2
next prev parent reply other threads:[~2021-09-06 11:32 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-06 11:32 [pve-devel] [PATCH-SERIES manager] ui: some backup job improvements Fabian Ebner
2021-09-06 11:32 ` [pve-devel] [PATCH manager 1/6] ui: cluster backup: fix running backup with prune settings Fabian Ebner
2021-09-08 10:59 ` [pve-devel] applied: " Thomas Lamprecht
2021-09-06 11:32 ` Fabian Ebner [this message]
2021-09-08 11:01 ` [pve-devel] applied: [PATCH manager 2/6] ui: factor out input panel for editing " Thomas Lamprecht
2021-09-06 11:32 ` [pve-devel] [PATCH manager 3/6] ui: prune edit: prepare for being re-used for backup jobs Fabian Ebner
2021-09-08 11:01 ` [pve-devel] applied: " Thomas Lamprecht
2021-09-06 11:32 ` [pve-devel] [PATCH manager 4/6] fix #1803: ui: cluster backup: handle job-specific retention options Fabian Ebner
2021-09-08 11:01 ` [pve-devel] applied: " Thomas Lamprecht
2021-09-06 11:32 ` [pve-devel] [PATCH manager 5/6] ui: backup job detail: also show retention settings Fabian Ebner
2021-09-08 11:04 ` Thomas Lamprecht
2021-09-08 14:15 ` [pve-devel] applied: " Thomas Lamprecht
2021-09-06 11:32 ` [pve-devel] [PATCH manager 6/6] ui: cluster backup: use cluster-wide storage selector Fabian Ebner
2021-09-08 11:06 ` Thomas Lamprecht
2021-09-09 6:56 ` Fabian Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210906113231.61790-3-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.