public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [PATCH datacenter-manager 1/2] ui: pve: tree: add 'Open Shell' action to node rows
Date: Mon, 30 Nov 2026 14:43:02 +0100	[thread overview]
Message-ID: <20261130134311.2843926-1-d.csapak@proxmox.com> (raw)

so users can open the shell of a node in its own browser window, like
the console of a guest, instead of only in the 'Shell' tab of the node
panel.

The action is only shown if the user has 'Sys.Console' on the node and
the pve-manager version of the node is new enough, like for the 'Shell'
tab. It is always enabled then. If the shell cannot be opened, e.g.
because the node is offline, the shell window itself shows the reason.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 ui/src/pve/tree.rs  | 38 ++++++++++++++++++++++++++++++++++++--
 ui/src/pve/utils.rs |  6 ++++++
 2 files changed, 42 insertions(+), 2 deletions(-)

diff --git a/ui/src/pve/tree.rs b/ui/src/pve/tree.rs
index 3c0b533d..2c3ffac3 100644
--- a/ui/src/pve/tree.rs
+++ b/ui/src/pve/tree.rs
@@ -28,7 +28,7 @@ use pwt::widget::{
 use pwt::{prelude::*, widget::Button};
 
 use pdm_api_types::{
-    RemoteUpid,
+    PRIV_SYS_CONSOLE, RemoteUpid,
     resource::{AsResourceView, PveNodeResource, PveResource, Resource},
 };
 use pdm_search::SearchTerm;
@@ -43,7 +43,10 @@ use crate::{
     widget::{BulkActionWindow, MigrateWindow, bulk_action_disabled_reason},
 };
 
-use super::{ConfirmGuestAction, GuestInfo, GuestRowActions, PowerAction, PowerActionExt, utils};
+use super::{
+    ConfirmGuestAction, GuestInfo, GuestRowActions, PowerAction, PowerActionExt, action_tooltip,
+    utils,
+};
 
 #[derive(Clone, PartialEq)]
 pub enum PveTreeNode {
@@ -856,9 +859,19 @@ fn columns(
                         .on_activate(open_pve_ui(&link, &remote, node, local_id)),
                 )
                 .tip(tr!("Open in PVE UI"));
+                let open_shell = match entry {
+                    // a placeholder for a node that the remote did not list has no name
+                    PveTreeNode::Resource(PveResource::Node(node)) if !node.node.is_empty() => {
+                        let version = pve_manager_versions.get(&node.node);
+                        open_shell_action(&acl, &remote, &node.node, version)
+                    }
+                    _ => None,
+                };
 
                 Row::new()
                     .class(JustifyContent::FlexEnd)
+                    // in front, so that the other icons stay in line with those of the other rows
+                    .with_optional_child(open_shell)
                     .with_child(open_pve_ui)
                     .with_optional_child(match entry {
                         PveTreeNode::Root if !querying => {
@@ -907,6 +920,27 @@ fn columns(
     ])
 }
 
+/// The row action that opens a shell on `node` in its own window, if the user has `Sys.Console`
+/// and the pve-manager version of the node is new enough.
+fn open_shell_action(
+    acl: &AclContext,
+    remote: &str,
+    node: &str,
+    pve_manager_version: Option<&Version>,
+) -> Option<Tooltip> {
+    let may_open = acl.check_privs(&["resource", remote, "node", node], PRIV_SYS_CONSOLE);
+    let blocked = utils::console_unavailable_reason(may_open, pve_manager_version, node);
+    blocked.is_none().then(|| {
+        let (remote, node) = (remote.to_string(), node.to_string());
+        action_tooltip(
+            ActionIcon::new("fa fa-terminal")
+                .on_activate(move |_| utils::open_node_shell(&remote, &node)),
+            tr!("Open Shell"),
+            None,
+        )
+    })
+}
+
 /// A callback that opens the resource in the web interface of the remote, in a new tab. It also
 /// closes the menu of a right click on a guest, which the other actions replace with a dialog.
 fn open_pve_ui<IN>(
diff --git a/ui/src/pve/utils.rs b/ui/src/pve/utils.rs
index 91cc03b0..17d9b34c 100644
--- a/ui/src/pve/utils.rs
+++ b/ui/src/pve/utils.rs
@@ -328,6 +328,12 @@ pub(crate) fn open_guest_console(remote: &str, node: &str, guest: GuestInfo, nov
     XTermJs::open_xterm_js_viewer(console_type, node, use_vnc);
 }
 
+/// Opens a login shell on `node` of `remote` in its own browser window.
+pub(crate) fn open_node_shell(remote: &str, node: &str) {
+    let console_type = ConsoleType::RemotePveLoginShell(remote.to_string());
+    XTermJs::open_xterm_js_viewer(console_type, node, false);
+}
+
 /// Returns `console`, or why it cannot be shown if the user lacks `Sys.Console` or `node` runs a
 /// version of Proxmox VE that is too old for it. An unknown version counts as new enough.
 pub(crate) fn render_console(
-- 
2.47.3





             reply	other threads:[~2026-11-30 13:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 13:43 Dominik Csapak [this message]
2026-11-30 13:43 ` [PATCH datacenter-manager 2/2] docs: web ui: describe the 'Open Shell' action of node rows Dominik Csapak
2026-11-30 20:15 ` applied: [PATCH datacenter-manager 1/2] ui: pve: tree: add 'Open Shell' action to " 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=20261130134311.2843926-1-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pdm-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