[pdm-devel] [PATCH proxmox-yew-comp 1/1] task list: add support for starting refresh tasks
Lukas Wagner
l.wagner at proxmox.com
Tue Dec 16 14:15:13 CET 2025
PDM has an API endpoint to trigger remote task fetching. By adding
the 'refresh_task_url' property to the task list implementation in
`Tasks`, we now allow starting this refresh task manually when pressing
the 'Refresh' button.
Signed-off-by: Lukas Wagner <l.wagner at proxmox.com>
---
src/tasks.rs | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/tasks.rs b/src/tasks.rs
index ece8f2e..f4c5026 100644
--- a/src/tasks.rs
+++ b/src/tasks.rs
@@ -62,6 +62,13 @@ pub struct Tasks {
#[builder(IntoPropValue, into_prop_value)]
pub base_url: Option<AttrValue>,
+ /// If set, clicking the 'refresh' button will POST the provided URL to start
+ /// a task which refreshes the underlying task storage. Once the task finishes,
+ /// the view automatically refreshes and shows the latest tasks.
+ #[prop_or_default]
+ #[builder(IntoPropValue, into_prop_value)]
+ pub refresh_task_url: Option<AttrValue>,
+
#[builder_cb(IntoEventCallback, into_event_callback, (String, Option<i64>))]
#[prop_or_default]
/// Called when the task is opened
@@ -103,6 +110,7 @@ pub enum ViewDialog {
pub enum Msg {
ToggleFilter,
LoadBatch(bool), // fresh load
+ RefreshClicked,
LoadFinished,
UpdateFilter,
ShowTask,
@@ -337,6 +345,16 @@ impl LoadableComponent for ProxmoxTasks {
self.fresh_load = false;
false
}
+ Msg::RefreshClicked => {
+ let link = ctx.link().clone();
+ if let Some(url) = &ctx.props().refresh_task_url {
+ link.start_task(url.to_string(), None, true);
+ } else {
+ link.send_message(Msg::LoadBatch(true));
+ }
+
+ false
+ }
Msg::ShowTask => {
if let Some(on_show_task) = &ctx.props().on_show_task {
let selected_item = self
@@ -394,7 +412,7 @@ impl LoadableComponent for ProxmoxTasks {
.with_child({
let loading = self.loading();
let link = ctx.link().clone();
- Button::refresh(loading).onclick(move |_| link.send_message(Msg::LoadBatch(true)))
+ Button::refresh(loading).onclick(move |_| link.send_message(Msg::RefreshClicked))
});
let filter_classes = classes!(
--
2.47.3
More information about the pdm-devel
mailing list