all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pdm-devel] [PATCH yew-comp 1/1] apt package manager: add property for custom subscription alert message
@ 2025-12-03 12:18 Dominik Csapak
  2025-12-03 12:18 ` [pdm-devel] [PATCH datacenter-manager 1/1] ui: pdm update panel: show correct subscription notice message Dominik Csapak
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dominik Csapak @ 2025-12-03 12:18 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>
---
 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] 4+ messages in thread

* [pdm-devel] [PATCH datacenter-manager 1/1] ui: pdm update panel: show correct subscription notice message
  2025-12-03 12:18 [pdm-devel] [PATCH yew-comp 1/1] apt package manager: add property for custom subscription alert message Dominik Csapak
@ 2025-12-03 12:18 ` Dominik Csapak
  2025-12-03 12:51 ` [pdm-devel] superseded: [PATCH yew-comp 1/1] apt package manager: add property for custom subscription alert message Dominik Csapak
  2025-12-03 12:51 ` [pdm-devel] " Thomas Lamprecht
  2 siblings, 0 replies; 4+ messages in thread
From: Dominik Csapak @ 2025-12-03 12:18 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>
---
 ui/src/administration/mod.rs |  5 ++++-
 ui/src/lib.rs                | 17 ++++++++++++-----
 2 files changed, 16 insertions(+), 6 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 b7f1c1e3..0ad0e7a6 100644
--- a/ui/src/lib.rs
+++ b/ui/src/lib.rs
@@ -260,17 +260,24 @@ pub async fn check_subscription() -> bool {
 
 /// Returns a an [`AlertDialog`] for the 'no valid subscription' popup.
 pub fn subscription_alert(on_close: impl IntoEventCallback<()>) -> AlertDialog {
-    let dest = "<a target=\"_blank\" href=\"https://pdm.proxmox.com/docs/faq.html\">pdm.proxmox.com</a>"
-        .to_string();
+    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();
 
     let msg = tr!(
         "Too many remote nodes without active basic or higher subscription. Please visit {0} for more details.",
         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] 4+ messages in thread

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

both patches superseded by v2:
https://lore.proxmox.com/pdm-devel/20251203125056.2821841-1-d.csapak@proxmox.com/T/#t


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


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

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

On Wed, 03 Dec 2025 13:18:18 +0100, Dominik Csapak wrote:
> 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.
> 
> 
> [...]

Applied, thanks!

[1/1] apt package manager: add property for custom subscription alert message
      commit: 70448ed5e24928c7046cb0f2beed40f4eb337ea2


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


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

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

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-03 12:18 [pdm-devel] [PATCH yew-comp 1/1] apt package manager: add property for custom subscription alert message Dominik Csapak
2025-12-03 12:18 ` [pdm-devel] [PATCH datacenter-manager 1/1] ui: pdm update panel: show correct subscription notice message Dominik Csapak
2025-12-03 12:51 ` [pdm-devel] superseded: [PATCH yew-comp 1/1] apt package manager: add property for custom subscription alert message Dominik Csapak
2025-12-03 12:51 ` [pdm-devel] " 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