public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH manager] ui: tree: add expand/collapse all options to datacenter cmd menu
Date: Tue, 24 Nov 2026 17:26:11 +0100	[thread overview]
Message-ID: <20261124163004.871330-1-d.csapak@proxmox.com> (raw)

The tree often comes collapsed, and sometimes it's tedious to open all
relevant nodes, tags, etc.

Add expand and collapse all options to the right click menu of the
datacenter entry. This is always available, and does not take up any
valuable space.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
@Thomas: since we couldn't find common ground on the actual positioning
last time, this menu was added, so i though this might be a good place
to add these buttons. We can still add them somewhere else in the future
but this still fits IMO.

Note that nested expanded nodes inside collapsed ones are not collapsed.
This is existing extjs behavior and seems like the right choice (only
collapse what was visibly expanded). If, not we can ofc forcibly
collpase *all* nodes recursively. (this should only matter for
pools since we don't have multiple layers of nesting otherwise).


 www/manager6/dc/CmdMenu.js        | 41 +++++++++++++++++++++++++++++++
 www/manager6/tree/ResourceTree.js |  8 ++++++
 2 files changed, 49 insertions(+)

diff --git a/www/manager6/dc/CmdMenu.js b/www/manager6/dc/CmdMenu.js
index a8df24104..ecdff73d8 100644
--- a/www/manager6/dc/CmdMenu.js
+++ b/www/manager6/dc/CmdMenu.js
@@ -6,6 +6,8 @@ Ext.define('PVE.dc.CmdMenu', {
 
     extraHandlerArgs: {},
 
+    showTreeActions: true,
+
     items: [
         {
             text: gettext('Bulk Start'),
@@ -71,6 +73,37 @@ Ext.define('PVE.dc.CmdMenu', {
                 });
             },
         },
+        {
+            xtype: 'menuseparator',
+            itemId: 'treeSeparator',
+            hidden: true,
+        },
+        {
+            text: gettext('Expand All'),
+            iconCls: 'fa fa-fw fa-expand',
+            itemId: 'expandAll',
+            hidden: true,
+            handler: function () {
+                let tree = Ext.ComponentQuery.query('pveResourceTree')[0];
+                if (!tree) {
+                    return;
+                }
+                tree.expandAll();
+            },
+        },
+        {
+            text: gettext('Collapse All'),
+            itemId: 'collapseAll',
+            iconCls: 'fa fa-fw fa-compress',
+            hidden: true,
+            handler: function () {
+                let tree = Ext.ComponentQuery.query('pveResourceTree')[0];
+                if (!tree) {
+                    return;
+                }
+                tree.collapseBelowDC();
+            },
+        },
     ],
 
     initComponent: function () {
@@ -99,6 +132,10 @@ Ext.define('PVE.dc.CmdMenu', {
         if (PVE.Utils.isStandaloneNode()) {
             me.getComponent('bulkmigrate').setVisible(false);
         }
+
+        me.getComponent('treeSeparator').setVisible(!!me.showTreeActions);
+        me.getComponent('expandAll').setVisible(!!me.showTreeActions);
+        me.getComponent('collapseAll').setVisible(!!me.showTreeActions);
     },
 });
 
@@ -108,6 +145,8 @@ Ext.define('PVE.dc.TagCmdMenu', {
 
     minWidth: 220,
 
+    showTreeActions: false,
+
     initComponent: function () {
         let me = this;
 
@@ -131,6 +170,8 @@ Ext.define('PVE.dc.PoolCmdMenu', {
 
     minWidth: 220,
 
+    showTreeActions: false,
+
     initComponent: function () {
         let me = this;
 
diff --git a/www/manager6/tree/ResourceTree.js b/www/manager6/tree/ResourceTree.js
index 5d96bffb9..15b90d159 100644
--- a/www/manager6/tree/ResourceTree.js
+++ b/www/manager6/tree/ResourceTree.js
@@ -304,6 +304,14 @@ Ext.define('PVE.tree.ResourceTree', {
         return changed;
     },
 
+    // collapseAll also collapses the root element, which we don't want
+    collapseBelowDC: function () {
+        let me = this;
+        me.suspendLayouts();
+        me.getRootNode().collapseChildren(true);
+        me.resumeLayouts(true);
+    },
+
     initComponent: function () {
         let me = this;
         me.saveSortingOptions();
-- 
2.47.3





                 reply	other threads:[~2026-11-24 16:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261124163004.871330-1-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal