From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-manager v4 2/2] ui: resource tree: only fire 'refresh' event when something changed
Date: Mon, 16 Nov 2026 09:51:01 +0100 [thread overview]
Message-ID: <20261116085222.993923-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20261116085222.993923-1-d.csapak@proxmox.com>
to optimize the rendering to the dom, only fire the 'refresh' event of
the store at the end of the updateTree method when either:
* an element changed its relevant data
* something moved
* a new element was inserted
* an element was removed
We also need to refresh the store when the UI options are reloaded, so
the tags get the correct color.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
changes from v3:
* rebase on current master
* use 'me.store' consistently when firing the 'refresh' event after
the UI options were loaded
* improve the comment there to say why the refresh is necessary
* fix typo in the commit message
www/manager6/tree/ResourceTree.js | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/www/manager6/tree/ResourceTree.js b/www/manager6/tree/ResourceTree.js
index 3efb1cd3..5d96bffb 100644
--- a/www/manager6/tree/ResourceTree.js
+++ b/www/manager6/tree/ResourceTree.js
@@ -377,6 +377,7 @@ Ext.define('PVE.tree.ResourceTree', {
let updateTree = function () {
store.suspendEvents();
+ let anyChanged = false;
let rootnode;
if (firstUpdate) {
rootnode = Ext.create('PVETree', {
@@ -465,6 +466,7 @@ Ext.define('PVE.tree.ResourceTree', {
}
me.setIconCls(info);
olditem.commit();
+ anyChanged = true;
}
if ((!item || moved) && olditem.isLeaf()) {
delete index[key];
@@ -482,6 +484,8 @@ Ext.define('PVE.tree.ResourceTree', {
let grandParent = parentNode.parentNode;
grandParent.removeChild(parentNode, true);
}
+
+ anyChanged = true;
}
}
@@ -501,10 +505,13 @@ Ext.define('PVE.tree.ResourceTree', {
if (child) {
index[item.data.id] = child;
}
+ anyChanged = true;
});
store.resumeEvents();
- store.fireEvent('refresh', store);
+ if (anyChanged) {
+ store.fireEvent('refresh', store);
+ }
let foundChild = findNode(rootnode, lastsel?.data.id);
@@ -663,6 +670,9 @@ Ext.define('PVE.tree.ResourceTree', {
return true;
},
});
+
+ // some nodes need rerendering here, e.g. for tag colors
+ me.store.fireEvent('refresh', me.store);
});
},
});
--
2.47.3
next prev parent reply other threads:[~2026-11-16 8:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 8:51 [PATCH pve-manager v4 1/2] ui: resource tree: use 'diskuse' instead of calculating every time Dominik Csapak
2026-11-16 8:51 ` Dominik Csapak [this message]
2026-11-16 11:04 ` applied: " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261116085222.993923-2-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.