From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 8DF7F1FF16B for ; Fri, 7 Nov 2025 15:01:10 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 463D111D40; Fri, 7 Nov 2025 15:01:50 +0100 (CET) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Fri, 7 Nov 2025 15:00:26 +0100 Message-ID: <20251107140136.3972272-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.027 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH manager] ui: resource tree: prevent overwriting of 'text' property X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" currently, when 'setText' is called for a tree item, the 'text' property in the store is overwritten. This can occur when the item changes or when the 'UIOptions' change, which can be triggered arbitrarily (e.g. by opening the 'Datacenter -> Options' panel.) Since this can be triggered manually, overwriting the 'text' property can lead to tags being shown multiple times. (When sorting is set to vmid). To prevent this from happening, instead of overwriting the 'text' property, use the 'renderer' method of the column. For that the column has to be manually redefined. This should prevent similar problems in the future, since the 'text' is not overwritten anymore, but it is generated during rendering. Fixes: 952a4f61 (fix #6815: ui: resource tree: update tag colors properly) Reported-by: Stefan Hanreich Signed-off-by: Dominik Csapak --- www/manager6/tree/ResourceTree.js | 60 +++++++++++++++++-------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/www/manager6/tree/ResourceTree.js b/www/manager6/tree/ResourceTree.js index e83ccfc8..68611a42 100644 --- a/www/manager6/tree/ResourceTree.js +++ b/www/manager6/tree/ResourceTree.js @@ -42,6 +42,39 @@ Ext.define('PVE.tree.ResourceTree', { }, }, + columns: [ + { + xtype: 'treecolumn', + flex: 1, + dataIndex: 'text', + renderer: function (val, meta, rec) { + let info = rec.data; + + let text = ''; + let status = ''; + if (info.type === 'storage') { + let usage = info.disk / info.maxdisk; + if (usage >= 0.0 && usage <= 1.0) { + let barHeight = (usage * 100).toFixed(0); + let remainingHeight = (100 - barHeight).toFixed(0); + status = '
'; + status += `
`; + status += `
`; + status += '
'; + } + } + if (Ext.isNumeric(info.vmid) && info.vmid > 0) { + if (PVE.UIOptions.getTreeSortingValue('sort-field') !== 'vmid') { + text = `${info.name} (${String(info.vmid)})`; + } + } + text = `${status}${info.text}`; + text += PVE.Utils.renderTags(info.tags, PVE.UIOptions.tagOverrides); + return (info.renderedText = text); + }, + }, + ], + useArrows: true, // private @@ -130,30 +163,6 @@ Ext.define('PVE.tree.ResourceTree', { } }, - setText: function (info) { - let _me = this; - - let status = ''; - if (info.type === 'storage') { - let usage = info.disk / info.maxdisk; - if (usage >= 0.0 && usage <= 1.0) { - let barHeight = (usage * 100).toFixed(0); - let remainingHeight = (100 - barHeight).toFixed(0); - status = '
'; - status += `
`; - status += `
`; - status += '
'; - } - } - if (Ext.isNumeric(info.vmid) && info.vmid > 0) { - if (PVE.UIOptions.getTreeSortingValue('sort-field') !== 'vmid') { - info.text = `${info.name} (${String(info.vmid)})`; - } - } - info.text = `${status}${info.text}`; - info.text += PVE.Utils.renderTags(info.tags, PVE.UIOptions.tagOverrides); - }, - getToolTip: function (info) { let qtips = []; if (info.qmpstatus || info.status) { @@ -186,7 +195,6 @@ Ext.define('PVE.tree.ResourceTree', { let me = this; me.setIconCls(info); - me.setText(info); if (info.groupbyid) { if (me.viewFilter.groupRenderer) { @@ -408,7 +416,6 @@ Ext.define('PVE.tree.ResourceTree', { info.id = oldid; } me.setIconCls(info); - me.setText(info); olditem.commit(); } if ((!item || moved) && olditem.isLeaf()) { @@ -609,7 +616,6 @@ Ext.define('PVE.tree.ResourceTree', { node.beginEdit(); let info = node.data; me.setIconCls(info); - me.setText(info); if (me.viewFilter.groupRenderer) { info.text = me.viewFilter.groupRenderer(info); } -- 2.47.3 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel