[pve-devel] [PATCH manager 1/4] ui: hide 'no tags' field and edit icon without VM.Config.Options

Dominik Csapak d.csapak at proxmox.com
Fri Nov 18 12:59:15 CET 2022


they cannot edit them anyway, so no point in showing them that
there is no tag

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/form/TagEdit.js | 12 ++++++++++--
 www/manager6/lxc/Config.js   |  1 +
 www/manager6/qemu/Config.js  |  1 +
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/www/manager6/form/TagEdit.js b/www/manager6/form/TagEdit.js
index d4428e029..23b75acc7 100644
--- a/www/manager6/form/TagEdit.js
+++ b/www/manager6/form/TagEdit.js
@@ -7,6 +7,9 @@ Ext.define('PVE.panel.TagEditContainer', {
 	align: 'middle',
     },
 
+    // set to false to hide the 'no tags' field and the edit button
+    canEdit: true,
+
     controller: {
 	xclass: 'Ext.app.ViewController',
 
@@ -241,6 +244,7 @@ Ext.define('PVE.panel.TagEditContainer', {
 	    if (view.tags) {
 		me.loadTags(view.tags);
 	    }
+	    me.getViewModel().set('canEdit', view.canEdit);
 
 	    me.mon(Ext.GlobalEvents, 'loadedUiOptions', () => {
 		view.toggleCls('hide-handles', PVE.Utils.shouldSortTags());
@@ -253,11 +257,15 @@ Ext.define('PVE.panel.TagEditContainer', {
 	data: {
 	    tagCount: 0,
 	    editMode: false,
+	    canEdit: true,
 	},
 
 	formulas: {
 	    hideNoTags: function(get) {
-		return get('tagCount') !== 0;
+		return get('tagCount') !== 0 || !get('canEdit');
+	    },
+	    hideEditBtn: function(get) {
+		return get('editMode') || !get('canEdit');
 	    },
 	},
     },
@@ -326,7 +334,7 @@ Ext.define('PVE.panel.TagEditContainer', {
 	    cls: 'pve-tag-inline-button',
 	    html: `<i data-qtip="${gettext('Edit Tags')}" class="fa fa-pencil"></i>`,
 	    bind: {
-		hidden: '{editMode}',
+		hidden: '{hideEditBtn}',
 	    },
 	    listeners: {
 		click: 'editClick',
diff --git a/www/manager6/lxc/Config.js b/www/manager6/lxc/Config.js
index f33390513..23c17d2ea 100644
--- a/www/manager6/lxc/Config.js
+++ b/www/manager6/lxc/Config.js
@@ -186,6 +186,7 @@ Ext.define('PVE.lxc.Config', {
 
 	let tagsContainer = Ext.create('PVE.panel.TagEditContainer', {
 	    tags: vm.tags,
+	    canEdit: !!caps.vms['VM.Config.Options'],
 	    listeners: {
 		change: function(tags) {
 		    Proxmox.Utils.API2Request({
diff --git a/www/manager6/qemu/Config.js b/www/manager6/qemu/Config.js
index 5c8fa620d..94c540c59 100644
--- a/www/manager6/qemu/Config.js
+++ b/www/manager6/qemu/Config.js
@@ -222,6 +222,7 @@ Ext.define('PVE.qemu.Config', {
 
 	let tagsContainer = Ext.create('PVE.panel.TagEditContainer', {
 	    tags: vm.tags,
+	    canEdit: !!caps.vms['VM.Config.Options'],
 	    listeners: {
 		change: function(tags) {
 		    Proxmox.Utils.API2Request({
-- 
2.30.2






More information about the pve-devel mailing list