[pve-devel] [PATCH v4 manager 3/4] lxc: refactor stop button

Oguz Bektas o.bektas at proxmox.com
Wed Nov 20 15:49:40 CET 2019


move stopBtn into shutdownBtn as a menu item.

we can remove the setDisabled() call for stopBtn near the end, since when
shutdownBtn is disabled, so is stopBtn.

Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
---
 www/manager6/lxc/Config.js | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)

diff --git a/www/manager6/lxc/Config.js b/www/manager6/lxc/Config.js
index 0f81c1da..bfe58040 100644
--- a/www/manager6/lxc/Config.js
+++ b/www/manager6/lxc/Config.js
@@ -52,18 +52,6 @@ Ext.define('PVE.lxc.Config', {
 	    iconCls: 'fa fa-play'
 	});
 
-	var stopBtn = Ext.create('Ext.menu.Item',{
-	    text: gettext('Stop'),
-	    disabled: !caps.vms['VM.PowerMgmt'],
-	    confirmMsg: Proxmox.Utils.format_task_description('vzstop', vmid),
-	    tooltip: Ext.String.format(gettext('Stop {0} immediately'), 'CT'),
-	    dangerous: true,
-	    handler: function() {
-		vm_command("stop");
-	    },
-	    iconCls: 'fa fa-stop'
-	});
-
 	var shutdownBtn = Ext.create('PVE.button.Split', {
 	    text: gettext('Shutdown'),
 	    disabled: !caps.vms['VM.PowerMgmt'] || !running,
@@ -73,7 +61,17 @@ Ext.define('PVE.lxc.Config', {
 		vm_command('shutdown');
 	    },
 	    menu: {
-		items:[stopBtn]
+		items:[{
+		    text: gettext('Stop'),
+		    disabled: !caps.vms['VM.PowerMgmt'],
+		    confirmMsg: Proxmox.Utils.format_task_description('vzstop', vmid),
+		    tooltip: Ext.String.format(gettext('Stop {0} immediately'), 'CT'),
+		    dangerous: true,
+		    handler: function() {
+			vm_command("stop");
+		    },
+		    iconCls: 'fa fa-stop'
+		}]
 	    },
 	    iconCls: 'fa fa-power-off'
 	});
@@ -344,7 +342,6 @@ Ext.define('PVE.lxc.Config', {
 
 	    startBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status === 'running' || template);
 	    shutdownBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status !== 'running');
-	    stopBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status === 'stopped');
 	    me.down('#removeBtn').setDisabled(!caps.vms['VM.Allocate'] || status !== 'stopped');
 	    consoleBtn.setDisabled(template);
 	});
-- 
2.20.1




More information about the pve-devel mailing list