* [PATCH datacenter-manager] ui: snapshots: use constructor instead of custom `From` implementation
@ 2026-05-26 9:31 Dominik Csapak
2026-05-26 9:50 ` applied: " Lukas Wagner
0 siblings, 1 reply; 2+ messages in thread
From: Dominik Csapak @ 2026-05-26 9:31 UTC (permalink / raw)
To: pdm-devel
having it return a dialog when a specific property is set instead of an
embedded list is better done via a custom constructor. This way we don't
have to passthrough the properties of the dialog we need, we save the
extra property to differentiate, and the logic is not hidden inside the
`From` implementation.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
ui/src/guests.rs | 2 +-
ui/src/pve/lxc/mod.rs | 1 -
ui/src/pve/qemu/mod.rs | 1 -
ui/src/widget/snapshot_window.rs | 42 +++++++++-----------------------
4 files changed, 13 insertions(+), 33 deletions(-)
diff --git a/ui/src/guests.rs b/ui/src/guests.rs
index decfffa9..c49eaff5 100644
--- a/ui/src/guests.rs
+++ b/ui/src/guests.rs
@@ -575,7 +575,7 @@ impl LoadableComponent for GuestPanelComp {
.into(),
),
ViewState::Snapshots(remote, guest_info) => Some(
- SnapshotWindow::new(remote.clone(), *guest_info)
+ SnapshotWindow::dialog(remote.clone(), *guest_info)
.on_close(ctx.link().change_view_callback(|_| None))
.into(),
),
diff --git a/ui/src/pve/lxc/mod.rs b/ui/src/pve/lxc/mod.rs
index a0ce86aa..4569a5ee 100644
--- a/ui/src/pve/lxc/mod.rs
+++ b/ui/src/pve/lxc/mod.rs
@@ -182,7 +182,6 @@ impl yew::Component for LxcPanelComp {
vmid,
},
)
- .embedded(true)
.into()
}
},
diff --git a/ui/src/pve/qemu/mod.rs b/ui/src/pve/qemu/mod.rs
index 1d2ffa7c..b1a5c15d 100644
--- a/ui/src/pve/qemu/mod.rs
+++ b/ui/src/pve/qemu/mod.rs
@@ -162,7 +162,6 @@ impl yew::Component for QemuPanelComp {
vmid,
},
)
- .embedded(true)
.into()
}
},
diff --git a/ui/src/widget/snapshot_window.rs b/ui/src/widget/snapshot_window.rs
index 4630759b..7e22ed79 100644
--- a/ui/src/widget/snapshot_window.rs
+++ b/ui/src/widget/snapshot_window.rs
@@ -11,9 +11,8 @@ use std::rc::Rc;
use anyhow::{bail, Error};
use serde_json::json;
-use yew::html::IntoEventCallback;
use yew::virtual_dom::{Key, VComp, VNode};
-use yew::{Callback, Properties};
+use yew::Properties;
use proxmox_client::ApiResponseData;
use proxmox_yew_comp::{
@@ -139,16 +138,6 @@ pub struct SnapshotWindow {
/// Which guest to manage snapshots for.
pub guest_info: GuestInfo,
-
- /// Render the list inline (for embedding as a tab) instead of as a modal dialog.
- #[prop_or_default]
- #[builder]
- pub embedded: bool,
-
- /// Close callback (only used in modal mode).
- #[prop_or_default]
- #[builder_cb(IntoEventCallback, into_event_callback, ())]
- pub on_close: Option<Callback<()>>,
}
impl SnapshotWindow {
@@ -158,31 +147,24 @@ impl SnapshotWindow {
guest_info,
})
}
-}
-impl From<SnapshotWindow> for VNode {
- fn from(val: SnapshotWindow) -> Self {
- let embedded = val.embedded;
- let on_close = val.on_close.clone();
- let title = tr!("Snapshots - {0}", val.guest_info.vmid);
-
- // The master renders a Column/page (toolbar + table + dialogs), not a dialog. Embedded as
- // a detail-panel tab it is dropped in inline; as a standalone window it is wrapped in a
- // Dialog that carries the title and the close callback.
- let master: VNode =
- VComp::new::<LoadableComponentMaster<PdmSnapshotWindow>>(Rc::new(val), None).into();
- if embedded {
- return master;
- }
+ /// Returns the snapshot component within a dialog
+ pub fn dialog(remote: impl Into<AttrValue>, guest_info: GuestInfo) -> Dialog {
+ let title = tr!("Snapshots - {0}", guest_info.vmid);
+ let snapshot_comp = Self::new(remote, guest_info);
Dialog::new(title)
.min_width(720)
.min_height(440)
.max_height("90vh")
.resizable(true)
- .on_close(on_close)
- .with_child(master)
- .into()
+ .with_child(snapshot_comp)
+ }
+}
+
+impl From<SnapshotWindow> for VNode {
+ fn from(val: SnapshotWindow) -> Self {
+ VComp::new::<LoadableComponentMaster<PdmSnapshotWindow>>(Rc::new(val), None).into()
}
}
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* applied: [PATCH datacenter-manager] ui: snapshots: use constructor instead of custom `From` implementation
2026-05-26 9:31 [PATCH datacenter-manager] ui: snapshots: use constructor instead of custom `From` implementation Dominik Csapak
@ 2026-05-26 9:50 ` Lukas Wagner
0 siblings, 0 replies; 2+ messages in thread
From: Lukas Wagner @ 2026-05-26 9:50 UTC (permalink / raw)
To: Dominik Csapak, pdm-devel
On Tue May 26, 2026 at 11:31 AM CEST, Dominik Csapak wrote:
> having it return a dialog when a specific property is set instead of an
> embedded list is better done via a custom constructor. This way we don't
> have to passthrough the properties of the dialog we need, we save the
> extra property to differentiate, and the logic is not hidden inside the
> `From` implementation.
>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
applied, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-26 9:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-26 9:31 [PATCH datacenter-manager] ui: snapshots: use constructor instead of custom `From` implementation Dominik Csapak
2026-05-26 9:50 ` applied: " Lukas Wagner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox