feat(statuspage): show the open incident's status next to its component
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 10m19s
ci / test (pull_request) Successful in 13m1s
ci / build (pull_request) Successful in 16m3s
ci / image (pull_request) Successful in 4m54s
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 10m19s
ci / test (pull_request) Successful in 13m1s
ci / build (pull_request) Successful in 16m3s
ci / image (pull_request) Successful in 4m54s
The component list names the status of the component's newest unresolved incident the organization gave one, built-in or own with its color. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
45123ff93a
commit
316bdeb223
4 files changed
+190
-146
No files matched your search
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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>
|
||||
|
||||
+161
-143
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user