From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 2/2] ui: backup: protect button: use dynamic protect/unprotect text
Date: Fri, 12 Nov 2021 12:28:34 +0100 [thread overview]
Message-ID: <20211112112834.40892-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20211112112834.40892-1-f.ebner@proxmox.com>
Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
www/manager6/grid/BackupView.js | 22 +++++++++++++++++++++-
www/manager6/storage/BackupView.js | 24 +++++++++++++++++++++++-
2 files changed, 44 insertions(+), 2 deletions(-)
diff --git a/www/manager6/grid/BackupView.js b/www/manager6/grid/BackupView.js
index c08fb67d..cbdac02e 100644
--- a/www/manager6/grid/BackupView.js
+++ b/www/manager6/grid/BackupView.js
@@ -12,6 +12,7 @@ Ext.define('PVE.grid.BackupView', {
let me = this;
me.down('#removeButton').updateStatus(record);
+ me.down('#protectButton').updateStatus(record);
},
initComponent: function() {
@@ -314,8 +315,14 @@ Ext.define('PVE.grid.BackupView', {
},
{
xtype: 'proxmoxButton',
- text: gettext('Change Protection'),
+ text: gettext('Protect'),
+ defaultText: gettext('Protect'),
+ altText: gettext('Unprotect'),
disabled: true,
+ itemId: 'protectButton',
+ updateStatus: function(record) {
+ this.setText(record?.data.protected ? this.altText : this.defaultText);
+ },
handler: function(button, event, record) {
const volid = record.data.volid;
const storage = storagesel.getValue();
@@ -330,6 +337,19 @@ Ext.define('PVE.grid.BackupView', {
success: (response) => reload(),
});
},
+ listeners: {
+ render: function(btn) {
+ // HACK: calculate the max button width on first render to avoid
+ // toolbar glitches
+ let defSize = btn.getSize().width;
+
+ btn.setText(btn.altText);
+ let altSize = btn.getSize().width;
+
+ btn.setText(btn.defaultText);
+ btn.setSize({ width: altSize > defSize ? altSize : defSize });
+ },
+ },
},
'-',
delete_btn,
diff --git a/www/manager6/storage/BackupView.js b/www/manager6/storage/BackupView.js
index 42fd6623..606581cc 100644
--- a/www/manager6/storage/BackupView.js
+++ b/www/manager6/storage/BackupView.js
@@ -11,6 +11,7 @@ Ext.define('PVE.storage.BackupView', {
let me = this;
me.down('#removeButton').updateStatus(record);
+ me.down('#protectButton').updateStatus(record);
},
initComponent: function() {
@@ -181,8 +182,14 @@ Ext.define('PVE.storage.BackupView', {
},
{
xtype: 'proxmoxButton',
- text: gettext('Change Protection'),
+ text: gettext('Protect'),
+ defaultText: gettext('Protect'),
+ altText: gettext('Unprotect'),
disabled: true,
+ itemId: 'protectButton',
+ updateStatus: function(record) {
+ this.setText(record?.data.protected ? this.altText : this.defaultText);
+ },
handler: function(button, event, record) {
const volid = record.data.volid;
Proxmox.Utils.API2Request({
@@ -194,6 +201,19 @@ Ext.define('PVE.storage.BackupView', {
success: (response) => reload(),
});
},
+ listeners: {
+ render: function(btn) {
+ // HACK: calculate the max button width on first render to avoid
+ // toolbar glitches
+ let defSize = btn.getSize().width;
+
+ btn.setText(btn.altText);
+ let altSize = btn.getSize().width;
+
+ btn.setText(btn.defaultText);
+ btn.setSize({ width: altSize > defSize ? altSize : defSize });
+ },
+ },
},
'-',
pruneButton,
@@ -228,6 +248,8 @@ Ext.define('PVE.storage.BackupView', {
me.callParent();
+ me.on('selectionchange', (model, records) => me.updateButtonStatus(records[0]));
+
me.store.on('load', () => me.updateButtonStatus(me.selModel.getSelection()[0]));
},
});
--
2.30.2
next prev parent reply other threads:[~2021-11-12 11:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-12 11:28 [pve-devel] [PATCH manager 1/2] ui: backup: disable remove button when backup is protected Fabian Ebner
2021-11-12 11:28 ` Fabian Ebner [this message]
2022-03-16 16:36 ` [pve-devel] [PATCH manager 2/2] ui: backup: protect button: use dynamic protect/unprotect text Thomas Lamprecht
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=20211112112834.40892-2-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox