diff --git a/internal/agentapi/pages.go b/internal/agentapi/pages.go index d1f0b14..d12b8ad 100644 --- a/internal/agentapi/pages.go +++ b/internal/agentapi/pages.go @@ -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) { diff --git a/internal/statuspage/statuspage_test.go b/internal/statuspage/statuspage_test.go index 3d9f480..89178e6 100644 --- a/internal/statuspage/statuspage_test.go +++ b/internal/statuspage/statuspage_test.go @@ -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) diff --git a/internal/web/public.templ b/internal/web/public.templ index 7f843d8..d9d3ab2 100644 --- a/internal/web/public.templ +++ b/internal/web/public.templ @@ -138,10 +138,10 @@ templ publicComponentList(comps []agentapi.Component, s agentapi.PageSnapshot, a
← ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 61, "\" class=\"text-muted hover:text-ink\">← ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var34 string templ_7745c5c3_Var34, templ_7745c5c3_Err = templ.JoinStringErrs(s.Title) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 185, Col: 103} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 191, Col: 103} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var34)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 59, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 67, ">
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var38 string templ_7745c5c3_Var38, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.component."+comp.Status)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 202, Col: 80} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 208, Col: 80} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var38)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 65, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 104, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var61 string templ_7745c5c3_Var61, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "page.no_incidents")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 292, Col: 67} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 298, Col: 67} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var61)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 102, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 105, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } else { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 103, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 119, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1475,20 +1493,20 @@ func publicIncidents(incidents []agentapi.PageIncident) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 117, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 120, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var67 string templ_7745c5c3_Var67, templ_7745c5c3_Err = templ.JoinStringErrs(" · " + u.At.UTC().Format("2006-01-02 15:04") + " UTC") if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 319, Col: 103} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 325, Col: 103} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var67)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 118, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 143, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var80 string templ_7745c5c3_Var80, templ_7745c5c3_Err = templ.JoinStringErrs(strings.Join(m.Components, ", ")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 370, Col: 80} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 376, Col: 80} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var80)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 141, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 144, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if m.Description != "" { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 142, "