On 10/30/2015 03:15 PM, Thomas Lamprecht wrote:
Only show edit dialogs for HA resources and groups when an user
has the privileges to edit them.
---
  www/manager/ha/Groups.js    | 8 ++++++++
  www/manager/ha/Resources.js | 8 ++++++++
  2 files changed, 16 insertions(+)

diff --git a/www/manager/ha/Groups.js b/www/manager/ha/Groups.js
index 786327e..e596c00 100644
--- a/www/manager/ha/Groups.js
+++ b/www/manager/ha/Groups.js
@@ -5,6 +5,8 @@ Ext.define('PVE.ha.GroupsView', {
      initComponent : function() {
        var me = this;
+ var caps = Ext.state.Manager.get('GuiCap');
+
        var store = new Ext.data.Store({
            model: 'pve-ha-groups',
            sorters: {
@@ -67,6 +69,7 @@ Ext.define('PVE.ha.GroupsView', {
            tbar: [
                {
                    text: gettext('Create'),
+                   disabled: !caps.nodes['Sys.Console'],
                    handler: function() {
                        var win = Ext.create('PVE.ha.GroupEdit',{});
                        win.on('destroy', reload);
@@ -110,6 +113,11 @@ Ext.define('PVE.ha.GroupsView', {
            ],
            listeners: {
                show: reload,
+               beforeselect: function(grid, record, index, eOpts) {
+                   if (!caps.nodes['Sys.Console']) {
+                       return false;
+                   }
+               },

To explain the addition made here and in the Resource.js:
The beforeselect event gets fired before a record is selected.
If any listener returns false, the selection is cancelled.

                itemdblclick: run_editor
            }
        });
diff --git a/www/manager/ha/Resources.js b/www/manager/ha/Resources.js
index a8212bd..495f039 100644
--- a/www/manager/ha/Resources.js
+++ b/www/manager/ha/Resources.js
@@ -5,6 +5,8 @@ Ext.define('PVE.ha.ResourcesView', {
      initComponent : function() {
        var me = this;
+ var caps = Ext.state.Manager.get('GuiCap');
+
        var store = new Ext.data.Store({
            model: 'pve-ha-resources',
            proxy: {
@@ -93,6 +95,7 @@ Ext.define('PVE.ha.ResourcesView', {
            tbar: [
                {
                    text: gettext('Add'),
+                   disabled: !caps.nodes['Sys.Console'],
                    handler: function() {
                        var win = Ext.create('PVE.ha.VMResourceEdit',{});
                        win.on('destroy', reload);
@@ -135,6 +138,11 @@ Ext.define('PVE.ha.ResourcesView', {
            ],
            listeners: {
                show: reload,
+               beforeselect: function(grid, record, index, eOpts) {
+                   if (!caps.nodes['Sys.Console']) {
+                       return false;
+                   }
+               },
                itemdblclick: run_editor
            }
        });


_______________________________________________
pve-devel mailing list
[email protected]
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to