feat(statuspage): add nested status page groups and optional component details
ci / image (pull_request) Successful in 4m23s
ci / lint (pull_request) Canceled after 6m9s
ci / test (pull_request) Canceled after 6m8s
ci / build (pull_request) Canceled after 6m7s

This commit is contained in:
Sebastian Unterschütz committed 2026-11-22 20:07:30 +01:00
1 parent 1c31003baf
commit 9b26b4150e
26 files changed
+4566 -760

No files matched your search

+52 -6
View File
@@ -832,9 +832,11 @@ func (s *Server) statusPageEditor(c *gin.Context, p *principal, page web.Page, m
}
ctx := c.Request.Context()
var (
row store.StatusPage
listed []store.StatusPageMonitorsRow
monitors []store.Monitor
row store.StatusPage
listed []store.StatusPageMonitorsRow
pageGroups []store.StatusPageGroup
orgGroups []store.MonitorGroup
monitors []store.Monitor
)
err = s.db.Tx(ctx, p.scope(), func(q *store.Queries) error {
var err error
@@ -844,6 +846,12 @@ func (s *Server) statusPageEditor(c *gin.Context, p *principal, page web.Page, m
if listed, err = q.StatusPageMonitors(ctx, id); err != nil {
return err
}
if pageGroups, err = q.ListStatusPageGroups(ctx, id); err != nil {
return err
}
if orgGroups, err = q.ListGroups(ctx); err != nil {
return err
}
monitors, err = q.ListMonitors(ctx)
return err
})
@@ -856,21 +864,59 @@ func (s *Server) statusPageEditor(c *gin.Context, p *principal, page web.Page, m
v := viewStatusPage(row)
e := web.PageEditor{
ID: row.ID.String(), Title: row.Title, Slug: row.Slug, Description: row.Description,
Published: row.Published, Accent: v.Theme.Accent, LogoURL: v.Theme.LogoURL, CSS: v.Theme.CSS,
Published: row.Published, ShowDetails: row.ShowComponentDetails,
Accent: v.Theme.Accent, LogoURL: v.Theme.LogoURL, CSS: v.Theme.CSS,
URL: s.pageURL(row), Domain: deref(row.CustomDomain), DomainVerified: v.DomainVerified,
HasOrgGroups: len(orgGroups) > 0,
}
if v.DomainRecord != nil {
e.RecordName, e.RecordValue = v.DomainRecord.Name, v.DomainRecord.Value
}
newPageGroupTree(pageGroups).walk(func(g store.StatusPageGroup, depth int) {
var parentID string
if g.ParentID != nil {
parentID = g.ParentID.String()
}
e.Groups = append(e.Groups, web.PageGroupRow{
ID: g.ID.String(), Name: g.Name, ParentID: parentID, Position: int(g.Position), Depth: depth,
Label: strings.Repeat("— ", depth) + g.Name,
})
})
orgTree := newGroupTree(orgGroups)
groupPath := func(gid *uuid.UUID) string {
if gid == nil {
return ""
}
var parts []string
for cur := gid; cur != nil && len(parts) < 10; {
g, ok := orgTree.byID[*cur]
if !ok {
break
}
parts = append(parts, g.Name)
cur = g.ParentID
}
slices.Reverse(parts)
return strings.Join(parts, " / ")
}
// Listed monitors keep their order; the rest follow alphabetically.
seen := map[uuid.UUID]bool{}
for _, l := range listed {
seen[l.MonitorID] = true
e.Monitors = append(e.Monitors, web.PageMonitorOption{ID: l.MonitorID.String(), Name: l.MonitorName, Included: true, Section: l.Section, Label: l.Label})
var groupID string
if l.GroupID != nil {
groupID = l.GroupID.String()
}
e.Monitors = append(e.Monitors, web.PageMonitorOption{
ID: l.MonitorID.String(), Name: l.MonitorName, MonitorGroupPath: groupPath(l.MonitorGroupID),
Included: true, GroupID: groupID, Label: l.Label,
})
}
for _, m := range monitors {
if !seen[m.ID] {
e.Monitors = append(e.Monitors, web.PageMonitorOption{ID: m.ID.String(), Name: m.Name})
e.Monitors = append(e.Monitors, web.PageMonitorOption{
ID: m.ID.String(), Name: m.Name, MonitorGroupPath: groupPath(m.GroupID),
})
}
}
return web.StatusPageEditor(page, me, e), nil