| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
use std::fmt; |
| 19 |
|
| 20 |
use makeover_layout::Tone; |
| 21 |
use quasi_router::screen::Act; |
| 22 |
use quasi_router::{Action, Node}; |
| 23 |
|
| 24 |
|
| 25 |
#[must_use] |
| 26 |
pub fn html(key_id: impl fmt::Display) -> String { |
| 27 |
use quasi_axum::Serves as _; |
| 28 |
|
| 29 |
let act = Act::new( |
| 30 |
"Revoke", |
| 31 |
Action::post(format!("/api/keys/{key_id}/revoke")).replacing("license-keys-list"), |
| 32 |
) |
| 33 |
.tone(Tone::Danger) |
| 34 |
.confirm("Revoke this license key? All activations will be deactivated."); |
| 35 |
|
| 36 |
quasi_webview::Webview::new().fragment(&Node::Act(act)) |
| 37 |
} |
| 38 |
|
| 39 |
#[cfg(test)] |
| 40 |
mod tests { |
| 41 |
#[test] |
| 42 |
fn a_revoke_names_its_route_its_region_and_its_prompt() { |
| 43 |
let html = super::html("k1"); |
| 44 |
|
| 45 |
assert!(html.contains(r#"hx-post="/api/keys/k1/revoke""#), "{html}"); |
| 46 |
assert!( |
| 47 |
html.contains(r##"hx-target="#license-keys-list""##), |
| 48 |
"{html}" |
| 49 |
); |
| 50 |
assert!( |
| 51 |
html.contains( |
| 52 |
r#"hx-confirm="Revoke this license key? All activations will be deactivated.""# |
| 53 |
), |
| 54 |
"{html}" |
| 55 |
); |
| 56 |
} |
| 57 |
|
| 58 |
#[test] |
| 59 |
fn a_revoke_says_it_is_dangerous() { |
| 60 |
assert!(super::html("k1").contains(r#"data-tone="danger""#)); |
| 61 |
} |
| 62 |
} |
| 63 |
|