public inbox for yew-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Shannon Sterz <s.sterz@proxmox.com>
To: yew-devel@lists.proxmox.com
Subject: [PATCH yew-mobile-gui v2 04/21] tree-wide: collapse if statements
Date: Fri,  8 May 2026 17:57:05 +0200	[thread overview]
Message-ID: <20260508155722.464564-5-s.sterz@proxmox.com> (raw)
In-Reply-To: <20260508155722.464564-1-s.sterz@proxmox.com>

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 <s.sterz@proxmox.com>
---
 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>) -> 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::<ServerConfig>(&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::<ServerConfig>(&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<ResourceFilter> =
             PersistentState::new("pve-resource-filter");
 
-        if let Some(location) = ctx.link().location() {
-            if let Some(state) = location.state::<ResourceFilter>() {
-                filter.update(state.as_ref().clone());
-            }
+        if let Some(location) = ctx.link().location()
+            && let Some(state) = location.state::<ResourceFilter>()
+        {
+            filter.update(state.as_ref().clone());
         }
 
         Self {
-- 
2.47.3





  parent reply	other threads:[~2026-05-08 15:58 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08 15:57 [PATCH yew-comp/yew-mobile-gui v2 00/21] firewall tabs and clean up for pve-yew-mobile-gui Shannon Sterz
2026-05-08 15:57 ` [PATCH yew-comp v2 01/21] firewall rules panel: correct the url for the pve cluster firewall rules Shannon Sterz
2026-05-08 15:57 ` [PATCH yew-mobile-gui v2 02/21] cargo.toml: globally ignore certain clippy lints Shannon Sterz
2026-05-08 15:57 ` [PATCH yew-mobile-gui v2 03/21] main: avoid unnecessary clones Shannon Sterz
2026-05-08 15:57 ` Shannon Sterz [this message]
2026-05-08 15:57 ` [PATCH yew-mobile-gui v2 05/21] tree-wide: implement the `From` trait instead of the `Into` trait Shannon Sterz
2026-05-08 15:57 ` [PATCH yew-mobile-gui v2 06/21] tree-wide: implement `Default` for types with an `new()` constructor Shannon Sterz
2026-05-08 15:57 ` [PATCH yew-mobile-gui v2 07/21] tree-wide: remove unnecessary lazy evaluations Shannon Sterz
2026-05-08 15:57 ` [PATCH yew-mobile-gui v2 08/21] tree-wide: remove needless borrows Shannon Sterz
2026-05-08 15:57 ` [PATCH yew-mobile-gui v2 09/21] configuration page: remove redundant static lifetimes Shannon Sterz
2026-05-08 15:57 ` [PATCH yew-mobile-gui v2 10/21] resources/configuration page: remove useless `.into()` calls Shannon Sterz
2026-05-08 15:57 ` [PATCH yew-mobile-gui v2 11/21] tree-wide: fix several clippy lints Shannon Sterz
2026-05-08 15:57 ` [PATCH yew-mobile-gui v2 12/21] dashboard: use proper plural translation string instead of "CPU(s)" Shannon Sterz
2026-05-08 16:11   ` Shan Shaji
2026-05-08 16:13   ` Shannon Sterz
2026-05-08 15:57 ` [PATCH yew-mobile-gui v2 13/21] configuration: clarify that "Firewall" shows the cluster's firewall Shannon Sterz
2026-05-08 15:57 ` [PATCH yew-mobile-gui v2 14/21] cluster/qemu firewall: use rules panel and comment out unused tabs Shannon Sterz
2026-05-08 15:57 ` [PATCH yew-mobile-gui v2 15/21] qemu status page: align icons better with tabs Shannon Sterz
2026-05-08 15:57 ` [PATCH yew-mobile-gui v2 16/21] lxc page: align layout for lxc guest with qemu guests Shannon Sterz
2026-05-08 15:57 ` [PATCH yew-mobile-gui v2 17/21] lxc: add support for a rudimentary firewall tab for lxc guests Shannon Sterz
2026-05-08 15:57 ` [PATCH yew-mobile-gui v2 18/21] node status: align layout for node status with guest pages Shannon Sterz
2026-05-08 15:57 ` [PATCH yew-mobile-gui v2 19/21] node: add a rudimentary firewall tab for cluster nodes Shannon Sterz
2026-05-08 15:57 ` [PATCH yew-mobile-gui v2 20/21] api types: remove unused file Shannon Sterz
2026-05-08 15:57 ` [PATCH yew-mobile-gui v2 21/21] resources page: map subscription level analogous to dashboard Shannon Sterz

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=20260508155722.464564-5-s.sterz@proxmox.com \
    --to=s.sterz@proxmox.com \
    --cc=yew-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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal