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 1/3] api: factor out read_pwt_version and pwt_base_dir
Date: Wed, 23 Sep 2026 13:35:01 +0200	[thread overview]
Message-ID: <20260923113757.2202858-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20260923113757.2202858-1-d.csapak@proxmox.com>

Getting the pwt version will be useful in other places later, so factor
it out into API2Tools.

While at it, change it to use 'PVE::File' and handle missing pwt file by
providing the default '' (to avoid a perl warning in that case).

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 PVE/API2Tools.pm        | 12 ++++++++++++
 PVE/Service/pveproxy.pm |  6 +++---
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/PVE/API2Tools.pm b/PVE/API2Tools.pm
index bca21aa5..63d50fd5 100644
--- a/PVE/API2Tools.pm
+++ b/PVE/API2Tools.pm
@@ -11,6 +11,7 @@ use URI;
 
 use PVE::Cluster;
 use PVE::DataCenterConfig; # so we can cfs-read datacenter.cfg
+use PVE::File;
 use PVE::Exception qw(raise_param_exc);
 use PVE::INotify;
 use PVE::RPCEnvironment;
@@ -272,4 +273,15 @@ sub get_resource_pool_guest_members {
     return $pool_members;
 }
 
+sub pwt_base_dir {
+    return '/usr/share/javascript/proxmox-widget-toolkit';
+}
+
+sub read_pwt_version {
+    my $base_dir = pwt_base_dir();
+    my $wtversionraw = PVE::File::file_read_first_line("$base_dir/proxmoxlib.js") // '';
+    my $wtversion = $wtversionraw =~ m|^// (.*)$| ? $1 : '';
+    return $wtversion;
+}
+
 1;
diff --git a/PVE/Service/pveproxy.pm b/PVE/Service/pveproxy.pm
index dfdd014c..9ff0770b 100755
--- a/PVE/Service/pveproxy.pm
+++ b/PVE/Service/pveproxy.pm
@@ -11,6 +11,7 @@ use URI::QueryParam;
 use URI;
 
 use PVE::API2;
+use PVE::API2Tools;
 use PVE::APIServer::AnyEvent;
 use PVE::APIServer::Formatter::HTML;
 use PVE::APIServer::Formatter::Standard;
@@ -56,7 +57,7 @@ my $basedirs = {
     novnc => '/usr/share/novnc-pve',
     yew_mobile => '/usr/share/pve-yew-mobile-gui',
     i18n_yew => '/usr/share/pve-yew-mobile-i18n',
-    widgettoolkit => '/usr/share/javascript/proxmox-widget-toolkit',
+    widgettoolkit => PVE::API2Tools::pwt_base_dir(),
     xtermjs => '/usr/share/pve-xtermjs',
 };
 
@@ -254,8 +255,7 @@ sub get_index {
 
     my $version = PVE::pvecfg::version();
 
-    my $wtversionraw = PVE::Tools::file_read_firstline("$basedirs->{widgettoolkit}/proxmoxlib.js");
-    my $wtversion = $wtversionraw =~ m|^// (.*)$| ? $1 : '';
+    my $wtversion = PVE::API2Tools::read_pwt_version();
 
     # while we could use the actual pkg version (e.g., shipped as pkg-version file in each
     # respective package's /usr/share/<pkg> folder, this way it should also work when using make
-- 
2.47.3





  reply	other threads:[~2026-09-23 11:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23 11:35 [PATCH manager 0/3] ui: prompt users for reload when web ui version changes Dominik Csapak
2026-09-23 11:35 ` Dominik Csapak [this message]
2026-09-23 11:35 ` [PATCH manager 2/3] api: provide GUI versions via index and /cluster/resources Dominik Csapak
2026-09-23 11:35 ` [PATCH manager 3/3] ui: workspace: prompt user for reload when UI packages were updated Dominik Csapak

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=20260923113757.2202858-2-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