Initial commit
This commit is contained in:
commit
5cda7bc309
28 changed files with 1173 additions and 0 deletions
30
yksa_kit/states.py
Normal file
30
yksa_kit/states.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
"""Domain status -> UI state name.
|
||||
|
||||
Lives here rather than in yksa-web-kit because it is a property of the data, not
|
||||
of the presentation: a model exposes ``ui_state`` and the template renders it.
|
||||
The visual vocabulary — which icon and word each state gets — is the web kit's
|
||||
half, in ``yksa_web.states``.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
#: Every service's RunStatus-like TextChoices overlaps by value, so one table
|
||||
#: covers them all.
|
||||
_HEALTH = {
|
||||
"ok": "ok",
|
||||
"success": "ok",
|
||||
"partial": "warning",
|
||||
"warning": "warning",
|
||||
"failed": "failed",
|
||||
"error": "failed",
|
||||
"running": "running",
|
||||
"pending": "running",
|
||||
"queued": "running",
|
||||
"skipped": "skipped",
|
||||
}
|
||||
|
||||
|
||||
def health_state(value: str | None) -> str:
|
||||
"""A value absent from the table renders as ``unknown`` rather than blank —
|
||||
a status the reader can see beats one that silently disappears."""
|
||||
return _HEALTH.get((value or "").lower(), "unknown")
|
||||
Loading…
Add table
Add a link
Reference in a new issue