From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 879CE1FF15C for ; Fri, 14 Nov 2025 19:13:31 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E76CA19636; Fri, 14 Nov 2025 19:13:30 +0100 (CET) From: Shan Shaji To: pdm-devel@lists.proxmox.com Date: Fri, 14 Nov 2025 19:12:42 +0100 Message-ID: <20251114181242.423922-1-s.shaji@proxmox.com> X-Mailer: git-send-email 2.47.3 MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1763143969948 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.118 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [view.rs, proxmox.com] Subject: [pdm-devel] [PATCH datacenter-manager] fix: add details button to show subscriptions dialog X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" When clicking on the (www.proxmox.com) url on the subscriptions panel the url will open and also the dialog window at the same time. Inorder to fix the issue add a "Details" button on the subscriptions panel. Now the dialog will only be shown when the "Details" button is clicked. Signed-off-by: Shan Shaji --- ui/src/dashboard/subscription_info.rs | 79 +++++++++++---------------- ui/src/dashboard/view.rs | 39 +++++++++++-- 2 files changed, 66 insertions(+), 52 deletions(-) diff --git a/ui/src/dashboard/subscription_info.rs b/ui/src/dashboard/subscription_info.rs index a420601..fed2b2c 100644 --- a/ui/src/dashboard/subscription_info.rs +++ b/ui/src/dashboard/subscription_info.rs @@ -2,14 +2,13 @@ use std::rc::Rc; use anyhow::Error; use yew::{ - html, virtual_dom::{VComp, VNode}, Component, Html, Properties, }; use proxmox_yew_comp::Status; use pwt::prelude::*; -use pwt::widget::{Column, Container, Dialog, Fa, Panel, Row}; +use pwt::widget::{Button, Column, Container, Dialog, Fa, Panel, Row}; use pwt::{ css::{AlignItems, FlexFit, JustifyContent, TextAlign}, state::SharedState, @@ -30,13 +29,7 @@ impl SubscriptionInfo { } } -enum Msg { - ShowDialog(Option), -} - -struct PdmSubscriptionInfo { - dialog: Option, -} +struct PdmSubscriptionInfo; fn render_subscription_status(subs: &[RemoteSubscriptions]) -> Row { let mut none = 0; @@ -103,49 +96,19 @@ fn render_subscription_status(subs: &[RemoteSubscriptions]) -> Row { } impl Component for PdmSubscriptionInfo { - type Message = Msg; + type Message = (); type Properties = SubscriptionInfo; fn create(_ctx: &yew::Context) -> Self { - Self { dialog: None } - } - - fn update(&mut self, _: &Context, msg: Self::Message) -> bool { - match msg { - Msg::ShowDialog(dialog) => { - self.dialog = dialog; - true - } - } + Self {} } fn view(&self, ctx: &yew::Context) -> yew::Html { let props = ctx.props(); - - let mut column = Column::new() + Column::new() .class(FlexFit) .class(JustifyContent::Center) - .class(AlignItems::Center); - - if let Some(subs) = props.subs.as_ref() { - let dialog = Dialog::new(tr!("Your Subscriptions")) - .resizable(true) - .width(500) - .height(400) - .min_width(200) - .min_height(50) - .with_child(SubscriptionsList::new(subs.clone())) - .on_close(ctx.link().callback(|_| Msg::ShowDialog(None))); - - column = column - .onclick( - ctx.link() - .callback(move |_| Msg::ShowDialog(Some(dialog.clone()))), - ) - .style("cursor", "pointer"); - } - - column + .class(AlignItems::Center) .with_optional_child( props.subs.is_none().then_some( Container::new() @@ -159,7 +122,6 @@ impl Component for PdmSubscriptionInfo { .as_ref() .map(|subs| render_subscription_status(subs)), ) - .with_optional_child(self.dialog.clone()) .into() } } @@ -171,8 +133,27 @@ impl From for VNode { } } +pub fn create_subscriptions_dialog( + subs: SharedState, Error>>, + on_dialog_close: Callback<()>, +) -> Option { + if let Some(subs) = subs.read().data.clone() { + let dialog = Dialog::new(tr!("Your Subscriptions")) + .resizable(true) + .width(500) + .height(400) + .min_width(200) + .min_height(50) + .with_child(SubscriptionsList::new(subs.clone())) + .on_close(on_dialog_close); + return Some(dialog); + } + None +} + pub fn create_subscription_panel( subs: SharedState, Error>>, + on_details_clicked: Callback, ) -> Panel { let title: Html = Row::new() .class(AlignItems::Center) @@ -181,8 +162,14 @@ pub fn create_subscription_panel( .with_child(tr!("Subscription Status")) .into(); - Panel::new() + let mut panel = Panel::new() .title(title) .border(true) - .with_child(SubscriptionInfo::new(subs.read().data.clone())) + .with_child(SubscriptionInfo::new(subs.read().data.clone())); + + if subs.read().data.is_some() { + panel.add_tool(Button::new(tr!("Details")).onclick(on_details_clicked)); + } + + panel } diff --git a/ui/src/dashboard/view.rs b/ui/src/dashboard/view.rs index 28fb015..5ddf5ff 100644 --- a/ui/src/dashboard/view.rs +++ b/ui/src/dashboard/view.rs @@ -3,6 +3,7 @@ use std::rc::Rc; use anyhow::Error; use futures::join; use js_sys::Date; +use pwt::widget::Dialog; use serde_json::json; use yew::virtual_dom::{VComp, VNode}; @@ -18,6 +19,7 @@ use crate::dashboard::refresh_config_edit::{ refresh_config_id, RefreshConfig, DEFAULT_MAX_AGE_S, DEFAULT_REFRESH_INTERVAL_S, FORCE_RELOAD_MAX_AGE_S, INITIAL_MAX_AGE_S, }; +use crate::dashboard::subscription_info::create_subscriptions_dialog; use crate::dashboard::tasks::get_task_options; use crate::dashboard::types::RowWidget; use crate::dashboard::types::{TaskSummaryGrouping, ViewLayout, ViewTemplate, WidgetType}; @@ -72,6 +74,7 @@ pub enum Msg { Reload(bool), // force ConfigWindow(bool), // show UpdateConfig(RefreshConfig), + ShowSubscriptionsDialog(Option), } struct ViewComp { @@ -90,6 +93,7 @@ struct ViewComp { load_finished_time: Option, show_config_window: bool, show_create_wizard: Option, + subscriptions_dialog: Option, } fn render_widget( @@ -110,7 +114,16 @@ fn render_widget( show_wizard.then_some(link.callback(|_| Msg::CreateWizard(Some(RemoteType::Pbs)))), ), WidgetType::PbsDatastores => create_pbs_datastores_panel(status), - WidgetType::Subscription => create_subscription_panel(subscriptions), + WidgetType::Subscription => create_subscription_panel( + subscriptions.clone(), + link.clone().callback(move |_| { + let dialog = create_subscriptions_dialog( + subscriptions.clone(), + link.callback(|_| Msg::ShowSubscriptionsDialog(None)), + ); + Msg::ShowSubscriptionsDialog(dialog) + }), + ), WidgetType::Sdn => create_sdn_panel(status), WidgetType::Leaderboard { leaderboard_type } => { create_top_entities_panel(top_entities, *leaderboard_type) @@ -269,6 +282,7 @@ impl Component for ViewComp { loading: true, show_config_window: false, show_create_wizard: None, + subscriptions_dialog: None, } } @@ -324,6 +338,9 @@ impl Component for ViewComp { self.show_config_window = false; } + Msg::ShowSubscriptionsDialog(dialog) => { + self.subscriptions_dialog = dialog; + } } true } @@ -356,11 +373,18 @@ impl Component for ViewComp { )), ); if !has_sub_panel(self.template.data.as_ref()) { - view.add_child( - Row::new() - .class("pwt-content-spacer") - .with_child(create_subscription_panel(self.subscriptions.clone())), - ); + let subs = self.subscriptions.clone(); + let link = ctx.link().clone(); + view.add_child(Row::new().class("pwt-content-spacer").with_child( + create_subscription_panel( + subs.clone(), + link.clone().callback(move |_| { + let on_dialog_close = link.callback(|_| Msg::ShowSubscriptionsDialog(None)); + let dialog = create_subscriptions_dialog(subs.clone(), on_dialog_close); + Msg::ShowSubscriptionsDialog(dialog) + }), + ), + )); } match self.template.data.as_ref().map(|template| &template.layout) { Some(ViewLayout::Rows { rows }) => { @@ -421,6 +445,9 @@ impl Component for ViewComp { .on_close(ctx.link().callback(|_| Msg::CreateWizard(None))) .on_submit(move |ctx| crate::remotes::create_remote(ctx, remote_type)) })); + + view.add_optional_child(self.subscriptions_dialog.clone()); + view.into() } } -- 2.47.3 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel