From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [RFC PATCH pve-manager 2/2] ui: create wizards: optionally open the new guest's summary or console
Date: Tue, 24 Nov 2026 15:37:50 +0100 [thread overview]
Message-ID: <20261124144207.3675423-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20261124144207.3675423-1-d.csapak@proxmox.com>
after it was created, so users don't have to search for it in the tree.
Select it once the creation task succeeded, but only if the user did
not select something else in the meantime. Use the embedded Console tab
instead of a console window, since the browser would block such a popup
that isn't directly initiated by the user.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
in case the the current tree does not show the guests, nothing happens.
(e.g. storage view). This is IMO an ok tradeoff for this edge case.
Also if the guest vanishes in the backend before the ResourceStore could
update, it's limited to 3 tries of finding it.
www/manager6/Makefile | 1 +
www/manager6/Utils.js | 48 ++++++++++++++++++++
www/manager6/form/AfterCreateViewSelector.js | 32 +++++++++++++
www/manager6/lxc/CreateWizard.js | 28 ++++++++++--
www/manager6/qemu/CreateWizard.js | 33 ++++++++++++--
5 files changed, 136 insertions(+), 6 deletions(-)
create mode 100644 www/manager6/form/AfterCreateViewSelector.js
diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index cdf222a2..41f7d745 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -23,6 +23,7 @@ JSSRC= \
form/ACMEAPISelector.js \
form/ACMEAccountSelector.js \
form/ACMEPluginSelector.js \
+ form/AfterCreateViewSelector.js \
form/AgentFeatureSelector.js \
form/BackupCompressionSelector.js \
form/BackupModeSelector.js \
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index fc3667f5..5079726d 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -1665,6 +1665,54 @@ Ext.define('PVE.Utils', {
}
},
+ // Returns the currently selected ID in the resource tree if possible
+ getCurrentTreeSelection: function () {
+ let tree = Ext.ComponentQuery.query('pveResourceTree')[0];
+ if (!tree) {
+ return;
+ }
+ return tree.getSelection()[0]?.data.id;
+ },
+
+ // Selects a freshly created guest and opens the given tab (e.g. 'console'). Meant to be
+ // called once its creation task succeeded, but the resource store might not know the
+ // guest yet, so wait for up to two loads after that.
+ showGuestAfterCreate: function (type, vmid, tab, initialSelection) {
+ let tree = Ext.ComponentQuery.query('pveResourceTree')[0];
+ if (!tree) {
+ return;
+ }
+ let rstore = PVE.data.ResourceStore;
+ let id = `${type}/${vmid}`;
+
+ let select = function (attempt) {
+ // the user navigated away in the meantime, do not pull them back
+ if (PVE.Utils.getCurrentTreeSelection() !== initialSelection) {
+ return;
+ }
+
+ // retry on the next load if it's not in the ResourceStore yet
+ if (rstore.findExact('id', id) === -1) {
+ if (attempt < 3) {
+ rstore.on('load', select, undefined, { single: true, args: [attempt + 1] });
+ }
+ return;
+ }
+
+ if (tab) {
+ let stateId = type === 'qemu' ? 'kvmtab' : 'lxctab';
+ // lxc console tab is named differently
+ if (stateId === 'lxctab' && tab === 'console') {
+ tab = 'consolejs';
+ }
+ Ext.state.Manager.getProvider().set(stateId, { value: tab });
+ }
+ tree.selectById(id);
+ };
+
+ select(1);
+ },
+
// test automation helper
call_menu_handler: function (menu, text) {
let item = menu.query('menuitem').find((el) => el.text === text);
diff --git a/www/manager6/form/AfterCreateViewSelector.js b/www/manager6/form/AfterCreateViewSelector.js
new file mode 100644
index 00000000..1580cbb2
--- /dev/null
+++ b/www/manager6/form/AfterCreateViewSelector.js
@@ -0,0 +1,32 @@
+// Selects which view of a guest to open once the create wizard has submitted it.
+// Automatically saves the last selected value.
+Ext.define('PVE.form.AfterCreateViewSelector', {
+ extend: 'Proxmox.form.KVComboBox',
+ alias: ['widget.pveAfterCreateViewSelector'],
+
+ submitValue: false,
+ deleteEmpty: false,
+
+ fieldLabel: gettext('Then open'),
+ labelAlign: 'right',
+ width: 250,
+
+ comboItems: [
+ ['none', Proxmox.Utils.noneText],
+ ['summary', gettext('Summary')],
+ ['console', gettext('Console')],
+ ],
+
+ stateKey: 'guest-create-open-view',
+
+ initComponent: function () {
+ let me = this;
+
+ let sp = Ext.state.Manager.getProvider();
+ me.value = sp.get(me.stateKey) || 'none';
+
+ me.callParent();
+
+ me.on('change', (_field, value) => sp.set(me.stateKey, value));
+ },
+});
diff --git a/www/manager6/lxc/CreateWizard.js b/www/manager6/lxc/CreateWizard.js
index caa04fc9..757f9810 100644
--- a/www/manager6/lxc/CreateWizard.js
+++ b/www/manager6/lxc/CreateWizard.js
@@ -291,11 +291,25 @@ Ext.define('PVE.lxc.CreateWizard', {
],
dockedItems: [
{
- xtype: 'proxmoxcheckbox',
- name: 'start',
+ xtype: 'container',
dock: 'bottom',
margin: '5 0 0 0',
- boxLabel: gettext('Start after created'),
+ layout: {
+ type: 'hbox',
+ align: 'middle',
+ },
+ items: [
+ {
+ xtype: 'proxmoxcheckbox',
+ name: 'start',
+ flex: 1,
+ boxLabel: gettext('Start after created'),
+ },
+ {
+ xtype: 'pveAfterCreateViewSelector',
+ itemId: 'afterCreateView',
+ },
+ ],
},
],
listeners: {
@@ -340,15 +354,23 @@ Ext.define('PVE.lxc.CreateWizard', {
delete kv.password;
}
+ let currentId = PVE.Utils.getCurrentTreeSelection();
+
Proxmox.Utils.API2Request({
url: `/nodes/${nodename}/lxc`,
waitMsgTarget: wizard,
method: 'POST',
params: kv,
success: function (response, opts) {
+ let view = wizard.down('#afterCreateView').getValue();
Ext.create('Proxmox.window.TaskViewer', {
autoShow: true,
upid: response.result.data,
+ taskDone: (success) => {
+ if (success && view !== 'none') {
+ PVE.Utils.showGuestAfterCreate('lxc', kv.vmid, view, currentId);
+ }
+ },
});
wizard.close();
},
diff --git a/www/manager6/qemu/CreateWizard.js b/www/manager6/qemu/CreateWizard.js
index 9c6e18d3..535adab5 100644
--- a/www/manager6/qemu/CreateWizard.js
+++ b/www/manager6/qemu/CreateWizard.js
@@ -291,11 +291,25 @@ Ext.define('PVE.qemu.CreateWizard', {
],
dockedItems: [
{
- xtype: 'proxmoxcheckbox',
- name: 'start',
+ xtype: 'container',
dock: 'bottom',
margin: '5 0 0 0',
- boxLabel: gettext('Start after created'),
+ layout: {
+ type: 'hbox',
+ align: 'middle',
+ },
+ items: [
+ {
+ xtype: 'proxmoxcheckbox',
+ name: 'start',
+ flex: 1,
+ boxLabel: gettext('Start after created'),
+ },
+ {
+ xtype: 'pveAfterCreateViewSelector',
+ itemId: 'afterCreateView',
+ },
+ ],
},
],
listeners: {
@@ -350,15 +364,28 @@ Ext.define('PVE.qemu.CreateWizard', {
kv.kvm = 0;
}
+ let currentId = PVE.Utils.getCurrentTreeSelection();
+
Proxmox.Utils.API2Request({
url: '/nodes/' + nodename + '/qemu',
waitMsgTarget: wizard,
method: 'POST',
params: kv,
success: function (response) {
+ let view = wizard.down('#afterCreateView').getValue();
Ext.create('Proxmox.window.TaskProgress', {
autoShow: true,
upid: response.result.data,
+ taskDone: (success) => {
+ if (success && view !== 'none') {
+ PVE.Utils.showGuestAfterCreate(
+ 'qemu',
+ kv.vmid,
+ view,
+ currentId,
+ );
+ }
+ },
});
wizard.close();
},
--
2.47.3
prev parent reply other threads:[~2026-11-24 14:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 14:37 [PATCH/RFC pve-manager 0/2] allow to automatically open guest panel after create wizard Dominik Csapak
2026-11-24 14:37 ` [PATCH pve-manager 1/2] ui: qemu create wizard: show the task progress after submitting Dominik Csapak
2026-11-24 14:37 ` Dominik Csapak [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=20261124144207.3675423-3-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.