all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pdm-devel] [PATCH yew-comp v2 1/1] apt package manager: add property for custom subscription alert message
@ 2025-12-03 12:50 Dominik Csapak
  2025-12-03 12:50 ` [pdm-devel] [PATCH datacenter-manager v2 1/1] ui: pdm update panel: show correct subscription notice message Dominik Csapak
  0 siblings, 1 reply; 3+ messages in thread
From: Dominik Csapak @ 2025-12-03 12:50 UTC (permalink / raw)
  To: pdm-devel

If given, will show an alert dialog with those instead of the default
subscription alert dialog.

In the long term, having both url+title/message in some kind of struct
like EditableProperty would be nicer, but this should be fine for now.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
no changes from v1
 src/apt_package_manager.rs | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/src/apt_package_manager.rs b/src/apt_package_manager.rs
index b419957..82d536f 100644
--- a/src/apt_package_manager.rs
+++ b/src/apt_package_manager.rs
@@ -17,7 +17,7 @@ use pwt::state::{Selection, SlabTree, TreeStore};
 use pwt::widget::data_table::{
     DataTable, DataTableCellRenderArgs, DataTableColumn, DataTableHeader, DataTableHeaderGroup,
 };
-use pwt::widget::{Button, Container, Toolbar, Tooltip};
+use pwt::widget::{AlertDialog, Button, Container, Toolbar, Tooltip};
 use pwt::AsyncPool;
 
 use crate::percent_encoding::percent_encode_component;
@@ -61,10 +61,16 @@ pub struct AptPackageManager {
     #[builder_cb(IntoEventCallback, into_event_callback, ())]
     pub on_upgrade: Option<Callback<()>>,
 
+    // todo refactor url+message into a struct like EditableProperty
     #[prop_or_default]
     #[builder(IntoPropValue, into_prop_value)]
     /// The base url for the subscription check
     pub subscription_url: Option<AttrValue>,
+
+    #[prop_or_default]
+    #[builder(IntoPropValue, into_prop_value)]
+    /// Custom subscription dialog title and message
+    pub subscription_message: Option<(String, Html)>,
 }
 
 impl Default for AptPackageManager {
@@ -321,15 +327,19 @@ impl LoadableComponent for ProxmoxAptPackageManager {
                 let props = ctx.props();
                 let task_base_url = props.task_base_url.clone();
                 let command = format!("{}/update", props.base_url);
-                Some(
-                    SubscriptionAlert::new("notfound")
-                        .on_close(move |_| {
-                            link.change_view(None);
-                            link.task_base_url(task_base_url.clone());
-                            link.start_task(&command, None, false);
-                        })
-                        .into(),
-                )
+                let on_close = move |_| {
+                    link.change_view(None);
+                    link.task_base_url(task_base_url.clone());
+                    link.start_task(&command, None, false);
+                };
+                Some(if let Some(msg) = props.subscription_message.clone() {
+                    AlertDialog::new(msg.1)
+                        .title(msg.0)
+                        .on_close(on_close)
+                        .into()
+                } else {
+                    SubscriptionAlert::new("notfound").on_close(on_close).into()
+                })
             }
         }
     }
-- 
2.47.3



_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pdm-devel] [PATCH datacenter-manager v2 1/1] ui: pdm update panel: show correct subscription notice message
  2025-12-03 12:50 [pdm-devel] [PATCH yew-comp v2 1/1] apt package manager: add property for custom subscription alert message Dominik Csapak
@ 2025-12-03 12:50 ` Dominik Csapak
  2025-12-03 14:04   ` Thomas Lamprecht
  0 siblings, 1 reply; 3+ messages in thread
From: Dominik Csapak @ 2025-12-03 12:50 UTC (permalink / raw)
  To: pdm-devel

instead of the default one that does not fit for pdm hosts.

For that, refactor the message + title generation into its own function,
so we can reuse it for the generic alert dialog as well.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
change from v1:
* rebase on master
 ui/src/administration/mod.rs |  5 ++++-
 ui/src/lib.rs                | 12 +++++++++---
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/ui/src/administration/mod.rs b/ui/src/administration/mod.rs
index 9e45a425..760cc90b 100644
--- a/ui/src/administration/mod.rs
+++ b/ui/src/administration/mod.rs
@@ -20,6 +20,8 @@ mod node_status;
 
 use proxmox_yew_comp::{AptPackageManager, AptRepositories, ExistingProduct, Syslog, Tasks};
 
+use crate::pdm_subscription_title_and_message;
+
 #[derive(Clone, PartialEq, Properties)]
 #[builder]
 pub struct ServerAdministration {
@@ -88,7 +90,8 @@ impl Component for PdmServerAdministration {
                         .with_child(
                             AptPackageManager::new()
                                 .enable_upgrade(enable_upgrade)
-                                .subscription_url("/nodes/localhost/subscription"),
+                                .subscription_url("/nodes/localhost/subscription")
+                                .subscription_message(pdm_subscription_title_and_message()),
                         )
                         .into()
                 },
diff --git a/ui/src/lib.rs b/ui/src/lib.rs
index 5ca0461c..1aac7571 100644
--- a/ui/src/lib.rs
+++ b/ui/src/lib.rs
@@ -269,6 +269,14 @@ pub async fn check_pdm_subscription() -> bool {
 /// i.e., one that's not just relayed 1:1 to a specific remote node, as for that one should use the
 /// remote-specific alert.
 pub fn pdm_subscription_alert(on_close: impl IntoEventCallback<()>) -> AlertDialog {
+    let (title, msg) = pdm_subscription_title_and_message();
+    AlertDialog::new(Container::from_tag("p").with_child(msg))
+        .title(title)
+        .on_close(on_close)
+}
+
+/// returns the PDM specific title and message for the subscription alert
+pub fn pdm_subscription_title_and_message() -> (String, Html) {
     let dest =
         "<a target=\"_blank\" href=\"https://pdm.proxmox.com/docs/faq.html\">pdm.proxmox.com</a>"
             .to_string();
@@ -278,9 +286,7 @@ pub fn pdm_subscription_alert(on_close: impl IntoEventCallback<()>) -> AlertDial
         dest
     );
     let msg = Html::from_html_unchecked(msg.into());
-    AlertDialog::new(Container::from_tag("p").with_child(msg))
-        .title(tr!("No valid subscriptions"))
-        .on_close(on_close)
+    (tr!("No valid subscriptions"), msg)
 }
 
 /// Extract the version of a specific package from `RemoteUpdateSummary` for a specific node
-- 
2.47.3



_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pdm-devel] [PATCH datacenter-manager v2 1/1] ui: pdm update panel: show correct subscription notice message
  2025-12-03 12:50 ` [pdm-devel] [PATCH datacenter-manager v2 1/1] ui: pdm update panel: show correct subscription notice message Dominik Csapak
@ 2025-12-03 14:04   ` Thomas Lamprecht
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2025-12-03 14:04 UTC (permalink / raw)
  To: pdm-devel, Dominik Csapak

On Wed, 03 Dec 2025 13:50:45 +0100, Dominik Csapak wrote:
> instead of the default one that does not fit for pdm hosts.
> 
> For that, refactor the message + title generation into its own function,
> so we can reuse it for the generic alert dialog as well.
> 
> 

Applied, thanks!

[1/1] ui: pdm update panel: show correct subscription notice message
      commit: e13b383c438f5470eebf32949a99a40cf8a04abf


_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-12-03 14:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-03 12:50 [pdm-devel] [PATCH yew-comp v2 1/1] apt package manager: add property for custom subscription alert message Dominik Csapak
2025-12-03 12:50 ` [pdm-devel] [PATCH datacenter-manager v2 1/1] ui: pdm update panel: show correct subscription notice message Dominik Csapak
2025-12-03 14:04   ` Thomas Lamprecht

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.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal