[pve-devel] applied+cleanup: [PATCH manager v2 3/3] hide migrate in contextmenu when no cluster or no rights
Fabian Grünbichler
f.gruenbichler at proxmox.com
Fri Sep 1 11:27:39 CEST 2017
see below
On Tue, Aug 29, 2017 at 11:41:19AM +0200, Thomas Lamprecht wrote:
> 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'])
this was wrong, replaced with correct and IMHO more readable:
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
>
>
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
More information about the pve-devel
mailing list