From: Nicolas Frey <n.frey@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-manager 3/3] ui: resource tree: allow selecting multiple guests for bulk actions
Date: Tue, 27 Oct 2026 15:30:50 +0100 [thread overview]
Message-ID: <20261027143050.493707-4-n.frey@proxmox.com> (raw)
In-Reply-To: <20261027143050.493707-1-n.frey@proxmox.com>
by switching the selmModel mode to 'MULTI' and restricting those selects
to guest resources only. now opens `PVE.dc.GuestSelectionCmdMenu` as the
context menu on right click, instead of the one for that resource.
Signed-off-by: Nicolas Frey <n.frey@proxmox.com>
---
www/manager6/Utils.js | 17 ++++++++++++++++-
www/manager6/Workspace.js | 6 +++++-
www/manager6/tree/ResourceTree.js | 10 +++++++++-
3 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 8b99371d..1efce1a4 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -1615,7 +1615,22 @@ Ext.define('PVE.Utils', {
let menu;
let type = record.data.type;
- if (record.data.template) {
+ let selModel = v.getSelectionModel();
+ let selection = selModel.isSelected(record) ? selModel.getSelection() : [];
+ let vmids =
+ selection
+ .filter(
+ (rec) =>
+ (rec.data.type === 'qemu' || rec.data.type === 'lxc') &&
+ !rec.data.template,
+ )
+ .map((rec) => rec.data.vmid);
+
+ if (selection.length > 1 && vmids.length) {
+ menu = Ext.create('PVE.dc.GuestSelectionCmdMenu', {
+ vmids,
+ });
+ } else if (record.data.template) {
if (type === 'qemu' || type === 'lxc') {
menu = Ext.create('PVE.menu.TemplateMenu', {
pveSelNode: record,
diff --git a/www/manager6/Workspace.js b/www/manager6/Workspace.js
index 189d3373..f1b0c90a 100644
--- a/www/manager6/Workspace.js
+++ b/www/manager6/Workspace.js
@@ -232,9 +232,13 @@ Ext.define('PVE.StdWorkspace', {
flex: 1,
selModel: {
selType: 'treemodel',
+ mode: 'MULTI',
+ allowDeselect: true,
listeners: {
selectionchange: function (sm, selected) {
- if (selected.length <= 0) {
+ // when selecting multiple guests, another selection (in multi-select)
+ // should not switch the view
+ if (selected.length !== 1) {
return;
}
let treeNode = selected[0];
diff --git a/www/manager6/tree/ResourceTree.js b/www/manager6/tree/ResourceTree.js
index e2acc431..971c1140 100644
--- a/www/manager6/tree/ResourceTree.js
+++ b/www/manager6/tree/ResourceTree.js
@@ -547,7 +547,15 @@ Ext.define('PVE.tree.ResourceTree', {
beforeselect: function (tree, record, index, eopts) {
let allow = me.allowSelection;
me.allowSelection = true;
- return allow;
+ if (!allow) {
+ return false;
+ }
+ // only guests can be part of a selection of multiple entries, as they're the
+ // only resources with bulk actions
+ let isGuest = (rec) =>
+ (rec.data.type === 'qemu' || rec.data.type === 'lxc') && !rec.data.template;
+ let others = tree.getSelection().filter((rec) => rec !== record);
+ return !others.length || (isGuest(record) && others.every(isGuest));
},
itemdblclick: PVE.Utils.openTreeConsole,
afterrender: function () {
--
2.47.3
prev parent reply other threads:[~2026-10-27 14:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 14:30 [RFC manager 0/3] add bulk actions cmdmenu with multi select in resource tree Nicolas Frey
2026-10-27 14:30 ` [PATCH pve-manager 1/3] ui: bulk action window: allow restricting the guest list by VMIDs Nicolas Frey
2026-10-27 14:30 ` [PATCH pve-manager 2/3] ui: bulk actions: add cmdmenu with guest selection Nicolas Frey
2026-10-27 14:30 ` Nicolas Frey [this message]
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=20261027143050.493707-4-n.frey@proxmox.com \
--to=n.frey@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