38 lines
1.7 KiB
Python
38 lines
1.7 KiB
Python
"""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")),
|
|
}
|