* [pve-devel] [PATCH manager 1/2] ui: backup: disable remove button when backup is protected
@ 2021-11-12 11:28 Fabian Ebner
2021-11-12 11:28 ` [pve-devel] [PATCH manager 2/2] ui: backup: protect button: use dynamic protect/unprotect text Fabian Ebner
0 siblings, 1 reply; 3+ messages in thread
From: Fabian Ebner @ 2021-11-12 11:28 UTC (permalink / raw)
To: pve-devel
Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
www/manager6/grid/BackupView.js | 18 +++++++++++++++++-
www/manager6/storage/BackupView.js | 22 ++++++++++++++++++++++
2 files changed, 39 insertions(+), 1 deletion(-)
diff --git a/www/manager6/grid/BackupView.js b/www/manager6/grid/BackupView.js
index fdc385a8..c08fb67d 100644
--- a/www/manager6/grid/BackupView.js
+++ b/www/manager6/grid/BackupView.js
@@ -8,6 +8,12 @@ Ext.define('PVE.grid.BackupView', {
stateful: true,
stateId: 'grid-guest-backup',
+ updateButtonStatus: function(record) {
+ let me = this;
+
+ me.down('#removeButton').updateStatus(record);
+ },
+
initComponent: function() {
var me = this;
@@ -62,7 +68,10 @@ Ext.define('PVE.grid.BackupView', {
vmtypeFilter,
searchFilter,
vmidFilter,
- ],
+ ],
+ listeners: {
+ load: () => me.updateButtonStatus(me.selModel.getSelection()[0]),
+ },
});
let updateFilter = function() {
@@ -197,6 +206,10 @@ Ext.define('PVE.grid.BackupView', {
selModel: sm,
dangerous: true,
delay: 5,
+ itemId: 'removeButton',
+ updateStatus: function(record) {
+ this.setDisabled(!record || record.data.protected);
+ },
confirmMsg: function(rec) {
var msg = Ext.String.format(gettext('Are you sure you want to remove entry {0}'),
"'" + rec.data.volid + "'");
@@ -379,6 +392,9 @@ Ext.define('PVE.grid.BackupView', {
renderer: PVE.Utils.render_backup_verification,
},
],
+ listeners: {
+ selectionchange: (model, records) => me.updateButtonStatus(records[0]),
+ },
});
me.callParent();
diff --git a/www/manager6/storage/BackupView.js b/www/manager6/storage/BackupView.js
index dca140fe..42fd6623 100644
--- a/www/manager6/storage/BackupView.js
+++ b/www/manager6/storage/BackupView.js
@@ -5,6 +5,14 @@ Ext.define('PVE.storage.BackupView', {
showColumns: ['name', 'notes', 'protected', 'date', 'format', 'size'],
+ useCustomRemoveButton: true,
+
+ updateButtonStatus: function(record) {
+ let me = this;
+
+ me.down('#removeButton').updateStatus(record);
+ },
+
initComponent: function() {
var me = this;
@@ -189,6 +197,18 @@ Ext.define('PVE.storage.BackupView', {
},
'-',
pruneButton,
+ {
+ xtype: 'proxmoxStdRemoveButton',
+ itemId: 'removeButton',
+ selModel: sm,
+ delay: 5,
+ callback: () => reload(),
+ baseurl: `/api2/extjs/nodes/${nodename}/storage/${me.storage}/content`,
+ enableFn: (record) => !record.data.protected,
+ updateStatus: function(record) { // enableFn is not called after store load
+ this.setDisabled(!record || record.data.protected);
+ },
+ },
);
if (isPBS) {
@@ -207,5 +227,7 @@ Ext.define('PVE.storage.BackupView', {
}
me.callParent();
+
+ me.store.on('load', () => me.updateButtonStatus(me.selModel.getSelection()[0]));
},
});
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [pve-devel] [PATCH manager 2/2] ui: backup: protect button: use dynamic protect/unprotect text
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
2022-03-16 16:36 ` Thomas Lamprecht
0 siblings, 1 reply; 3+ messages in thread
From: Fabian Ebner @ 2021-11-12 11:28 UTC (permalink / raw)
To: pve-devel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [pve-devel] [PATCH manager 2/2] ui: backup: protect button: use dynamic protect/unprotect text
2021-11-12 11:28 ` [pve-devel] [PATCH manager 2/2] ui: backup: protect button: use dynamic protect/unprotect text Fabian Ebner
@ 2022-03-16 16:36 ` Thomas Lamprecht
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2022-03-16 16:36 UTC (permalink / raw)
To: Proxmox VE development discussion, Fabian Ebner
On 12.11.21 12:28, Fabian Ebner wrote:
> 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 });
with this we'd have that behavior three times (ct/vm resource/hw are the existing two),
so maybe we should move it out in a new separate, from proxmoxButton derived, component?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-03-16 16:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [pve-devel] [PATCH manager 2/2] ui: backup: protect button: use dynamic protect/unprotect text Fabian Ebner
2022-03-16 16:36 ` Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox