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 854F91FF16E
	for <inbox@lore.proxmox.com>; Mon, 20 Jan 2025 10:30:42 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 258D1161EE;
	Mon, 20 Jan 2025 10:30:41 +0100 (CET)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pdm-devel@lists.proxmox.com
Date: Mon, 20 Jan 2025 10:29:55 +0100
Message-Id: <20250120093006.927014-6-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.39.5
In-Reply-To: <20250120093006.927014-1-d.csapak@proxmox.com>
References: <20250120093006.927014-1-d.csapak@proxmox.com>
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.017 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
Subject: [pdm-devel] [PATCH yew-comp 5/7] running tasks: make buttons
 configurable
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>

we sometimes want different buttons here (e.g. on PDM we want two)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/running_tasks.rs        | 37 +++++++++++++++++++++++++------------
 src/running_tasks_button.rs |  8 +++++++-
 2 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/src/running_tasks.rs b/src/running_tasks.rs
index b0b63af..c5cea4c 100644
--- a/src/running_tasks.rs
+++ b/src/running_tasks.rs
@@ -1,6 +1,6 @@
 use std::rc::Rc;
 
-use yew::html::IntoEventCallback;
+use yew::html::{IntoEventCallback, IntoPropValue};
 use yew::virtual_dom::{VComp, VNode};
 
 use pwt::prelude::*;
@@ -35,6 +35,11 @@ pub struct RunningTasks {
     #[builder]
     #[prop_or_default]
     pub as_dropdown: bool,
+
+    #[builder(IntoPropValue, into_prop_value)]
+    #[prop_or_default]
+    /// Custom Buttons instead of the default 'Show all' one.
+    pub buttons: Option<Vec<Button>>,
 }
 
 impl RunningTasks {
@@ -167,17 +172,25 @@ impl Component for ProxmoxRunningTasks {
         });
 
         let toolbar = props.as_dropdown.then(|| {
-            Toolbar::new().with_flex_spacer().with_child({
-                let on_close = props.on_close.clone();
-                Button::new(tr!("Show All Tasks"))
-                    .class("pwt-scheme-primary")
-                    .onclick(move |_| {
-                        crate::utils::set_location_href("#/administration/tasks");
-                        if let Some(on_close) = &on_close {
-                            on_close.emit(());
-                        }
-                    })
-            })
+            if let Some(buttons) = props.buttons.clone() {
+                let mut tb = Toolbar::new().with_flex_spacer();
+                for button in buttons {
+                    tb.add_child(button);
+                }
+                tb
+            } else {
+                Toolbar::new().with_flex_spacer().with_child({
+                    let on_close = props.on_close.clone();
+                    Button::new(tr!("Show All Tasks"))
+                        .class("pwt-scheme-primary")
+                        .onclick(move |_| {
+                            crate::utils::set_location_href("#/administration/tasks");
+                            if let Some(on_close) = &on_close {
+                                on_close.emit(());
+                            }
+                        })
+                })
+            }
         });
 
         Panel::new()
diff --git a/src/running_tasks_button.rs b/src/running_tasks_button.rs
index e0e1062..331c006 100644
--- a/src/running_tasks_button.rs
+++ b/src/running_tasks_button.rs
@@ -3,7 +3,7 @@ use std::rc::Rc;
 use gloo_timers::callback::Timeout;
 use pwt::css::ColorScheme;
 use wasm_bindgen::JsCast;
-use yew::html::IntoEventCallback;
+use yew::html::{IntoEventCallback, IntoPropValue};
 use yew::virtual_dom::{VComp, VNode};
 
 use pwt::dom::align::{align_to, AlignOptions, GrowDirection, Point};
@@ -30,6 +30,11 @@ pub struct RunningTasksButton {
     #[prop_or_default]
     /// Render function for the [`TaskListItem`]
     pub render: Option<RenderFn<TaskListItem>>,
+
+    #[builder(IntoPropValue, into_prop_value)]
+    #[prop_or_default]
+    /// Custom Buttons instead of the default 'Show all' one.
+    pub buttons: Option<Vec<Button>>,
 }
 
 impl RunningTasksButton {
@@ -156,6 +161,7 @@ impl Component for ProxmoxRunningTasksButton {
                 .node_ref(self.submenu_ref.clone())
                 .with_child(
                     RunningTasks::new(props.running_tasks.clone())
+                        .buttons(props.buttons.clone())
                         .as_dropdown(true)
                         .on_show_task(props.on_show_task.clone())
                         .render(props.render.clone())
-- 
2.39.5



_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel