{# Component library for the panel. Every component here is driven by an explicit context, so a template never reaches into a manager or a model. The state vocabulary is fixed and shared: "active", "idle", "failed" and "busy". Those four words are what the state rail, the badge and the notice all agree on, so an operator learns the language once and it holds on every screen. #} {% set _STATE_ALIASES = { "active": "active", "running": "active", "valid": "active", "enabled": "active", "failed": "failed", "error": "failed", "expired": "failed", "corrupt": "failed", "busy": "busy", "deploying": "busy", "renewing": "busy", "expiring": "busy", "building": "busy", "restoring": "busy" } %} {% macro state_class(state) -%} {{- _STATE_ALIASES.get(state | lower, "idle") -}} {%- endmacro %} {% macro badge(state, text=none) -%} {{ text or state }} {%- endmacro %} {# A resource row. The coloured rail on the leading edge is the whole point: running your eye down the left border of a list tells you the health of everything on it without reading a word. meta is a list of (label, value) pairs rendered in mono. Keep it to the three or four facts an operator scans for, not everything the record holds. note is one further line, for what a tool said about this record verbatim: certbot's own validity line, or a backup's description. It is not a place for commentary. state_text is the state in words. The rail is a colour, and a colour on its own is unreadable to anyone who cannot see this particular pair of hues and invisible to a screen reader. Pass it wherever the record actually has a state worth naming; where it does not, the state is still announced, just not taken up screen space with. Used with {% call %} so the caller supplies the action buttons: {% call m.row("example.com", "active", meta) %} {{ m.action_button("Restart", "/api/apps/example.com/restart") }} {% endcall %} #} {% macro row(name, state, meta=[], href=none, row_id=none, note=none, state_text=none) %}
{{ subtitle }}
{% endif %}{{ body }}
{% if action_label and action_href %} {{ action_label }} {% endif %} {% if command %}Or run {{ command }}
{{ fix }}
{% if output %}{{ output }}{% endif %}
| {{ label }} | {{ value }} |
|---|