From 62e9609fe8da6c5edee840e8c90de8077f9dcf11 Mon Sep 17 00:00:00 2001 From: mathieu Date: Sat, 16 May 2026 02:45:33 +0200 Subject: [PATCH] feat(hosts): add delete confirmation modal on hosts list page Replace the direct dispatch on the Delete button with a pending_delete signal (id + name). A DeleteHostModal identical to the one in host detail opens for confirmation before the action is dispatched. The modal closes automatically after a successful deletion. Co-Authored-By: Claude Sonnet 4.6 --- src/client/hosts.rs | 67 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/src/client/hosts.rs b/src/client/hosts.rs index 00b2e5a..5cc8494 100644 --- a/src/client/hosts.rs +++ b/src/client/hosts.rs @@ -27,6 +27,47 @@ const PER_PAGE_OPTIONS: &[(i64, &str)] = &[ (0, "All"), ]; +// ─── Delete host modal ──────────────────────────────────────────────────────── + +#[component] +fn DeleteHostModal( + host_name: String, + host_id: i64, + delete_action: ServerAction, + pending_delete: RwSignal>, +) -> impl IntoView { + view! { + + }.into_any() +} + // ─── Add host modal ─────────────────────────────────────────────────────────── #[component] @@ -247,7 +288,7 @@ fn PaginationBar( #[component] fn HostTable( hosts: Resource>, - delete_action: ServerAction, + pending_delete: RwSignal>, ) -> impl IntoView { view! { "Loading hosts…"

}> @@ -276,6 +317,7 @@ fn HostTable( {rows.into_iter().map(|host| { let id = host.id; + let delete_name = host.name.clone(); view! { @@ -293,7 +335,7 @@ fn HostTable( {host.application_count} @@ -319,6 +361,16 @@ pub fn HostsPage() -> impl IntoView { let show_modal = RwSignal::new(false); + // None = no modal, Some((id, name)) = delete confirmation open. + let pending_delete: RwSignal> = RwSignal::new(None); + + // Close the delete modal automatically after a successful deletion. + Effect::new(move |_| { + if let Some(Ok(_)) = delete_action.value().get() { + pending_delete.set(None); + } + }); + // Filter signals ("" / 0 = no filter) let name_filter = RwSignal::new(String::new()); let network_id_filter = RwSignal::new(0i64); @@ -369,6 +421,15 @@ pub fn HostsPage() -> impl IntoView { /> })} + {move || pending_delete.get().map(|(host_id, host_name)| view! { + + })} + impl IntoView { - + }.into_any()