From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager 1/4] ui: dashboard: subscriptions: refactor subscriptions show logic
Date: Thu, 27 Nov 2025 15:03:45 +0100 [thread overview]
Message-ID: <20251127140451.3131469-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20251127140451.3131469-1-d.csapak@proxmox.com>
Instead of creating the dialog in the click callback and passing it
around, just to clone it again in the view. Simply set a boolean flag
and create the dialog in the view method if needed.
This is more in line with what we do with most dialogs and saves us a
few headaches later (since the dialog will be rendered on every `view`
call instead of just once).
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
ui/src/dashboard/view.rs | 34 +++++++++++++++-------------------
1 file changed, 15 insertions(+), 19 deletions(-)
diff --git a/ui/src/dashboard/view.rs b/ui/src/dashboard/view.rs
index 65697d38..2adcee53 100644
--- a/ui/src/dashboard/view.rs
+++ b/ui/src/dashboard/view.rs
@@ -3,7 +3,6 @@ use std::rc::Rc;
use anyhow::Error;
use futures::join;
use js_sys::Date;
-use pwt::widget::Dialog;
use serde_json::{json, Value};
use yew::virtual_dom::{VComp, VNode};
@@ -93,7 +92,7 @@ pub enum Msg {
Reload(bool), // force
ConfigWindow(bool), // show
UpdateConfig(RefreshConfig),
- ShowSubscriptionsDialog(Option<Dialog>),
+ ShowSubscriptionsDialog(bool),
LayoutUpdate(ViewLayout),
UpdateResult(Result<(), Error>),
}
@@ -109,7 +108,7 @@ struct ViewComp {
load_finished_time: Option<f64>,
show_config_window: bool,
show_create_wizard: Option<RemoteType>,
- subscriptions_dialog: Option<Dialog>,
+ subscriptions_dialog: bool,
editing_state: SharedState<Vec<EditingMessage>>,
update_result: LoadResult<(), Error>,
@@ -151,13 +150,8 @@ fn render_widget(
WidgetType::PbsDatastores => create_pbs_datastores_panel(status),
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)
- }),
+ link.clone()
+ .callback(move |_| Msg::ShowSubscriptionsDialog(true)),
),
WidgetType::Sdn => create_sdn_panel(status),
WidgetType::Leaderboard { leaderboard_type } => {
@@ -337,7 +331,7 @@ impl Component for ViewComp {
loading: true,
show_config_window: false,
show_create_wizard: None,
- subscriptions_dialog: None,
+ subscriptions_dialog: false,
editing_state: SharedState::new(Vec::new()),
update_result: LoadResult::new(),
@@ -480,13 +474,8 @@ impl Component for ViewComp {
.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)
- }),
+ link.clone()
+ .callback(move |_| Msg::ShowSubscriptionsDialog(true)),
)
.flex(1.0),
),
@@ -558,7 +547,14 @@ impl Component for ViewComp {
.on_submit(move |ctx| crate::remotes::create_remote(ctx, remote_type))
}));
- view.add_optional_child(self.subscriptions_dialog.clone());
+ view.add_optional_child(if self.subscriptions_dialog {
+ create_subscriptions_dialog(
+ self.render_args.subscriptions.clone(),
+ ctx.link().callback(|_| Msg::ShowSubscriptionsDialog(false)),
+ )
+ } else {
+ None
+ });
let view_context = ViewContext {
name: props.view.clone(),
--
2.47.3
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next prev parent reply other threads:[~2025-11-27 14:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-27 14:03 [pdm-devel] [PATCH datacenter-manager 0/4] improve subscription display in Dominik Csapak
2025-11-27 14:03 ` Dominik Csapak [this message]
2025-11-27 14:03 ` [pdm-devel] [PATCH datacenter-manager 2/4] ui: dashboard: subscriptions list: update store when data changes Dominik Csapak
2025-11-27 14:03 ` [pdm-devel] [PATCH datacenter-manager 3/4] ui: dashboard: subscriptions list: improve display of subscription state Dominik Csapak
2025-11-27 14:03 ` [pdm-devel] [PATCH datacenter-manager 4/4] ui: dashboard: subscriptions details: add a 'force refresh' button Dominik Csapak
2025-11-27 16:13 ` Michael Köppl
2025-11-27 21:10 ` Thomas Lamprecht
2025-11-27 16:13 ` [pdm-devel] [PATCH datacenter-manager 0/4] improve subscription display in Michael Köppl
2025-11-27 21:12 ` [pdm-devel] applied: " 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=20251127140451.3131469-2-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