From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id AF1831FF14F for ; Fri, 08 May 2026 17:05:49 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 91C581C6DD; Fri, 8 May 2026 17:05:49 +0200 (CEST) From: Shannon Sterz To: yew-devel@lists.proxmox.com Subject: [PATCH yew-mobile-gui 04/20] tree-wide: collapse if statements Date: Fri, 8 May 2026 17:05:19 +0200 Message-ID: <20260508150535.420205-5-s.sterz@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260508150535.420205-1-s.sterz@proxmox.com> References: <20260508150535.420205-1-s.sterz@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1778252629548 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.117 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: HSFUPPYCAJOS2SUHRD55HD754CZPLTLN X-Message-ID-Hash: HSFUPPYCAJOS2SUHRD55HD754CZPLTLN X-MailFrom: s.sterz@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Yew framework devel list at Proxmox List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: fixes the clippy lint "clippy::collapsible_if" [1]. [1]: https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_if Signed-off-by: Shannon Sterz --- src/main.rs | 11 ++-- src/pages/page_dashboard.rs | 14 ++-- src/pages/page_lxc_status/dashboard_panel.rs | 62 +++++++++--------- src/pages/page_qemu_status/dashboard_panel.rs | 64 +++++++++---------- src/pages/page_resources.rs | 16 ++--- 5 files changed, 80 insertions(+), 87 deletions(-) diff --git a/src/main.rs b/src/main.rs index 77991fd..2a91379 100644 --- a/src/main.rs +++ b/src/main.rs @@ -313,12 +313,11 @@ impl Component for PveMobileApp { fn create(ctx: &Context) -> Self { let mut server_config = None; - if let Some(window) = web_sys::window() { - if let Ok(value) = js_sys::Reflect::get(&window, &JsValue::from_str("Proxmox")) { - if let Ok(config) = JsValueSerdeExt::into_serde::(&value) { - server_config = Some(config); - } - } + if let Some(window) = web_sys::window() + && let Ok(value) = js_sys::Reflect::get(&window, &JsValue::from_str("Proxmox")) + && let Ok(config) = JsValueSerdeExt::into_serde::(&value) + { + server_config = Some(config); } // set auth info from cookie diff --git a/src/pages/page_dashboard.rs b/src/pages/page_dashboard.rs index f33f182..211d66d 100644 --- a/src/pages/page_dashboard.rs +++ b/src/pages/page_dashboard.rs @@ -472,13 +472,13 @@ impl Component for PvePageDashboard { let alert = CACHE.with_borrow(|cache| { let mut alert = None; - if let Some(status) = &cache.subscription_error { - if self.show_subscription_alert || !cache.subscription_confirmed { - alert = Some( - SubscriptionAlert::new(status.clone()) - .on_close(ctx.link().callback(|_| Msg::ConfirmSubscription)), - ); - } + if let Some(status) = &cache.subscription_error + && (self.show_subscription_alert || !cache.subscription_confirmed) + { + alert = Some( + SubscriptionAlert::new(status.clone()) + .on_close(ctx.link().callback(|_| Msg::ConfirmSubscription)), + ); } alert }); diff --git a/src/pages/page_lxc_status/dashboard_panel.rs b/src/pages/page_lxc_status/dashboard_panel.rs index 91afd24..8009dcc 100644 --- a/src/pages/page_lxc_status/dashboard_panel.rs +++ b/src/pages/page_lxc_status/dashboard_panel.rs @@ -144,42 +144,38 @@ impl PveLxcDashboardPanel { data.status.to_string(), )); - if let Some(Ok(data)) = &self.data { - if data.status == IsRunning::Running { - if let (Some(cpu), Some(maxcpu)) = (data.cpu, data.cpus) { - let cpu_percentage = if maxcpu == 0.0 { - 0.0 - } else { - (cpu as f32) / (maxcpu as f32) - }; + if let Some(Ok(data)) = &self.data + && data.status == IsRunning::Running + { + if let (Some(cpu), Some(maxcpu)) = (data.cpu, data.cpus) { + let cpu_percentage = if maxcpu == 0.0 { + 0.0 + } else { + (cpu as f32) / (maxcpu as f32) + }; - tiles.push( - icon_list_tile(Fa::new("cpu"), "CPU", None::<&str>, ()).with_child( - list_tile_usage( - format!("{:.2}", cpu), - maxcpu.to_string(), - cpu_percentage, - ), - ), - ); - } + tiles.push( + icon_list_tile(Fa::new("cpu"), "CPU", None::<&str>, ()).with_child( + list_tile_usage(format!("{:.2}", cpu), maxcpu.to_string(), cpu_percentage), + ), + ); + } - if let (Some(mem), Some(maxmem)) = (data.mem, data.maxmem) { - let mem_percentage = if maxmem <= 0 { - 0.0 - } else { - (mem as f32) / (maxmem as f32) - }; - tiles.push( - icon_list_tile(Fa::new("memory"), "Memory", (), ()).with_child( - list_tile_usage( - HumanByte::new_binary(mem as f64).to_string(), - HumanByte::new_binary(maxmem as f64).to_string(), - mem_percentage, - ), + if let (Some(mem), Some(maxmem)) = (data.mem, data.maxmem) { + let mem_percentage = if maxmem <= 0 { + 0.0 + } else { + (mem as f32) / (maxmem as f32) + }; + tiles.push( + icon_list_tile(Fa::new("memory"), "Memory", (), ()).with_child( + list_tile_usage( + HumanByte::new_binary(mem as f64).to_string(), + HumanByte::new_binary(maxmem as f64).to_string(), + mem_percentage, ), - ); - } + ), + ); } } diff --git a/src/pages/page_qemu_status/dashboard_panel.rs b/src/pages/page_qemu_status/dashboard_panel.rs index 63669e0..3120046 100644 --- a/src/pages/page_qemu_status/dashboard_panel.rs +++ b/src/pages/page_qemu_status/dashboard_panel.rs @@ -153,42 +153,40 @@ impl PveQemuDashboardPanel { data.qmpstatus.clone().unwrap_or(data.status.to_string()), )); - if let Some(Ok(data)) = &self.data { - if data.status == IsRunning::Running { - if let (Some(cpu), Some(maxcpu)) = (data.cpu, data.cpus) { - let cpu_percentage = if maxcpu == 0.0 { - 0.0 - } else { - (cpu as f32) / (maxcpu as f32) - }; + if let Some(Ok(data)) = &self.data + && data.status == IsRunning::Running + { + if let (Some(cpu), Some(maxcpu)) = (data.cpu, data.cpus) { + let cpu_percentage = if maxcpu == 0.0 { + 0.0 + } else { + (cpu as f32) / (maxcpu as f32) + }; - tiles.push( - icon_list_tile(Fa::new("cpu"), tr!("CPU"), (), ()).with_child( - list_tile_usage( - format!("{:.2}", cpu), - maxcpu.to_string(), - cpu_percentage, - ), - ), - ); - } + tiles.push( + icon_list_tile(Fa::new("cpu"), tr!("CPU"), (), ()).with_child(list_tile_usage( + format!("{:.2}", cpu), + maxcpu.to_string(), + cpu_percentage, + )), + ); + } - if let (Some(mem), Some(maxmem)) = (data.mem, data.maxmem) { - let mem_percentage = if maxmem <= 0 { - 0.0 - } else { - (mem as f32) / (maxmem as f32) - }; - tiles.push( - icon_list_tile(Fa::new("memory"), tr!("Memory"), (), ()).with_child( - list_tile_usage( - HumanByte::new_binary(mem as f64).to_string(), - HumanByte::new_binary(maxmem as f64).to_string(), - mem_percentage, - ), + if let (Some(mem), Some(maxmem)) = (data.mem, data.maxmem) { + let mem_percentage = if maxmem <= 0 { + 0.0 + } else { + (mem as f32) / (maxmem as f32) + }; + tiles.push( + icon_list_tile(Fa::new("memory"), tr!("Memory"), (), ()).with_child( + list_tile_usage( + HumanByte::new_binary(mem as f64).to_string(), + HumanByte::new_binary(maxmem as f64).to_string(), + mem_percentage, ), - ); - } + ), + ); } } diff --git a/src/pages/page_resources.rs b/src/pages/page_resources.rs index 7302229..2d41e35 100644 --- a/src/pages/page_resources.rs +++ b/src/pages/page_resources.rs @@ -72,10 +72,10 @@ fn filter_match(item: &ClusterResource, filter: &ResourceFilter) -> bool { if item.id.to_lowercase().contains(&filter.name) { return true; } - if let Some(name) = &item.name { - if name.contains(&filter.name) { - return true; - } + if let Some(name) = &item.name + && name.contains(&filter.name) + { + return true; } false } else { @@ -360,10 +360,10 @@ impl Component for PvePageResources { let mut filter: PersistentState = PersistentState::new("pve-resource-filter"); - if let Some(location) = ctx.link().location() { - if let Some(state) = location.state::() { - filter.update(state.as_ref().clone()); - } + if let Some(location) = ctx.link().location() + && let Some(state) = location.state::() + { + filter.update(state.as_ref().clone()); } Self { -- 2.47.3