From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager v2 2/2] ui: remote migrate: correctly use node from selected endpoint
Date: Tue, 14 Jan 2025 15:38:16 +0100 [thread overview]
Message-ID: <20250114143816.3297378-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20250114143816.3297378-1-d.csapak@proxmox.com>
for network selector and detailed mapping too, not only for the target
storage selector.
Change the 'node' property to an option, so it's consistent across the
components.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
changes from v1:
* also give the node to the network selector in the detail mapping
* don't use 'localhost' as default value in the detail mapping directly,
just pass through the option and let the network/storage selector
handle that themselves.
ui/src/widget/migrate_window.rs | 4 +++-
ui/src/widget/pve_migrate_mapping.rs | 10 +++++++---
ui/src/widget/pve_network_selector.rs | 6 +++---
3 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/ui/src/widget/migrate_window.rs b/ui/src/widget/migrate_window.rs
index 7214ff4..559d04c 100644
--- a/ui/src/widget/migrate_window.rs
+++ b/ui/src/widget/migrate_window.rs
@@ -457,7 +457,7 @@ impl PdmMigrateWindow {
PveStorageSelector::new(target_remote.clone())
.key(format!("storage-{target_remote}"))
.name("target_storage")
- .node(target_node)
+ .node(target_node.clone())
.disabled(!show_target_storage)
.autoselect(!same_remote)
.content_types(content_types.clone())
@@ -471,6 +471,7 @@ impl PdmMigrateWindow {
PveNetworkSelector::new(target_remote.clone())
.key(format!("network-{target_remote}"))
.name("target_network")
+ .node(target_node.clone())
.disabled(detail_mode)
.required(!detail_mode),
);
@@ -481,6 +482,7 @@ impl PdmMigrateWindow {
PveMigrateMap::new(target_remote, guest_info)
.content_types(content_types)
.name("detail-map")
+ .node(target_node)
.submit(detail_mode)
.required(detail_mode),
);
diff --git a/ui/src/widget/pve_migrate_mapping.rs b/ui/src/widget/pve_migrate_mapping.rs
index b8ab3f9..79d15cf 100644
--- a/ui/src/widget/pve_migrate_mapping.rs
+++ b/ui/src/widget/pve_migrate_mapping.rs
@@ -81,8 +81,8 @@ pub struct PveMigrateMap {
/// The node to query
#[builder(IntoPropValue, into_prop_value)]
- #[prop_or(AttrValue::from("localhost"))]
- pub node: AttrValue,
+ #[prop_or_default]
+ pub node: Option<AttrValue>,
/// The target node for the storage
#[builder(IntoPropValue, into_prop_value)]
@@ -350,7 +350,8 @@ fn columns(
ctx: &ManagedFieldContext<'_, PveMigrateMapComp>,
remote: AttrValue,
) -> Rc<Vec<DataTableHeader<MapEntry>>> {
- let content_types = ctx.props().content_types.clone();
+ let props = ctx.props();
+ let content_types = props.content_types.clone();
Rc::new(vec![
DataTableColumn::new(tr!("Type"))
.get_property(|entry: &MapEntry| &entry.map_type)
@@ -366,10 +367,12 @@ fn columns(
.flex(2)
.render({
let link = ctx.link();
+ let node = props.node.clone();
move |entry: &MapEntry| match entry.map_type {
MapType::Storage => PveStorageSelector::new(remote.clone())
.content_types(content_types.clone())
.default(entry.target.clone())
+ .node(node.clone())
.on_change({
let link = link.clone();
let entry = entry.clone();
@@ -383,6 +386,7 @@ fn columns(
.into(),
MapType::Network => PveNetworkSelector::new(remote.clone())
.default(entry.target.clone())
+ .node(node.clone())
.on_change({
let link = link.clone();
let entry = entry.clone();
diff --git a/ui/src/widget/pve_network_selector.rs b/ui/src/widget/pve_network_selector.rs
index 1fcaed7..fddbf9c 100644
--- a/ui/src/widget/pve_network_selector.rs
+++ b/ui/src/widget/pve_network_selector.rs
@@ -44,8 +44,8 @@ pub struct PveNetworkSelector {
/// The node to select the network from
#[builder(IntoPropValue, into_prop_value)]
- #[prop_or(AttrValue::from("localhost"))]
- pub node: AttrValue,
+ #[prop_or_default]
+ pub node: Option<AttrValue>,
/// The interface types to list
#[builder(IntoPropValue, into_prop_value)]
@@ -82,7 +82,7 @@ impl PveNetworkSelectorComp {
fn create_load_callback(ctx: &yew::Context<Self>) -> LoadCallback<Vec<NetworkInterface>> {
let props = ctx.props();
let remote = props.remote.clone();
- let node = props.node.clone();
+ let node = props.node.clone().unwrap_or(AttrValue::from("localhost"));
let ty = props.interface_type;
(move || Self::get_network_list(remote.clone(), node.clone(), ty)).into()
--
2.39.5
_______________________________________________
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-01-14 14:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-14 14:38 [pdm-devel] [PATCH datacenter-manager v2 1/2] ui: improve foreach_drive_* functions Dominik Csapak
2025-01-14 14:38 ` Dominik Csapak [this message]
2025-01-15 9:39 ` [pdm-devel] applied: " Dietmar Maurer
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=20250114143816.3297378-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