From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id A60E91FF15C for ; Wed, 30 Oct 2024 11:11:04 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CB072147FA; Wed, 30 Oct 2024 11:11:07 +0100 (CET) From: Timothy Nicholson To: pve-devel@lists.proxmox.com Date: Wed, 30 Oct 2024 11:11:01 +0100 Message-Id: <20241030101101.41937-1-t.nicholson@proxmox.com> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.001 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pve-devel] [PATCH manager v3] fix #5787: ui: display guest name in confirmation dialog X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Signed-off-by: Timothy Nicholson --- changes since v2 [1]: - renamed new function - changed function name to camelCase - removed redundant variable binding - edited commit message to better convey the contents of the patch [1]: https://lore.proxmox.com/pve-devel/20241029103956.33643-1-t.nicholson@proxmox.com/ www/manager6/Utils.js | 4 ++++ www/manager6/lxc/CmdMenu.js | 4 ++-- www/manager6/lxc/Config.js | 6 +++--- www/manager6/qemu/CmdMenu.js | 4 ++-- www/manager6/qemu/Config.js | 12 ++++++------ www/manager6/window/GuestStop.js | 2 +- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js index db86fa9a..da8870a6 100644 --- a/www/manager6/Utils.js +++ b/www/manager6/Utils.js @@ -1960,6 +1960,10 @@ Ext.define('PVE.Utils', { } return languageCookie || Proxmox.defaultLang || 'en'; }, + + formatGuestTaskConfirmation: function(taskType, vmid, guestName) { + return Proxmox.Utils.format_task_description(taskType, `${vmid} (${guestName})`); + }, }, singleton: true, diff --git a/www/manager6/lxc/CmdMenu.js b/www/manager6/lxc/CmdMenu.js index 76b39423..e30989a6 100644 --- a/www/manager6/lxc/CmdMenu.js +++ b/www/manager6/lxc/CmdMenu.js @@ -22,7 +22,7 @@ Ext.define('PVE.lxc.CmdMenu', { }); }; let confirmedVMCommand = (cmd, params) => { - let msg = Proxmox.Utils.format_task_description(`vz${cmd}`, info.vmid); + let msg = PVE.Utils.formatGuestTaskConfirmation(`vz${cmd}`, info.vmid, info.name); Ext.Msg.confirm(gettext('Confirm'), msg, btn => { if (btn === 'yes') { vm_command(cmd, params); @@ -108,7 +108,7 @@ Ext.define('PVE.lxc.CmdMenu', { text: gettext('Convert to template'), iconCls: 'fa fa-fw fa-file-o', handler: function() { - let msg = Proxmox.Utils.format_task_description('vztemplate', info.vmid); + let msg = PVE.Utils.formatGuestTaskConfirmation('vztemplate', info.vmid, info.name); Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) { if (btn === 'yes') { Proxmox.Utils.API2Request({ diff --git a/www/manager6/lxc/Config.js b/www/manager6/lxc/Config.js index d0e40fc4..16494172 100644 --- a/www/manager6/lxc/Config.js +++ b/www/manager6/lxc/Config.js @@ -59,7 +59,7 @@ Ext.define('PVE.lxc.Config', { text: gettext('Shutdown'), disabled: !caps.vms['VM.PowerMgmt'] || !running, hidden: template, - confirmMsg: Proxmox.Utils.format_task_description('vzshutdown', vmid), + confirmMsg: PVE.Utils.formatGuestTaskConfirmation('vzshutdown', vmid, vm.name), handler: function() { vm_command('shutdown'); }, @@ -67,7 +67,7 @@ Ext.define('PVE.lxc.Config', { items: [{ text: gettext('Reboot'), disabled: !caps.vms['VM.PowerMgmt'], - confirmMsg: Proxmox.Utils.format_task_description('vzreboot', vmid), + confirmMsg: PVE.Utils.formatGuestTaskConfirmation('vzreboot', vmid, vm.name), tooltip: Ext.String.format(gettext('Reboot {0}'), 'CT'), handler: function() { vm_command("reboot"); @@ -124,7 +124,7 @@ Ext.define('PVE.lxc.Config', { xtype: 'pveMenuItem', iconCls: 'fa fa-fw fa-file-o', hidden: !caps.vms['VM.Allocate'], - confirmMsg: Proxmox.Utils.format_task_description('vztemplate', vmid), + confirmMsg: PVE.Utils.formatGuestTaskConfirmation('vztemplate', vmid, vm.name), handler: function() { Proxmox.Utils.API2Request({ url: base_url + '/template', diff --git a/www/manager6/qemu/CmdMenu.js b/www/manager6/qemu/CmdMenu.js index 834577e7..7a4e0a0e 100644 --- a/www/manager6/qemu/CmdMenu.js +++ b/www/manager6/qemu/CmdMenu.js @@ -23,7 +23,7 @@ Ext.define('PVE.qemu.CmdMenu', { }; let confirmedVMCommand = (cmd, params, confirmTask) => { let task = confirmTask || `qm${cmd}`; - let msg = Proxmox.Utils.format_task_description(task, info.vmid); + let msg = PVE.Utils.formatGuestTaskConfirmation(task, info.vmid, info.name); Ext.Msg.confirm(gettext('Confirm'), msg, btn => { if (btn === 'yes') { vm_command(cmd, params); @@ -136,7 +136,7 @@ Ext.define('PVE.qemu.CmdMenu', { iconCls: 'fa fa-fw fa-file-o', hidden: !caps.vms['VM.Allocate'], handler: function() { - let msg = Proxmox.Utils.format_task_description('qmtemplate', info.vmid); + let msg = PVE.Utils.formatGuestTaskConfirmation('qmtemplate', info.vmid, info.name); Ext.Msg.confirm(gettext('Confirm'), msg, btn => { if (btn === 'yes') { Proxmox.Utils.API2Request({ diff --git a/www/manager6/qemu/Config.js b/www/manager6/qemu/Config.js index f28ee67b..42e7f0db 100644 --- a/www/manager6/qemu/Config.js +++ b/www/manager6/qemu/Config.js @@ -97,7 +97,7 @@ Ext.define('PVE.qemu.Config', { xtype: 'pveMenuItem', iconCls: 'fa fa-fw fa-file-o', hidden: !caps.vms['VM.Allocate'], - confirmMsg: Proxmox.Utils.format_task_description('qmtemplate', vmid), + confirmMsg: PVE.Utils.formatGuestTaskConfirmation('qmtemplate', vmid, vm.name), handler: function() { Proxmox.Utils.API2Request({ url: base_url + '/template', @@ -142,7 +142,7 @@ Ext.define('PVE.qemu.Config', { text: gettext('Shutdown'), disabled: !caps.vms['VM.PowerMgmt'] || !running, hidden: template, - confirmMsg: Proxmox.Utils.format_task_description('qmshutdown', vmid), + confirmMsg: PVE.Utils.formatGuestTaskConfirmation('qmshutdown', vmid, vm.name), handler: function() { vm_command('shutdown'); }, @@ -151,7 +151,7 @@ Ext.define('PVE.qemu.Config', { text: gettext('Reboot'), disabled: !caps.vms['VM.PowerMgmt'], tooltip: Ext.String.format(gettext('Shutdown, apply pending changes and reboot {0}'), 'VM'), - confirmMsg: Proxmox.Utils.format_task_description('qmreboot', vmid), + confirmMsg: PVE.Utils.formatGuestTaskConfirmation('qmreboot', vmid, vm.name), handler: function() { vm_command("reboot"); }, @@ -159,7 +159,7 @@ Ext.define('PVE.qemu.Config', { }, { text: gettext('Pause'), disabled: !caps.vms['VM.PowerMgmt'], - confirmMsg: Proxmox.Utils.format_task_description('qmpause', vmid), + confirmMsg: PVE.Utils.formatGuestTaskConfirmation('qmpause', vmid, vm.name), handler: function() { vm_command("suspend"); }, @@ -167,7 +167,7 @@ Ext.define('PVE.qemu.Config', { }, { text: gettext('Hibernate'), disabled: !caps.vms['VM.PowerMgmt'], - confirmMsg: Proxmox.Utils.format_task_description('qmsuspend', vmid), + confirmMsg: PVE.Utils.formatGuestTaskConfirmation('qmsuspend', vmid, vm.name), tooltip: gettext('Suspend to disk'), handler: function() { vm_command("suspend", { todisk: 1 }); @@ -189,7 +189,7 @@ Ext.define('PVE.qemu.Config', { text: gettext('Reset'), disabled: !caps.vms['VM.PowerMgmt'], tooltip: Ext.String.format(gettext('Reset {0} immediately'), 'VM'), - confirmMsg: Proxmox.Utils.format_task_description('qmreset', vmid), + confirmMsg: PVE.Utils.formatGuestTaskConfirmation('qmreset', vmid, vm.name), handler: function() { vm_command("reset"); }, diff --git a/www/manager6/window/GuestStop.js b/www/manager6/window/GuestStop.js index fbd45c7a..324a6b8a 100644 --- a/www/manager6/window/GuestStop.js +++ b/www/manager6/window/GuestStop.js @@ -68,7 +68,7 @@ Ext.define('PVE.GuestStop', { let cfg = { title: gettext('Confirm'), icon: Ext.Msg.WARNING, - msg: Proxmox.Utils.format_task_description(me.taskType, me.vm.vmid), + msg: PVE.Utils.formatGuestTaskConfirmation(me.taskType, me.vm.vmid, me.vm.name), buttons: Ext.Msg.YESNO, callback: btn => me.handler(btn), }; -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel