| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
use std::fmt; |
| 33 |
|
| 34 |
use makeover_layout::Tone; |
| 35 |
use quasi_router::screen::Act; |
| 36 |
use quasi_router::{Action, Node}; |
| 37 |
|
| 38 |
|
| 39 |
#[must_use] |
| 40 |
pub fn html(link_id: impl fmt::Display) -> String { |
| 41 |
use quasi_axum::Serves as _; |
| 42 |
|
| 43 |
let act = Act::new( |
| 44 |
"Remove", |
| 45 |
Action::delete(format!("/api/links/{link_id}")).replacing_enclosing(), |
| 46 |
) |
| 47 |
.tone(Tone::Danger) |
| 48 |
.confirm("Remove this link?"); |
| 49 |
|
| 50 |
quasi_webview::Webview::new().fragment(&Node::Act(act)) |
| 51 |
} |
| 52 |
|
| 53 |
#[cfg(test)] |
| 54 |
mod tests { |
| 55 |
|
| 56 |
#[test] |
| 57 |
fn a_removal_names_its_route_its_row_and_its_prompt() { |
| 58 |
let html = super::html("l3"); |
| 59 |
|
| 60 |
assert!(html.contains(r#"hx-delete="/api/links/l3""#), "{html}"); |
| 61 |
assert!(html.contains(r#"hx-target="closest [data-row]""#), "{html}"); |
| 62 |
assert!(html.contains(r#"hx-confirm="Remove this link?""#), "{html}"); |
| 63 |
assert!(!html.contains(".link-row"), "{html}"); |
| 64 |
} |
| 65 |
|
| 66 |
#[test] |
| 67 |
fn a_removal_says_it_is_dangerous() { |
| 68 |
assert!(super::html("l3").contains(r#"data-tone="danger""#)); |
| 69 |
} |
| 70 |
} |
| 71 |
|