From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pdm-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id 58F2C1FF15E
	for <inbox@lore.proxmox.com>; Tue, 14 Jan 2025 15:39:08 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 8B72F185EC;
	Tue, 14 Jan 2025 15:38:50 +0100 (CET)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Date: Tue, 14 Jan 2025 15:38:16 +0100
Message-Id: <20250114143816.3297378-2-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.39.5
In-Reply-To: <20250114143816.3297378-1-d.csapak@proxmox.com>
References: <20250114143816.3297378-1-d.csapak@proxmox.com>
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.014 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
Subject: [pdm-devel] [PATCH datacenter-manager v2 2/2] ui: remote migrate:
 correctly use node from selected endpoint
X-BeenThere: pdm-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Datacenter Manager development discussion
 <pdm-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pdm-devel>, 
 <mailto:pdm-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pdm-devel/>
List-Post: <mailto:pdm-devel@lists.proxmox.com>
List-Help: <mailto:pdm-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel>, 
 <mailto:pdm-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox Datacenter Manager development discussion
 <pdm-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pdm-devel-bounces@lists.proxmox.com
Sender: "pdm-devel" <pdm-devel-bounces@lists.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