[pve-devel] [PATCH manager v2] ui: resourcetree: move guest position on template creation

Dominik Csapak d.csapak at proxmox.com
Mon Oct 4 09:50:00 CEST 2021


we sort templates at the end normally, but if we convert a guest to a
template, it was not moved in the tree

add it to the list of attributes that are checked for a move

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
changes from v1:
* create an array where we append the additional attributes to check
  instead of having the checks separate, this way, we can easily
  add new attributes to the list if we want to

 www/manager6/tree/ResourceTree.js | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/www/manager6/tree/ResourceTree.js b/www/manager6/tree/ResourceTree.js
index 3b883d23..be90d4f7 100644
--- a/www/manager6/tree/ResourceTree.js
+++ b/www/manager6/tree/ResourceTree.js
@@ -239,6 +239,8 @@ Ext.define('PVE.tree.ResourceTree', {
 	    }
 
 	    let groups = me.viewFilter.groups || [];
+	    // explicitly check for node/template, as those are not always grouping attributes
+	    let moveCheckAttrs = groups.concat(['node', 'template']);
 	    let filterfn = me.viewFilter.filterfn;
 
 	    let reselect = false; // for disappeared nodes
@@ -251,16 +253,12 @@ Ext.define('PVE.tree.ResourceTree', {
 		let changed = false, moved = false;
 		if (item) {
 		    // test if any grouping attributes changed, catches migrated tree-nodes in server view too
-		    for (const attr of groups) {
+		    for (const attr of moveCheckAttrs) {
 			if (item.data[attr] !== olditem.data[attr]) {
 			    moved = true;
 			    break;
 			}
 		    }
-		    // explicitly check for node, as node is not a grouping attribute in some views
-		    if (!moved && item.data.node !== olditem.data.node) {
-			moved = true;
-		    }
 
 		    // tree item has been updated
 		    for (const field of ['text', 'running', 'template', 'status', 'qmpstatus', 'hastate', 'lock']) {
-- 
2.30.2





More information about the pve-devel mailing list