Fix source actions and toggle regressions
This commit is contained in:
parent
94717b1d1b
commit
2a99edeec3
5 changed files with 122 additions and 5 deletions
|
|
@ -54,6 +54,29 @@ def _checked(source: Mapping[str, object] | None, key: str, default: bool) -> bo
|
|||
return bool(value)
|
||||
|
||||
|
||||
def _action_button(
|
||||
*,
|
||||
label: str,
|
||||
tone: str = "default",
|
||||
post_path: str | None = None,
|
||||
) -> Renderable:
|
||||
classes = {
|
||||
"default": "bg-stone-100 text-slate-700 hover:bg-stone-200",
|
||||
"danger": "bg-rose-50 text-rose-700 hover:bg-rose-100",
|
||||
}
|
||||
attributes: dict[str, str] = {}
|
||||
if post_path is not None:
|
||||
attributes["data-on:pointerdown"] = f"@post('{post_path}')"
|
||||
return h.button(
|
||||
attributes,
|
||||
type="button",
|
||||
class_=(
|
||||
"inline-flex items-center whitespace-nowrap rounded-full px-3 py-1.5 "
|
||||
f"text-sm font-semibold transition {classes[tone]}"
|
||||
),
|
||||
)[label]
|
||||
|
||||
|
||||
def _source_row(source: Mapping[str, object]) -> tuple[Node, ...]:
|
||||
return (
|
||||
h.div[
|
||||
|
|
@ -81,6 +104,11 @@ def _source_row(source: Mapping[str, object]) -> tuple[Node, ...]:
|
|||
href=f"/sources/{source['slug']}/edit", label="Edit", tone="amber"
|
||||
),
|
||||
inline_link(href="/runs", label="View runs"),
|
||||
_action_button(
|
||||
label="Delete",
|
||||
tone="danger",
|
||||
post_path=f"/actions/sources/{source['slug']}/delete",
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue