[pve-devel] [PATCH manager v2 3/3] hide migrate in contextmenu when no cluster or no rights

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Aug 29 11:41:19 CEST 2017


From: Dominik Csapak <d.csapak at proxmox.com>

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---

changes v1 -> v2:
 * remove confusing comment
 * hidden check: switched from `inline trenary if' to simple boolean
   negation
 * hide entries also in the non-stanalone but no right case also

 www/manager6/lxc/CmdMenu.js  |  9 ++++++++-
 www/manager6/qemu/CmdMenu.js | 12 ++++++++----
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/www/manager6/lxc/CmdMenu.js b/www/manager6/lxc/CmdMenu.js
index a96618af..d2fd0f1f 100644
--- a/www/manager6/lxc/CmdMenu.js
+++ b/www/manager6/lxc/CmdMenu.js
@@ -27,9 +27,12 @@ Ext.define('PVE.lxc.CmdMenu', {
 	    });
 	};
 
+	var caps = Ext.state.Manager.get('GuiCap');
+
 	var running = false;
 	var stopped = true;
 	var suspended = false;
+	var standalone = PVE.data.ResourceStore.getNodes().length < 2;
 
 	switch (me.pveSelNode.data.status) {
 	    case 'running':
@@ -108,10 +111,14 @@ Ext.define('PVE.lxc.CmdMenu', {
 		    });
 		}
 	    },
-	    { xtype: 'menuseparator' },
+	    {
+		xtype: 'menuseparator',
+		hidden: standalone || !caps.vms['VM.Migrate']
+	    },
 	    {
 		text: gettext('Migrate'),
 		iconCls: 'fa fa-fw fa-send-o',
+		hidden: standalone || !caps.vms['VM.Migrate'],
 		handler: function() {
 		    var win = Ext.create('PVE.window.Migrate', {
 			vmtype: 'lxc',
diff --git a/www/manager6/qemu/CmdMenu.js b/www/manager6/qemu/CmdMenu.js
index aa525b84..f9514690 100644
--- a/www/manager6/qemu/CmdMenu.js
+++ b/www/manager6/qemu/CmdMenu.js
@@ -33,6 +33,7 @@ Ext.define('PVE.qemu.CmdMenu', {
 	var running = false;
 	var stopped = true;
 	var suspended = false;
+	var standalone = PVE.data.ResourceStore.getNodes().length < 2;
 
 	switch (me.pveSelNode.data.status) {
 	    case 'running':
@@ -110,11 +111,14 @@ Ext.define('PVE.qemu.CmdMenu', {
 		    });
 		}
 	    },
-	    { xtype: 'menuseparator' },
+	    {
+		xtype: 'menuseparator',
+		hidden: !(standalone || !caps.vms['VM.Migrate'] || caps.vms['VM.Allocate'] || caps.vms['VM.Clone'])
+	    },
 	    {
 		text: gettext('Migrate'),
 		iconCls: 'fa fa-fw fa-send-o',
-		hidden: caps.vms['VM.Migrate'] ? false : true,
+		hidden: standalone || !caps.vms['VM.Migrate'],
 		handler: function() {
 		    var win = Ext.create('PVE.window.Migrate', {
 			vmtype: 'qemu',
@@ -127,7 +131,7 @@ Ext.define('PVE.qemu.CmdMenu', {
 	    {
 		text: gettext('Clone'),
 		iconCls: 'fa fa-fw fa-clone',
-		hidden: caps.vms['VM.Clone'] ? false : true,
+		hidden: !caps.vms['VM.Clone'],
 		handler: function() {
 		    PVE.window.Clone.wrap(nodename, vmid, me.isTemplate);
 		}
@@ -135,7 +139,7 @@ Ext.define('PVE.qemu.CmdMenu', {
 	    {
 		text: gettext('Convert to template'),
 		iconCls: 'fa fa-fw fa-file-o',
-		hidden: caps.vms['VM.Allocate'] ? false : true,
+		hidden: !caps.vms['VM.Allocate'],
 		handler: function() {
 		    var msg = PVE.Utils.format_task_description('qmtemplate', vmid);
 		    Ext.Msg.confirm(gettext('Confirm'), msg, function(btn) {
-- 
2.11.0




More information about the pve-devel mailing list