all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: "Shannon Sterz" <s.sterz@proxmox.com>
To: "Shannon Sterz" <s.sterz@proxmox.com>,
	"Proxmox VE development discussion" <pve-devel@lists.proxmox.com>
Cc: pve-devel <pve-devel-bounces@lists.proxmox.com>
Subject: Re: [pve-devel] [PATCH pve-manager v3 1/1] ui: fix #6209: create snapshots and backups from context menu
Date: Tue, 07 Oct 2025 11:13:58 +0200	[thread overview]
Message-ID: <DDBZ47U3O0OI.2VGCC5FPIKDY8@proxmox.com> (raw)
In-Reply-To: <DDBYG2IHI5C4.BJEYOLV9ABF@proxmox.com>

On Tue Oct 7, 2025 at 10:42 AM CEST, Shannon Sterz wrote:
> some small comments in-line
>
> On Mon Oct 6, 2025 at 3:33 PM CEST, Nicolas Frey wrote:
>> Adds snapshot and manual backup shortcut to VM/CT right-click context
>> menu.
>>
>> On the previous iteration (v2), the snapshot feature availablity was
>> checked on menu load. It is now called only when the snapshot button
>> is clicked, preventing delays in loading the context menu. Testing
>> with simulated latency (with setTimeout) showed better UX by
>> displaying an error on click rather than preloading the check.
>>
>> Previously, users couldn't distinguish between a slow API and the
>> feature being disabled. The explicit check provides clear feedback.
>> The 'disabled' property remains bound to VM.Snapshot to disable
>> the option when snapshots aren't allowed anyway.
>>
>> Fixes: https://bugzilla.proxmox.com/show_bug.cgi?id=6209
>> Signed-off-by: Nicolas Frey <n.frey@proxmox.com>
>> ---
>>  www/manager6/lxc/CmdMenu.js  | 46 ++++++++++++++++++++++++++++++++++++
>>  www/manager6/qemu/CmdMenu.js | 46 ++++++++++++++++++++++++++++++++++++
>>  2 files changed, 92 insertions(+)
>>
>> diff --git a/www/manager6/lxc/CmdMenu.js b/www/manager6/lxc/CmdMenu.js
>> index cd60c967..f0e8f700 100644
>> --- a/www/manager6/lxc/CmdMenu.js
>> +++ b/www/manager6/lxc/CmdMenu.js
>> @@ -134,6 +134,52 @@ Ext.define('PVE.lxc.CmdMenu', {
>>                  },
>>              },
>>              { xtype: 'menuseparator' },
>> +            {
>> +                text: gettext('Take Snapshot'),
>> +                iconCls: 'fa fa-fw fa-history',
>> +                disabled: !caps.vms['VM.Snapshot'],
>> +                handler: function () {
>> +                    Proxmox.Utils.API2Request({
>> +                        url: `/nodes/${info.node}/${info.type}/${info.vmid}/feature`,
>> +                        params: { feature: 'snapshot' },
>> +                        method: 'GET',
>> +                        success: function (response) {
>
> nit: you are mixing arrow style functions with anonymous functions here,
> imo this should also just be:
>
> (response) => {
>     [..]
> }
>
>> +                            if (!response.result.data.hasFeature) {
>> +                                Ext.Msg.alert(gettext('Error'), 'Cannot take snapshot: Feature not enabled.')
>
> nit: did you run `make tidy`? for me it cleans the line above up to:
>
>                                 Ext.Msg.alert(
>                                     gettext('Error'),
>                                     'Cannot take snapshot: Feature not enabled.',
>                                 );
>
>> +                                return;
>> +                            }
>> +                            Ext.create('PVE.window.Snapshot', {
>> +                                nodename: info.node,
>> +                                vmid: info.vmid,
>> +                                vmname: info.name,
>> +                                viewonly: false,
>> +                                type: info.type,
>> +                                isCreate: true,
>> +                                submitText: gettext('Take Snapshot'),
>> +                                autoShow: true,
>> +                                running: running,
>> +                            });
>> +                        },
>> +                        failure: (response, opts) =>
>> +                            Ext.Msg.alert(gettext('Error'), response.htmlStatus),
>> +                    });
>> +                },
>> +            },
>> +            {
>> +                text: gettext('Backup now'),
>> +                iconCls: 'fa fa-fw fa-floppy-o',
>> +                disabled: !caps.vms['VM.Backup'],
>> +                handler: function () {
>
> see comment about arrow function above
>
>> +                    Ext.create('PVE.window.Backup', {
>> +                        nodename: info.node,
>> +                        vmid: info.vmid,
>> +                        vmtype: info.type,
>> +                        vmname: info.name,
>> +                        autoShow: true,
>> +                    });
>> +                },
>> +            },
>> +            { xtype: 'menuseparator' },
>>              {
>>                  text: gettext('Console'),
>>                  iconCls: 'fa fa-fw fa-terminal',
>> diff --git a/www/manager6/qemu/CmdMenu.js b/www/manager6/qemu/CmdMenu.js
>> index adf64672..3e51be8f 100644
>> --- a/www/manager6/qemu/CmdMenu.js
>> +++ b/www/manager6/qemu/CmdMenu.js
>> @@ -169,6 +169,52 @@ Ext.define('PVE.qemu.CmdMenu', {
>>                  },
>>              },
>>              { xtype: 'menuseparator' },
>> +            {
>> +                text: gettext('Take Snapshot'),
>> +                iconCls: 'fa fa-fw fa-history',
>> +                disabled: !caps.vms['VM.Snapshot'],
>> +                handler: function () {
>> +                    Proxmox.Utils.API2Request({
>> +                        url: `/nodes/${info.node}/${info.type}/${info.vmid}/feature`,
>> +                        params: { feature: 'snapshot' },
>> +                        method: 'GET',
>> +                        success: function (response) {
>
> see comment about arrow function above
>
>> +                            if (!response.result.data.hasFeature) {
>> +                                Ext.Msg.alert(gettext('Error'), 'Cannot take snapshot: Feature not enabled.')
>
> see comment about `make tidy` above
>
>> +                                return;
>> +                            }
>> +                            Ext.create('PVE.window.Snapshot', {
>> +                                nodename: info.node,
>> +                                vmid: info.vmid,
>> +                                vmname: info.name,
>> +                                viewonly: false,
>> +                                type: info.type,
>> +                                isCreate: true,
>> +                                submitText: gettext('Take Snapshot'),
>> +                                autoShow: true,
>> +                                running: running,
>> +                            });
>> +                        },
>> +                        failure: (response, opts) =>
>> +                            Ext.Msg.alert(gettext('Error'), response.htmlStatus),
>> +                    });
>> +                },
>> +            },
>> +            {
>> +                text: gettext('Backup now'),
>> +                iconCls: 'fa fa-fw fa-floppy-o',
>> +                disabled: !caps.vms['VM.Backup'],
>> +                handler: function () {
>
> see comment about arrow function above
>
>> +                    Ext.create('PVE.window.Backup', {
>> +                        nodename: info.node,
>> +                        vmid: info.vmid,
>> +                        vmtype: info.type,
>> +                        vmname: info.name,
>> +                        autoShow: true,
>> +                    });
>> +                },
>> +            },
>> +            { xtype: 'menuseparator' },
>>              {
>>                  text: gettext('Console'),
>>                  iconCls: 'fa fa-fw fa-terminal',
>
> one small thought: have you explored whether querying the features of
> the guest when opening the context menu and graying out the snapshot
> option is viable? imo that would be a nicer user experience, but the
> overhead of querying the backend there might be too much.

just saw thomas' review of v2 of this series, so nevermind that. sorry
for the noise.

> other than that:
>
> Reviewed-by: Shannon Sterz <s.sterz@proxmox.com>



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  reply	other threads:[~2025-10-07  9:13 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-06 13:33 [pve-devel] [PATCH pve-manager v3 0/1] " Nicolas Frey
2025-10-06 13:33 ` [pve-devel] [PATCH pve-manager v3 1/1] " Nicolas Frey
2025-10-07  8:42   ` Shannon Sterz
2025-10-07  9:13     ` Shannon Sterz [this message]
2025-10-07  9:14     ` Nicolas Frey
2025-10-07  9:16     ` Thomas Lamprecht
2025-10-07 10:35       ` Nicolas Frey
2025-10-07 10:49         ` Thomas Lamprecht
2025-10-07 12:14 ` [pve-devel] [PATCH pve-manager v3 0/1] " Nicolas Frey

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=DDBZ47U3O0OI.2VGCC5FPIKDY8@proxmox.com \
    --to=s.sterz@proxmox.com \
    --cc=pve-devel-bounces@lists.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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal