Initial commit
This commit is contained in:
commit
97e799fd52
61 changed files with 2252 additions and 0 deletions
38
yksa_web/states.py
Normal file
38
yksa_web/states.py
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
"""The UI state vocabulary. One table, mapped once, used by ui/_state.html.
|
||||
|
||||
Two vocabularies, because there are two things being described:
|
||||
|
||||
* **health** -- how a machine process ended (a source run, an export, a decode).
|
||||
* **progress** -- how far a work item has got (a plan, a stage, a step).
|
||||
|
||||
Do not describe one object with both. See ../../../ui-kit.md section 2.1.
|
||||
|
||||
Mapping a *domain* status onto one of these names is the model's business, not the
|
||||
template's: ``yksa_kit.states.health_state``.
|
||||
|
||||
This exists because the alternative -- a `{% if %}` colour chain per template --
|
||||
drifts: the same run status rendered green on one page and grey on another, and
|
||||
readers had no way to tell whether that meant anything.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
#: state -> (Bootstrap semantic name, Bootstrap Icons name, default label).
|
||||
#: The template turns the semantic name into --bs-<name>-bg-subtle and
|
||||
#: --bs-<name>-text-emphasis, so the tint is contrast-checked and themes.
|
||||
STATES: dict[str, tuple[str, str, object]] = {
|
||||
# health
|
||||
"running": ("primary", "arrow-repeat", _("running")),
|
||||
"ok": ("success", "check-lg", _("ok")),
|
||||
"warning": ("warning", "exclamation-triangle", _("warning")),
|
||||
"failed": ("danger", "x-lg", _("failed")),
|
||||
"skipped": ("secondary", "dash", _("skipped")),
|
||||
"unknown": ("secondary", "question", _("unknown")),
|
||||
# progress
|
||||
"not-started": ("secondary", "circle", _("not started")),
|
||||
"in-progress": ("primary", "record-circle", _("in progress")),
|
||||
"complete": ("success", "check-circle-fill", _("complete")),
|
||||
"forced": ("warning", "exclamation-triangle-fill", _("forced")),
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue