feat(statuspage): show the open incident's status next to its component #146

Merged
Sebi merged 1 commits from feat/component-incident-status into main 2026-11-24 06:11:35 +00:00
4 changed files with 190 additions and 146 deletions

No files matched your search

+16
View File
@@ -275,6 +275,22 @@ func (s PageSnapshot) IncidentsForComponent(componentName string) []PageIncident
return out
}
// OpenIncidentStatus returns the newest unresolved incident of
// componentName the organization gave a status, if any.
func (s PageSnapshot) OpenIncidentStatus(componentName string) (PageIncident, bool) {
var found PageIncident
ok := false
for _, inc := range s.Incidents {
if inc.Component != componentName || inc.ResolvedAt != nil || inc.Status == "" {
continue
}
if !ok || inc.StartedAt.After(found.StartedAt) {
found, ok = inc, true
}
}
return found, ok
}
// MaintenanceForComponent splits planned maintenance affecting componentName
// into ongoing and upcoming occurrences at now.
func (s PageSnapshot) MaintenanceForComponent(componentName string, now time.Time) (ongoing, upcoming []PageMaintenance) {
+4
View File
@@ -390,6 +390,10 @@ func TestNestedGroupsAndComponentDetails(t *testing.T) {
if !strings.Contains(body, "Warten auf Anbieter") || !strings.Contains(body, "background-color:#7c3aed") {
t.Error("the own status lacks its name or color")
}
// The component list names the status of the newest open incident.
if i, j := strings.Index(body, "Beobachtung"), strings.Index(body, "Letzte Vorfälle"); i < 0 || i > j {
t.Error("the component list lacks the status of the open incident")
}
// Recent incidents come before planned maintenance.
if i, j := strings.Index(body, "Letzte Vorfälle"), strings.Index(body, "Geplante Wartung"); i < 0 || j < 0 || i > j {
t.Errorf("incidents at %d, planned maintenance at %d: want incidents first", i, j)
+9 -3
View File
@@ -138,10 +138,10 @@ templ publicComponentList(comps []agentapi.Component, s agentapi.PageSnapshot, a
<li class="py-3">
if href := ComponentHref(a.ComponentBase, comp, s.ShowDetails); href != "" {
<a href={ templ.SafeURL(href) } class="block rounded-sm transition hover:bg-rule/30">
@publicComponentBody(comp, true)
@publicComponentBody(comp, s, true)
</a>
} else {
@publicComponentBody(comp, false)
@publicComponentBody(comp, s, false)
if s.ShowDetails && comp.Details != nil {
<details class="mt-2 border-t border-rule pt-2 text-xs">
<summary class="cursor-pointer text-muted hover:text-ink">{ i18n.T(ctx, "page.details_expand") }</summary>
@@ -160,11 +160,17 @@ templ publicComponentList(comps []agentapi.Component, s agentapi.PageSnapshot, a
}
}
templ publicComponentBody(comp agentapi.Component, clickable bool) {
templ publicComponentBody(comp agentapi.Component, s agentapi.PageSnapshot, clickable bool) {
<div class="mb-2 flex items-center gap-2.5">
@statusDot(PageStatus(comp.Status))
<span class={ templ.KV("underline-offset-2 hover:underline", clickable) }>{ comp.Name }</span>
<span class="ml-auto flex items-center gap-2 text-sm text-muted">
if inc, ok := s.OpenIncidentStatus(comp.Name); ok {
<span class="text-xs">
@incidentStatusLabel(IncidentStatusInfo{Key: inc.Status, Name: inc.StatusName, Color: inc.StatusColor}, true)
</span>
<span aria-hidden="true">·</span>
}
<span>{ i18n.T(ctx, "page.component."+comp.Status) }</span>
if clickable {
<span aria-hidden="true" class="text-xs">→</span>
File diff suppressed because it is too large. Load diff