[pdm-devel] [PATCH datacenter-manager v2 2/2] ui: remote migrate: correctly use node from selected endpoint

Dominik Csapak d.csapak at proxmox.com
Tue Jan 14 15:38:16 CET 2025


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 at 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





More information about the pdm-devel mailing list