[pve-devel] [PATCH manager 15/17] hide migrate in contextmenu when no cluster or no rights
Thomas Lamprecht
t.lamprecht at proxmox.com
Wed Aug 23 11:27:32 CEST 2017
base idea OK, comments inline.
On 07/19/2017 03:45 PM, Dominik Csapak wrote:
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> www/manager6/lxc/CmdMenu.js | 9 ++++++++-
> www/manager6/qemu/CmdMenu.js | 3 ++-
> 2 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/www/manager6/lxc/CmdMenu.js b/www/manager6/lxc/CmdMenu.js
> index a96618af..f02f19c4 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 // we only have 1 element between to separators
confusing comment, I'd just omit it...
> + },
> {
> text: gettext('Migrate'),
> iconCls: 'fa fa-fw fa-send-o',
> + hidden: standalone || (caps.vms['VM.Migrate'] ? false : true),
I'd use:
!caps.vms['VM.Migrate']
easier to read, IMO.
> 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..0fb832d4 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':
> @@ -114,7 +115,7 @@ Ext.define('PVE.qemu.CmdMenu', {
> {
> text: gettext('Migrate'),
> iconCls: 'fa fa-fw fa-send-o',
> - hidden: caps.vms['VM.Migrate'] ? false : true,
> + hidden: standalone || (caps.vms['VM.Migrate'] ? false : true),
same as above
> handler: function() {
> var win = Ext.create('PVE.window.Migrate', {
> vmtype: 'qemu',
>
You need to hide the separator in the not-standalone but
no migrate-caps too. In the LXC case its currently easy.
The qemu case is easy too but needs quite long check as there may be more elements.
An on-top of your patch fix for this could look like:
----8<----
diff --git a/www/manager6/lxc/CmdMenu.js b/www/manager6/lxc/CmdMenu.js
index f02f19c4..585a5c54 100644
--- a/www/manager6/lxc/CmdMenu.js
+++ b/www/manager6/lxc/CmdMenu.js
@@ -113,7 +113,7 @@ Ext.define('PVE.lxc.CmdMenu', {
},
{
xtype: 'menuseparator',
- hidden: standalone // we only have 1 element between to separators
+ hidden: standalone || !caps.vms['VM.Migrate']
},
{
text: gettext('Migrate'),
diff --git a/www/manager6/qemu/CmdMenu.js b/www/manager6/qemu/CmdMenu.js
index 0fb832d4..c76c511b 100644
--- a/www/manager6/qemu/CmdMenu.js
+++ b/www/manager6/qemu/CmdMenu.js
@@ -111,7 +111,10 @@ 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',
---->8----
More information about the pve-devel
mailing list