feat: own incident statuses with a color; incidents before maintenance #144

Merged
Sebi merged 1 commits from feat/incident-statuses into main 2026-11-23 22:59:18 +00:00
26 changed files with 1252 additions and 233 deletions

No files matched your search

+7 -2
View File
@@ -90,9 +90,12 @@ type PageIncident struct {
ResolvedAt *time.Time `json:"resolved_at,omitempty"` ResolvedAt *time.Time `json:"resolved_at,omitempty"`
// Title names the incident; empty shows the component. // Title names the incident; empty shows the component.
Title string `json:"title,omitempty"` Title string `json:"title,omitempty"`
// Status is investigating, identified, monitoring or resolved, empty // Status is investigating, identified, monitoring or resolved, or
// while nobody said anything. // custom with StatusName and StatusColor; empty while nobody said
// anything.
Status string `json:"status,omitempty"` Status string `json:"status,omitempty"`
StatusName string `json:"status_name,omitempty"`
StatusColor string `json:"status_color,omitempty"`
// Updates are the public updates, newest first. // Updates are the public updates, newest first.
Updates []PageIncidentUpdate `json:"updates,omitempty"` Updates []PageIncidentUpdate `json:"updates,omitempty"`
} }
@@ -100,6 +103,8 @@ type PageIncident struct {
// PageIncidentUpdate is what the organization told about an incident. // PageIncidentUpdate is what the organization told about an incident.
type PageIncidentUpdate struct { type PageIncidentUpdate struct {
Status string `json:"status"` Status string `json:"status"`
StatusName string `json:"status_name,omitempty"`
StatusColor string `json:"status_color,omitempty"`
// Message is Markdown. // Message is Markdown.
Message string `json:"message"` Message string `json:"message"`
At time.Time `json:"at"` At time.Time `json:"at"`
+9 -1
View File
@@ -136,10 +136,18 @@ var endpoints = []endpoint{
{method: "PATCH", path: "/api/v1/org/incidents/:id", tag: "Monitors", summary: "Name an incident", perm: "incidents.write", {method: "PATCH", path: "/api/v1/org/incidents/:id", tag: "Monitors", summary: "Name an incident", perm: "incidents.write",
description: "The title status pages show; empty shows the monitor's name.", req: incidentTitleRequest{}, status: http.StatusNoContent}, description: "The title status pages show; empty shows the monitor's name.", req: incidentTitleRequest{}, status: http.StatusNoContent},
{method: "POST", path: "/api/v1/org/incidents/:id/updates", tag: "Monitors", summary: "Post an update with a status", perm: "incidents.write", {method: "POST", path: "/api/v1/org/incidents/:id/updates", tag: "Monitors", summary: "Post an update with a status", perm: "incidents.write",
description: "`message` is Markdown. `public` (default true) shows it on status pages; false keeps it an internal note. The update's status becomes the incident's.", description: "`status` is a built-in status or the `id` of one of the organization's own. `message` is Markdown. `public` (default true) shows it on status pages; false keeps it an internal note. The update's status becomes the incident's.",
req: incidentUpdateRequest{}, resp: incidentUpdateView{}, status: http.StatusCreated}, req: incidentUpdateRequest{}, resp: incidentUpdateView{}, status: http.StatusCreated},
{method: "DELETE", path: "/api/v1/org/incidents/:id/updates/:update", tag: "Monitors", summary: "Delete an update", perm: "incidents.write", {method: "DELETE", path: "/api/v1/org/incidents/:id/updates/:update", tag: "Monitors", summary: "Delete an update", perm: "incidents.write",
status: http.StatusNoContent}, status: http.StatusNoContent},
{method: "GET", path: "/api/v1/org/incident-statuses", tag: "Monitors", summary: "List the organization's own incident statuses", perm: "incidents.read",
resp: obj{"statuses": []incidentStatusView{}}},
{method: "POST", path: "/api/v1/org/incident-statuses", tag: "Monitors", summary: "Add an incident status with a color", perm: "org.manage",
description: "`color` is `#rrggbb`. Updates use it by its `id` as `status`.", req: incidentStatusRequest{}, resp: incidentStatusView{}, status: http.StatusCreated},
{method: "PUT", path: "/api/v1/org/incident-statuses/:id", tag: "Monitors", summary: "Rename or recolor an incident status", perm: "org.manage",
description: "Applies to the history of incidents that used it too.", req: incidentStatusRequest{}, status: http.StatusNoContent},
{method: "DELETE", path: "/api/v1/org/incident-statuses/:id", tag: "Monitors", summary: "Delete an unused incident status", perm: "org.manage",
description: "`409 status_in_use` while updates use it.", status: http.StatusNoContent},
// Status pages // Status pages
{method: "GET", path: "/api/v1/org/statuspages", tag: "Status pages", summary: "List status pages", resp: obj{"pages": []statusPageView{}}}, {method: "GET", path: "/api/v1/org/statuspages", tag: "Status pages", summary: "List status pages", resp: obj{"pages": []statusPageView{}}},
+3
View File
@@ -42,6 +42,9 @@ var auditActions = map[string]string{
"PATCH /api/v1/org/incidents/:id": "incident.title", "PATCH /api/v1/org/incidents/:id": "incident.title",
"POST /api/v1/org/incidents/:id/updates": "incident.update", "POST /api/v1/org/incidents/:id/updates": "incident.update",
"DELETE /api/v1/org/incidents/:id/updates/:update": "incident.update_delete", "DELETE /api/v1/org/incidents/:id/updates/:update": "incident.update_delete",
"POST /api/v1/org/incident-statuses": "incident_status.create",
"PUT /api/v1/org/incident-statuses/:id": "incident_status.update",
"DELETE /api/v1/org/incident-statuses/:id": "incident_status.delete",
"POST /api/v1/me/org": "", "POST /api/v1/me/org": "",
"POST /api/v1/me/totp/setup": "", "POST /api/v1/me/totp/setup": "",
"POST /api/v1/me/totp/enable": "account.totp_enable", "POST /api/v1/me/totp/enable": "account.totp_enable",
+14 -5
View File
@@ -290,9 +290,9 @@ type incidentView struct {
ResolvedAt *time.Time `json:"resolved_at"` ResolvedAt *time.Time `json:"resolved_at"`
Cause map[string]string `json:"cause"` Cause map[string]string `json:"cause"`
Title string `json:"title"` Title string `json:"title"`
// Status is resolved once the monitor recovered, otherwise the status // The status is resolved once the monitor recovered, otherwise the
// of the latest update, empty before the first. // status of the latest update, empty before the first.
Status string `json:"status"` statusFields
} }
// incidentPage reads a page of incidents, newest first, of one monitor // incidentPage reads a page of incidents, newest first, of one monitor
@@ -333,16 +333,25 @@ func (s *Server) listIncidents(c *gin.Context) {
if !ok { if !ok {
return return
} }
rows, info, err := s.incidentPage(c.Request.Context(), current(c), pg, monitor) ctx := c.Request.Context()
rows, info, err := s.incidentPage(ctx, current(c), pg, monitor)
if err != nil { if err != nil {
internalError(c, err) internalError(c, err)
return return
} }
var statuses customStatuses
if err := s.db.Tx(ctx, current(c).scope(), func(q *store.Queries) error {
statuses, err = loadCustomStatuses(ctx, q)
return err
}); err != nil {
internalError(c, err)
return
}
out := make([]incidentView, len(rows)) out := make([]incidentView, len(rows))
for i, r := range rows { for i, r := range rows {
out[i] = incidentView{ out[i] = incidentView{
ID: r.ID, MonitorID: r.MonitorID, MonitorName: r.MonitorName, StartedAt: r.StartedAt, ResolvedAt: r.ResolvedAt, ID: r.ID, MonitorID: r.MonitorID, MonitorName: r.MonitorName, StartedAt: r.StartedAt, ResolvedAt: r.ResolvedAt,
Title: r.Title, Status: incidentStatus(store.Incident{ResolvedAt: r.ResolvedAt, Status: r.Status}), Title: r.Title, statusFields: toStatusFields(statuses.of(store.Incident{ResolvedAt: r.ResolvedAt, Status: r.Status, StatusID: r.StatusID}), r.StatusID),
} }
_ = json.Unmarshal(r.Cause, &out[i].Cause) _ = json.Unmarshal(r.Cause, &out[i].Cause)
} }
+8 -3
View File
@@ -212,6 +212,8 @@ type monitorData struct {
// firstRegion the same per region. // firstRegion the same per region.
first map[uuid.UUID]time.Time first map[uuid.UUID]time.Time
firstRegion map[uuid.UUID]map[string]time.Time firstRegion map[uuid.UUID]map[string]time.Time
// statuses are the organization's own incident statuses.
statuses customStatuses
} }
// loadFirstData finds when monitors and their regions first reported. The // loadFirstData finds when monitors and their regions first reported. The
@@ -333,6 +335,9 @@ func (s *Server) loadMonitorData(ctx context.Context, p *principal, rng web.Time
if d.first, d.firstRegion, err = loadFirstData(ctx, q, p.Org.ID, now); err != nil { if d.first, d.firstRegion, err = loadFirstData(ctx, q, p.Org.ID, now); err != nil {
return err return err
} }
if d.statuses, err = loadCustomStatuses(ctx, q); err != nil {
return err
}
ids := make([]uuid.UUID, len(monitors)) ids := make([]uuid.UUID, len(monitors))
for i, m := range monitors { for i, m := range monitors {
ids[i] = m.ID ids[i] = m.ID
@@ -533,7 +538,7 @@ func (s *Server) monitorDetail(c *gin.Context, p *principal, page web.Page, me w
} }
v.Incidents = append(v.Incidents, d.incidentRow(store.Incident{ v.Incidents = append(v.Incidents, d.incidentRow(store.Incident{
ID: i.ID, OrgID: i.OrgID, MonitorID: i.MonitorID, StartedAt: i.StartedAt, ResolvedAt: i.ResolvedAt, Cause: i.Cause, ID: i.ID, OrgID: i.OrgID, MonitorID: i.MonitorID, StartedAt: i.StartedAt, ResolvedAt: i.ResolvedAt, Cause: i.Cause,
Title: i.Title, Status: i.Status, Title: i.Title, Status: i.Status, StatusID: i.StatusID,
}, m.Name)) }, m.Name))
} }
page.TitleID = "console.monitors.title" page.TitleID = "console.monitors.title"
@@ -557,7 +562,7 @@ func (d monitorData) incidentRow(i store.Incident, monitor string) web.IncidentR
row := web.IncidentRow{ row := web.IncidentRow{
ID: i.ID.String(), MonitorID: i.MonitorID.String(), Monitor: monitor, ID: i.ID.String(), MonitorID: i.MonitorID.String(), Monitor: monitor,
Started: i.StartedAt.UTC().Format(timeLayout), Open: i.ResolvedAt == nil, Started: i.StartedAt.UTC().Format(timeLayout), Open: i.ResolvedAt == nil,
Title: i.Title, Status: incidentStatus(i), Title: i.Title, Status: d.statuses.of(i),
} }
end := time.Now() end := time.Now()
if i.ResolvedAt != nil { if i.ResolvedAt != nil {
@@ -908,7 +913,7 @@ func (s *Server) incidentsView(c *gin.Context, p *principal, page web.Page, me w
for i, r := range rows { for i, r := range rows {
v.Rows[i] = d.incidentRow(store.Incident{ v.Rows[i] = d.incidentRow(store.Incident{
ID: r.ID, OrgID: r.OrgID, MonitorID: r.MonitorID, StartedAt: r.StartedAt, ResolvedAt: r.ResolvedAt, Cause: r.Cause, ID: r.ID, OrgID: r.OrgID, MonitorID: r.MonitorID, StartedAt: r.StartedAt, ResolvedAt: r.ResolvedAt, Cause: r.Cause,
Title: r.Title, Status: r.Status, Title: r.Title, Status: r.Status, StatusID: r.StatusID,
}, r.MonitorName) }, r.MonitorName)
} }
if monitor != nil { if monitor != nil {
+157
View File
@@ -0,0 +1,157 @@
package api
import (
"net/http"
"regexp"
"strings"
"github.com/a-h/templ"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"git.zb-server.de/ZB-Server/uptimesebi/internal/authz"
"git.zb-server.de/ZB-Server/uptimesebi/internal/store"
"git.zb-server.de/ZB-Server/uptimesebi/internal/web"
)
// An organization's own incident statuses, next to the built-in ones.
var hexColor = regexp.MustCompile(`^#[0-9a-f]{6}$`)
type incidentStatusRequest struct {
Name string `json:"name" binding:"required,max=40"`
Color string `json:"color" binding:"required,max=7"`
}
type incidentStatusView struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Color string `json:"color"`
}
// validStatusRequest normalizes req and reports whether it is usable.
func validStatusRequest(c *gin.Context, req *incidentStatusRequest) bool {
req.Name, req.Color = strings.TrimSpace(req.Name), strings.ToLower(strings.TrimSpace(req.Color))
if req.Name == "" || !hexColor.MatchString(req.Color) {
fail(c, http.StatusUnprocessableEntity, "invalid_input")
return false
}
return true
}
func (s *Server) listIncidentStatuses(c *gin.Context) {
ctx := c.Request.Context()
var rows []store.IncidentStatus
if err := s.db.Tx(ctx, current(c).scope(), func(q *store.Queries) error {
var err error
rows, err = q.ListIncidentStatuses(ctx)
return err
}); err != nil {
internalError(c, err)
return
}
out := make([]incidentStatusView, len(rows))
for i, r := range rows {
out[i] = incidentStatusView{ID: r.ID, Name: r.Name, Color: r.Color}
}
c.JSON(http.StatusOK, gin.H{"statuses": out})
}
func (s *Server) createIncidentStatus(c *gin.Context) {
var req incidentStatusRequest
if !bind(c, &req) || !validStatusRequest(c, &req) {
return
}
p := current(c)
ctx := c.Request.Context()
var row store.IncidentStatus
err := s.db.Tx(ctx, p.scope(), func(q *store.Queries) error {
var err error
row, err = q.CreateIncidentStatus(ctx, store.CreateIncidentStatusParams{OrgID: p.Org.ID, Name: req.Name, Color: req.Color})
return err
})
if isUniqueViolation(err, "incident_statuses_org_id_name_key") {
fail(c, http.StatusConflict, "status_name_taken")
return
}
if err != nil {
internalError(c, err)
return
}
auditDetail(c, "name", req.Name)
c.JSON(http.StatusCreated, incidentStatusView{ID: row.ID, Name: row.Name, Color: row.Color})
}
// updateIncidentStatus renames or recolors a status, also in the history
// of incidents that used it.
func (s *Server) updateIncidentStatus(c *gin.Context) {
id, err := uuid.Parse(c.Param("id"))
if err != nil {
fail(c, http.StatusNotFound, "not_found")
return
}
var req incidentStatusRequest
if !bind(c, &req) || !validStatusRequest(c, &req) {
return
}
ctx := c.Request.Context()
var n int64
err = s.db.Tx(ctx, current(c).scope(), func(q *store.Queries) error {
n, err = q.UpdateIncidentStatus(ctx, store.UpdateIncidentStatusParams{ID: id, Name: req.Name, Color: req.Color})
return err
})
switch {
case isUniqueViolation(err, "incident_statuses_org_id_name_key"):
fail(c, http.StatusConflict, "status_name_taken")
case err != nil:
internalError(c, err)
case n == 0:
fail(c, http.StatusNotFound, "not_found")
default:
auditDetail(c, "name", req.Name)
c.Status(http.StatusNoContent)
}
}
// deleteIncidentStatus removes a status nobody used yet; history keeps
// the ones in use.
func (s *Server) deleteIncidentStatus(c *gin.Context) {
id, err := uuid.Parse(c.Param("id"))
if err != nil {
fail(c, http.StatusNotFound, "not_found")
return
}
ctx := c.Request.Context()
var n int64
err = s.db.Tx(ctx, current(c).scope(), func(q *store.Queries) error {
n, err = q.DeleteIncidentStatus(ctx, id)
return err
})
switch {
case isForeignKeyViolation(err):
fail(c, http.StatusConflict, "status_in_use")
case err != nil:
internalError(c, err)
case n == 0:
fail(c, http.StatusNotFound, "not_found")
default:
c.Status(http.StatusNoContent)
}
}
func (s *Server) incidentStatusesView(c *gin.Context, p *principal, page web.Page, me web.Me) (templ.Component, error) {
ctx := c.Request.Context()
var rows []store.IncidentStatus
if err := s.db.Tx(ctx, p.scope(), func(q *store.Queries) error {
var err error
rows, err = q.ListIncidentStatuses(ctx)
return err
}); err != nil {
return nil, err
}
v := make([]web.CustomIncidentStatus, len(rows))
for i, r := range rows {
v[i] = web.CustomIncidentStatus{ID: r.ID.String(), Name: r.Name, Color: r.Color}
}
return web.IncidentStatusesPage(page, me, v, p.Grants.Can(authz.OrgManage)), nil
}
+135 -57
View File
@@ -1,6 +1,7 @@
package api package api
import ( import (
"context"
"errors" "errors"
"net/http" "net/http"
"slices" "slices"
@@ -19,19 +20,63 @@ import (
// Incidents open and close with their monitor. People explain them with a // Incidents open and close with their monitor. People explain them with a
// title, a status and updates, public on status pages or internal notes. // title, a status and updates, public on status pages or internal notes.
// Statuses are the built-in ones or the organization's own, with a color.
// incidentStatus is what an incident shows: resolved once its monitor // customStatuses are an organization's own statuses by ID.
// recovered, otherwise the status of its latest update, empty before one. type customStatuses map[uuid.UUID]store.IncidentStatus
func incidentStatus(i store.Incident) string {
if i.ResolvedAt != nil { func loadCustomStatuses(ctx context.Context, q *store.Queries) (customStatuses, error) {
return "resolved" rows, err := q.ListIncidentStatuses(ctx)
out := customStatuses{}
for _, r := range rows {
out[r.ID] = r
} }
return deref(i.Status) return out, err
}
// info describes a stored status: a built-in key, or custom with the
// status named by id.
func (cs customStatuses) info(key *string, id *uuid.UUID) web.IncidentStatusInfo {
if key == nil {
return web.IncidentStatusInfo{}
}
if *key == "custom" && id != nil {
st := cs[*id]
return web.IncidentStatusInfo{Key: "custom", Name: st.Name, Color: st.Color}
}
return web.IncidentStatusInfo{Key: *key}
}
// of is what an incident shows: resolved once its monitor recovered,
// otherwise the status of its latest update, empty before one.
func (cs customStatuses) of(i store.Incident) web.IncidentStatusInfo {
if i.ResolvedAt != nil {
return web.IncidentStatusInfo{Key: "resolved"}
}
return cs.info(i.Status, i.StatusID)
}
// statusFields are a status in API responses.
type statusFields struct {
// Status is investigating, identified, monitoring, resolved or custom.
Status string `json:"status"`
// StatusID, StatusName and StatusColor describe a custom status.
StatusID *uuid.UUID `json:"status_id,omitempty"`
StatusName string `json:"status_name,omitempty"`
StatusColor string `json:"status_color,omitempty"`
}
func toStatusFields(info web.IncidentStatusInfo, id *uuid.UUID) statusFields {
f := statusFields{Status: info.Key}
if info.Key == "custom" {
f.StatusID, f.StatusName, f.StatusColor = id, info.Name, info.Color
}
return f
} }
type incidentUpdateView struct { type incidentUpdateView struct {
ID uuid.UUID `json:"id"` ID uuid.UUID `json:"id"`
Status string `json:"status"` statusFields
Message string `json:"message"` Message string `json:"message"`
Public bool `json:"public"` Public bool `json:"public"`
Author string `json:"author"` Author string `json:"author"`
@@ -43,68 +88,77 @@ type incidentDetailView struct {
MonitorID uuid.UUID `json:"monitor_id"` MonitorID uuid.UUID `json:"monitor_id"`
Monitor string `json:"monitor"` Monitor string `json:"monitor"`
Title string `json:"title"` Title string `json:"title"`
Status string `json:"status"` statusFields
StartedAt time.Time `json:"started_at"` StartedAt time.Time `json:"started_at"`
ResolvedAt *time.Time `json:"resolved_at"` ResolvedAt *time.Time `json:"resolved_at"`
Updates []incidentUpdateView `json:"updates"` Updates []incidentUpdateView `json:"updates"`
} }
// loadIncident returns the incident of the request with its updates. // incidentData is an incident with its updates and the organization's
func (s *Server) loadIncident(c *gin.Context) (store.GetIncidentRow, []store.ListIncidentUpdatesRow, bool) { // statuses.
type incidentData struct {
inc store.GetIncidentRow
updates []store.ListIncidentUpdatesRow
statuses customStatuses
}
// loadIncident reads the incident of the request.
func (s *Server) loadIncident(c *gin.Context) (incidentData, bool) {
var d incidentData
id, err := uuid.Parse(c.Param("id")) id, err := uuid.Parse(c.Param("id"))
if err != nil { if err != nil {
fail(c, http.StatusNotFound, "not_found") fail(c, http.StatusNotFound, "not_found")
return store.GetIncidentRow{}, nil, false return d, false
} }
ctx := c.Request.Context() ctx := c.Request.Context()
var (
inc store.GetIncidentRow
updates []store.ListIncidentUpdatesRow
)
err = s.db.Tx(ctx, current(c).scope(), func(q *store.Queries) error { err = s.db.Tx(ctx, current(c).scope(), func(q *store.Queries) error {
var err error var err error
if inc, err = q.GetIncident(ctx, id); err != nil { if d.inc, err = q.GetIncident(ctx, id); err != nil {
return err return err
} }
updates, err = q.ListIncidentUpdates(ctx, id) if d.updates, err = q.ListIncidentUpdates(ctx, id); err != nil {
return err
}
d.statuses, err = loadCustomStatuses(ctx, q)
return err return err
}) })
if errors.Is(err, pgx.ErrNoRows) { if errors.Is(err, pgx.ErrNoRows) {
fail(c, http.StatusNotFound, "not_found") fail(c, http.StatusNotFound, "not_found")
return inc, nil, false return d, false
} }
if err != nil { if err != nil {
internalError(c, err) internalError(c, err)
return inc, nil, false return d, false
} }
return inc, updates, true return d, true
} }
func incidentOf(r store.GetIncidentRow) store.Incident { func incidentOf(r store.GetIncidentRow) store.Incident {
return store.Incident{ return store.Incident{
ID: r.ID, OrgID: r.OrgID, MonitorID: r.MonitorID, StartedAt: r.StartedAt, ResolvedAt: r.ResolvedAt, ID: r.ID, OrgID: r.OrgID, MonitorID: r.MonitorID, StartedAt: r.StartedAt, ResolvedAt: r.ResolvedAt,
Cause: r.Cause, Title: r.Title, Status: r.Status, Cause: r.Cause, Title: r.Title, Status: r.Status, StatusID: r.StatusID,
} }
} }
func toIncidentDetail(inc store.GetIncidentRow, updates []store.ListIncidentUpdatesRow) incidentDetailView { func (d incidentData) view() incidentDetailView {
inc := incidentOf(d.inc)
v := incidentDetailView{ v := incidentDetailView{
ID: inc.ID, MonitorID: inc.MonitorID, Monitor: inc.MonitorName, Title: inc.Title, ID: inc.ID, MonitorID: inc.MonitorID, Monitor: d.inc.MonitorName, Title: inc.Title,
Status: incidentStatus(incidentOf(inc)), StartedAt: inc.StartedAt, ResolvedAt: inc.ResolvedAt, statusFields: toStatusFields(d.statuses.of(inc), inc.StatusID), StartedAt: inc.StartedAt, ResolvedAt: inc.ResolvedAt,
Updates: []incidentUpdateView{}, Updates: []incidentUpdateView{},
} }
for _, u := range updates { for _, u := range d.updates {
v.Updates = append(v.Updates, incidentUpdateView{ v.Updates = append(v.Updates, incidentUpdateView{
ID: u.ID, Status: u.Status, Message: u.Message, Public: u.Public, Author: u.AuthorName, CreatedAt: u.CreatedAt, ID: u.ID, statusFields: toStatusFields(d.statuses.info(&u.Status, u.StatusID), u.StatusID),
Message: u.Message, Public: u.Public, Author: u.AuthorName, CreatedAt: u.CreatedAt,
}) })
} }
return v return v
} }
func (s *Server) getIncident(c *gin.Context) { func (s *Server) getIncident(c *gin.Context) {
inc, updates, ok := s.loadIncident(c) if d, ok := s.loadIncident(c); ok {
if ok { c.JSON(http.StatusOK, d.view())
c.JSON(http.StatusOK, toIncidentDetail(inc, updates))
} }
} }
@@ -135,23 +189,24 @@ func (s *Server) setIncidentTitle(c *gin.Context) {
if !bind(c, &req) { if !bind(c, &req) {
return return
} }
inc, _, ok := s.loadIncident(c) d, ok := s.loadIncident(c)
if !ok || !s.mayWriteIncident(c, inc) { if !ok || !s.mayWriteIncident(c, d.inc) {
return return
} }
ctx := c.Request.Context() ctx := c.Request.Context()
if err := s.db.Tx(ctx, current(c).scope(), func(q *store.Queries) error { if err := s.db.Tx(ctx, current(c).scope(), func(q *store.Queries) error {
_, err := q.SetIncidentTitle(ctx, store.SetIncidentTitleParams{ID: inc.ID, Title: strings.TrimSpace(req.Title)}) _, err := q.SetIncidentTitle(ctx, store.SetIncidentTitleParams{ID: d.inc.ID, Title: strings.TrimSpace(req.Title)})
return err return err
}); err != nil { }); err != nil {
internalError(c, err) internalError(c, err)
return return
} }
auditDetail(c, "incident_id", inc.ID.String()) auditDetail(c, "incident_id", d.inc.ID.String())
c.Status(http.StatusNoContent) c.Status(http.StatusNoContent)
} }
type incidentUpdateRequest struct { type incidentUpdateRequest struct {
// Status is a built-in status or the ID of a custom one.
Status string `json:"status" binding:"required"` Status string `json:"status" binding:"required"`
Message string `json:"message" binding:"required,max=5000"` Message string `json:"message" binding:"required,max=5000"`
// Public shows the update on status pages; otherwise it is an internal // Public shows the update on status pages; otherwise it is an internal
@@ -166,12 +221,23 @@ func (s *Server) addIncidentUpdate(c *gin.Context) {
return return
} }
req.Message = strings.TrimSpace(req.Message) req.Message = strings.TrimSpace(req.Message)
if !slices.Contains(web.IncidentStatuses, req.Status) || req.Message == "" { d, ok := s.loadIncident(c)
if !ok {
return
}
key, statusID := req.Status, (*uuid.UUID)(nil)
if id, err := uuid.Parse(req.Status); err == nil {
if _, ok := d.statuses[id]; !ok {
fail(c, http.StatusUnprocessableEntity, "invalid_input") fail(c, http.StatusUnprocessableEntity, "invalid_input")
return return
} }
inc, _, ok := s.loadIncident(c) key, statusID = "custom", &id
if !ok || !s.mayWriteIncident(c, inc) { }
if (statusID == nil && !slices.Contains(web.IncidentStatuses, key)) || req.Message == "" {
fail(c, http.StatusUnprocessableEntity, "invalid_input")
return
}
if !s.mayWriteIncident(c, d.inc) {
return return
} }
public := req.Public == nil || *req.Public public := req.Public == nil || *req.Public
@@ -185,19 +251,22 @@ func (s *Server) addIncidentUpdate(c *gin.Context) {
if err := s.db.Tx(ctx, p.scope(), func(q *store.Queries) error { if err := s.db.Tx(ctx, p.scope(), func(q *store.Queries) error {
var err error var err error
u, err = q.AddIncidentUpdate(ctx, store.AddIncidentUpdateParams{ u, err = q.AddIncidentUpdate(ctx, store.AddIncidentUpdateParams{
OrgID: p.Org.ID, IncidentID: inc.ID, Status: req.Status, Message: req.Message, Public: public, AuthorID: author, OrgID: p.Org.ID, IncidentID: d.inc.ID, Status: key, StatusID: statusID, Message: req.Message, Public: public, AuthorID: author,
}) })
if err != nil { if err != nil {
return err return err
} }
return q.RefreshIncidentStatus(ctx, inc.ID) return q.RefreshIncidentStatus(ctx, d.inc.ID)
}); err != nil { }); err != nil {
internalError(c, err) internalError(c, err)
return return
} }
auditDetail(c, "incident_id", inc.ID.String()) auditDetail(c, "incident_id", d.inc.ID.String())
auditDetail(c, "status", req.Status) auditDetail(c, "status", req.Status)
c.JSON(http.StatusCreated, incidentUpdateView{ID: u.ID, Status: u.Status, Message: u.Message, Public: u.Public, CreatedAt: u.CreatedAt}) c.JSON(http.StatusCreated, incidentUpdateView{
ID: u.ID, statusFields: toStatusFields(d.statuses.info(&u.Status, u.StatusID), u.StatusID),
Message: u.Message, Public: u.Public, CreatedAt: u.CreatedAt,
})
} }
func (s *Server) deleteIncidentUpdate(c *gin.Context) { func (s *Server) deleteIncidentUpdate(c *gin.Context) {
@@ -206,18 +275,18 @@ func (s *Server) deleteIncidentUpdate(c *gin.Context) {
fail(c, http.StatusNotFound, "not_found") fail(c, http.StatusNotFound, "not_found")
return return
} }
inc, _, ok := s.loadIncident(c) d, ok := s.loadIncident(c)
if !ok || !s.mayWriteIncident(c, inc) { if !ok || !s.mayWriteIncident(c, d.inc) {
return return
} }
ctx := c.Request.Context() ctx := c.Request.Context()
var n int64 var n int64
if err := s.db.Tx(ctx, current(c).scope(), func(q *store.Queries) error { if err := s.db.Tx(ctx, current(c).scope(), func(q *store.Queries) error {
var err error var err error
if n, err = q.DeleteIncidentUpdate(ctx, store.DeleteIncidentUpdateParams{ID: update, IncidentID: inc.ID}); err != nil || n == 0 { if n, err = q.DeleteIncidentUpdate(ctx, store.DeleteIncidentUpdateParams{ID: update, IncidentID: d.inc.ID}); err != nil || n == 0 {
return err return err
} }
return q.RefreshIncidentStatus(ctx, inc.ID) return q.RefreshIncidentStatus(ctx, d.inc.ID)
}); err != nil { }); err != nil {
internalError(c, err) internalError(c, err)
return return
@@ -226,19 +295,19 @@ func (s *Server) deleteIncidentUpdate(c *gin.Context) {
fail(c, http.StatusNotFound, "not_found") fail(c, http.StatusNotFound, "not_found")
return return
} }
auditDetail(c, "incident_id", inc.ID.String()) auditDetail(c, "incident_id", d.inc.ID.String())
c.Status(http.StatusNoContent) c.Status(http.StatusNoContent)
} }
// incidentDetailView is the console page of one incident. // incidentDetailView is the console page of one incident.
func (s *Server) incidentDetailView(c *gin.Context, p *principal, page web.Page, me web.Me) (templ.Component, error) { func (s *Server) incidentDetailView(c *gin.Context, p *principal, page web.Page, me web.Me) (templ.Component, error) {
c.Set(ctxPrincipal, p) c.Set(ctxPrincipal, p)
inc, updates, ok := s.loadIncident(c) d, ok := s.loadIncident(c)
if !ok { if !ok {
return nil, errAborted return nil, errAborted
} }
ctx := c.Request.Context() ctx := c.Request.Context()
d, err := s.loadMonitorData(ctx, p, web.RangeByKey("")) md, err := s.loadMonitorData(ctx, p, web.RangeByKey(""))
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -246,9 +315,10 @@ func (s *Server) incidentDetailView(c *gin.Context, p *principal, page web.Page,
if err != nil { if err != nil {
return nil, err return nil, err
} }
inc := incidentOf(d.inc)
v := web.IncidentDetailView{ v := web.IncidentDetailView{
Row: d.incidentRow(incidentOf(inc), inc.MonitorName), Row: md.incidentRow(inc, d.inc.MonitorName),
CanWrite: canInGroup(p, authz.IncidentsWrite, t, inc.MonitorGroupID), CanWrite: canInGroup(p, authz.IncidentsWrite, t, d.inc.MonitorGroupID),
} }
// Newest first; the monitor's own events among the updates. // Newest first; the monitor's own events among the updates.
type entry struct { type entry struct {
@@ -259,13 +329,14 @@ func (s *Server) incidentDetailView(c *gin.Context, p *principal, page web.Page,
if inc.ResolvedAt != nil { if inc.ResolvedAt != nil {
entries = append(entries, entry{*inc.ResolvedAt, web.IncidentTimelineEntry{Kind: "resolved"}}) entries = append(entries, entry{*inc.ResolvedAt, web.IncidentTimelineEntry{Kind: "resolved"}})
} }
for _, u := range updates { for _, u := range d.updates {
html, err := web.RenderMarkdown(u.Message) html, err := web.RenderMarkdown(u.Message)
if err != nil { if err != nil {
return nil, err return nil, err
} }
entries = append(entries, entry{u.CreatedAt, web.IncidentTimelineEntry{ entries = append(entries, entry{u.CreatedAt, web.IncidentTimelineEntry{
Kind: "update", ID: u.ID.String(), Status: u.Status, HTML: html, Author: u.AuthorName, Public: u.Public, Kind: "update", ID: u.ID.String(), Status: d.statuses.info(&u.Status, u.StatusID), HTML: html,
Author: u.AuthorName, Public: u.Public,
}}) }})
} }
slices.SortStableFunc(entries, func(a, b entry) int { return b.at.Compare(a.at) }) slices.SortStableFunc(entries, func(a, b entry) int { return b.at.Compare(a.at) })
@@ -273,16 +344,23 @@ func (s *Server) incidentDetailView(c *gin.Context, p *principal, page web.Page,
x.e.At = x.at.UTC().Format(timeLayout) x.e.At = x.at.UTC().Format(timeLayout)
v.Timeline = append(v.Timeline, x.e) v.Timeline = append(v.Timeline, x.e)
} }
v.NextStatus = nextIncidentStatus(v.Row.Status) v.NextStatus = nextIncidentStatus(inc)
for _, st := range d.statuses {
v.Custom = append(v.Custom, web.CustomIncidentStatus{ID: st.ID.String(), Name: st.Name, Color: st.Color})
}
slices.SortFunc(v.Custom, func(a, b web.CustomIncidentStatus) int { return strings.Compare(a.Name, b.Name) })
return web.IncidentDetailPage(page, me, v), nil return web.IncidentDetailPage(page, me, v), nil
} }
// nextIncidentStatus suggests the status after current: usually one step // nextIncidentStatus suggests the status of the next update: one built-in
// further, staying at resolved. // step further, the same custom status, resolved at the end.
func nextIncidentStatus(current string) string { func nextIncidentStatus(inc store.Incident) string {
i := slices.Index(web.IncidentStatuses, current) switch {
if i < 0 { case inc.Status == nil:
return web.IncidentStatuses[0] return web.IncidentStatuses[0]
case *inc.Status == "custom" && inc.StatusID != nil:
return inc.StatusID.String()
} }
i := slices.Index(web.IncidentStatuses, *inc.Status)
return web.IncidentStatuses[min(i+1, len(web.IncidentStatuses)-1)] return web.IncidentStatuses[min(i+1, len(web.IncidentStatuses)-1)]
} }
+72
View File
@@ -119,3 +119,75 @@ func TestIncidentUpdates(t *testing.T) {
t.Errorf("unknown incident = %d", st) t.Errorf("unknown incident = %d", st)
} }
} }
func TestCustomIncidentStatuses(t *testing.T) {
e := newEnv(t)
ctx := context.Background()
owner := e.browser(t)
owner.signup("o@"+uniq("cis")+".test", uniq("cis-"))
_, m := owner.do("POST", "/api/v1/org/monitors", map[string]any{"name": "Shop", "type": "heartbeat", "interval_seconds": 3600})
monitorID := m["id"].(string)
slug := uniq("cisp-")
_, page := owner.do("POST", "/api/v1/org/statuspages", map[string]any{"slug": slug, "title": "Acme"})
owner.do("PUT", "/api/v1/org/statuspages/"+page["id"].(string), map[string]any{"slug": slug, "title": "Acme", "published": true})
owner.do("PUT", "/api/v1/org/statuspages/"+page["id"].(string)+"/monitors", map[string]any{"monitors": []map[string]any{{"monitor_id": monitorID}}})
var incident uuid.UUID
if err := e.asSystem(t, func(tx pgx.Tx) error {
return tx.QueryRow(ctx, `INSERT INTO incidents (org_id, monitor_id, started_at, cause)
SELECT org_id, id, now() - interval '10 minutes', '{}' FROM monitors WHERE id = $1 RETURNING id`, monitorID).Scan(&incident)
}); err != nil {
t.Fatal(err)
}
for _, bad := range []map[string]any{{"name": "x", "color": "red"}, {"name": " ", "color": "#7c3aed"}} {
st, body := owner.do("POST", "/api/v1/org/incident-statuses", bad)
expect(t, "invalid status", st, body, http.StatusUnprocessableEntity, "invalid_input")
}
st, status := owner.do("POST", "/api/v1/org/incident-statuses", map[string]any{"name": "Waiting for provider", "color": "#7C3AED"})
if st != http.StatusCreated || status["color"] != "#7c3aed" {
t.Fatalf("create status = %d %v", st, status)
}
id := status["id"].(string)
st, body := owner.do("POST", "/api/v1/org/incident-statuses", map[string]any{"name": "Waiting for provider", "color": "#000000"})
expect(t, "duplicate name", st, body, http.StatusConflict, "status_name_taken")
viewer := e.joinVia(t, owner.invite("v@"+uniq("cis")+".test", owner.roleID("viewer")))
st, body = viewer.do("POST", "/api/v1/org/incident-statuses", map[string]any{"name": "Mine", "color": "#000000"})
expect(t, "viewer adds a status", st, body, http.StatusForbidden, "forbidden")
// Updates use it by its ID; it shows with name and color.
base := "/api/v1/org/incidents/" + incident.String()
if st, body := owner.do("POST", base+"/updates", map[string]any{"status": id, "message": "Provider is on it."}); st != http.StatusCreated || body["status_name"] != "Waiting for provider" {
t.Fatalf("update with own status = %d %v", st, body)
}
st, body = owner.do("POST", base+"/updates", map[string]any{"status": uuid.NewString(), "message": "x"})
expect(t, "update with an unknown status", st, body, http.StatusUnprocessableEntity, "invalid_input")
if _, inc := owner.do("GET", base, nil); inc["status"] != "custom" || inc["status_id"] != id || inc["status_color"] != "#7c3aed" {
t.Errorf("incident = %v", inc)
}
snap, err := e.statuspageClient(t, nil).Page(ctx, "", slug)
if err != nil {
t.Fatal(err)
}
if len(snap.Incidents) == 0 || snap.Incidents[0].StatusName != "Waiting for provider" || snap.Incidents[0].Updates[0].StatusColor != "#7c3aed" {
t.Errorf("status page incidents = %+v", snap.Incidents)
}
_, _, html := owner.page("/incidents/" + incident.String())
if !strings.Contains(html, "background-color:#7c3aed") || !strings.Contains(html, `<option value="`+id+`" selected`) {
t.Error("the incident page lacks the own status or does not preselect it")
}
if _, _, html := owner.page("/settings/incident-statuses"); !strings.Contains(html, "Waiting for provider") || !strings.Contains(html, "Investigating") {
t.Error("the settings page lacks the statuses")
}
// Renaming carries into the history; a status in use stays.
owner.do("PUT", "/api/v1/org/incident-statuses/"+id, map[string]any{"name": "Provider working", "color": "#0ea5e9"})
if _, inc := owner.do("GET", base, nil); inc["status_name"] != "Provider working" {
t.Errorf("after renaming = %v", inc["status_name"])
}
st, body = owner.do("DELETE", "/api/v1/org/incident-statuses/"+id, nil)
expect(t, "delete a status in use", st, body, http.StatusConflict, "status_in_use")
_, unused := owner.do("POST", "/api/v1/org/incident-statuses", map[string]any{"name": "Unused", "color": "#111111"})
if st, _ := owner.do("DELETE", "/api/v1/org/incident-statuses/"+unused["id"].(string), nil); st != http.StatusNoContent {
t.Errorf("delete an unused status = %d", st)
}
}
+1
View File
@@ -48,6 +48,7 @@ func (s *Server) registerPages(r gin.IRouter) {
r.GET("/admin/legal", s.adminLegalPage) r.GET("/admin/legal", s.adminLegalPage)
r.GET("/settings/legal", s.orgPage("legal.org_title", authz.OrgManage, s.orgLegalView)) r.GET("/settings/legal", s.orgPage("legal.org_title", authz.OrgManage, s.orgLegalView))
r.GET("/incidents/:id", s.orgPage("incidents.title", authz.IncidentsRead, s.incidentDetailView)) r.GET("/incidents/:id", s.orgPage("incidents.title", authz.IncidentsRead, s.incidentDetailView))
r.GET("/settings/incident-statuses", s.orgPage("incident_statuses.title", authz.IncidentsRead, s.incidentStatusesView))
r.GET("/legal/:kind", s.legalPage) r.GET("/legal/:kind", s.legalPage)
r.GET("/consent", s.consentPage) r.GET("/consent", s.consentPage)
r.GET("/account/suspended", s.suspendedPage) r.GET("/account/suspended", s.suspendedPage)
+4
View File
@@ -227,6 +227,10 @@ func (s *Server) Mount(r gin.IRouter) {
org.PATCH("/incidents/:id", s.setIncidentTitle) org.PATCH("/incidents/:id", s.setIncidentTitle)
org.POST("/incidents/:id/updates", s.addIncidentUpdate) org.POST("/incidents/:id/updates", s.addIncidentUpdate)
org.DELETE("/incidents/:id/updates/:update", s.deleteIncidentUpdate) org.DELETE("/incidents/:id/updates/:update", s.deleteIncidentUpdate)
org.GET("/incident-statuses", can(authz.IncidentsRead), s.listIncidentStatuses)
org.POST("/incident-statuses", can(authz.OrgManage), s.createIncidentStatus)
org.PUT("/incident-statuses/:id", can(authz.OrgManage), s.updateIncidentStatus)
org.DELETE("/incident-statuses/:id", can(authz.OrgManage), s.deleteIncidentStatus)
org.GET("/audit", can(authz.AuditRead), s.listOrgAudit) org.GET("/audit", can(authz.AuditRead), s.listOrgAudit)
org.GET("/alert-groups", can(authz.NotificationsRead), s.listAlertGroups) org.GET("/alert-groups", can(authz.NotificationsRead), s.listAlertGroups)
+10 -2
View File
@@ -63,6 +63,7 @@ func (s *Server) buildSnapshot(ctx context.Context, page store.StatusPage) (agen
regions []store.Region regions []store.Region
incidents []store.Incident incidents []store.Incident
updates []store.PublicIncidentUpdatesRow updates []store.PublicIncidentUpdatesRow
statuses customStatuses
planned map[uuid.UUID][]store.MaintenanceWindow planned map[uuid.UUID][]store.MaintenanceWindow
) )
now := time.Now() now := time.Now()
@@ -109,6 +110,9 @@ func (s *Server) buildSnapshot(ctx context.Context, page store.StatusPage) (agen
if updates, err = q.PublicIncidentUpdates(ctx, incidentIDs); err != nil { if updates, err = q.PublicIncidentUpdates(ctx, incidentIDs); err != nil {
return err return err
} }
if statuses, err = loadCustomStatuses(ctx, q); err != nil {
return err
}
if planned, err = maintenanceFor(ctx, q, ids); err != nil { if planned, err = maintenanceFor(ctx, q, ids); err != nil {
return err return err
} }
@@ -201,12 +205,16 @@ func (s *Server) buildSnapshot(ctx context.Context, page store.StatusPage) (agen
snap.Maintenance = pageMaintenance(planned, names, now) snap.Maintenance = pageMaintenance(planned, names, now)
updatesOf := map[uuid.UUID][]agentapi.PageIncidentUpdate{} updatesOf := map[uuid.UUID][]agentapi.PageIncidentUpdate{}
for _, u := range updates { for _, u := range updates {
updatesOf[u.IncidentID] = append(updatesOf[u.IncidentID], agentapi.PageIncidentUpdate{Status: u.Status, Message: u.Message, At: u.CreatedAt}) st := statuses.info(&u.Status, u.StatusID)
updatesOf[u.IncidentID] = append(updatesOf[u.IncidentID], agentapi.PageIncidentUpdate{
Status: st.Key, StatusName: st.Name, StatusColor: st.Color, Message: u.Message, At: u.CreatedAt,
})
} }
for _, i := range incidents { for _, i := range incidents {
st := statuses.of(i)
snap.Incidents = append(snap.Incidents, agentapi.PageIncident{ snap.Incidents = append(snap.Incidents, agentapi.PageIncident{
Component: names[i.MonitorID], StartedAt: i.StartedAt, ResolvedAt: i.ResolvedAt, Component: names[i.MonitorID], StartedAt: i.StartedAt, ResolvedAt: i.ResolvedAt,
Title: i.Title, Status: incidentStatus(i), Updates: updatesOf[i.ID], Title: i.Title, Status: st.Key, StatusName: st.Name, StatusColor: st.Color, Updates: updatesOf[i.ID],
}) })
} }
return snap, nil return snap, nil
+15
View File
@@ -92,6 +92,9 @@
"audit.action.incident.title": "Ausfall umbenannt", "audit.action.incident.title": "Ausfall umbenannt",
"audit.action.incident.update": "Update zu einem Ausfall veröffentlicht", "audit.action.incident.update": "Update zu einem Ausfall veröffentlicht",
"audit.action.incident.update_delete": "Update zu einem Ausfall gelöscht", "audit.action.incident.update_delete": "Update zu einem Ausfall gelöscht",
"audit.action.incident_status.create": "Status für Ausfälle hinzugefügt",
"audit.action.incident_status.delete": "Status für Ausfälle gelöscht",
"audit.action.incident_status.update": "Status für Ausfälle geändert",
"audit.action.invitation.create": "Einladung verschickt", "audit.action.invitation.create": "Einladung verschickt",
"audit.action.invitation.delete": "Einladung zurückgezogen", "audit.action.invitation.delete": "Einladung zurückgezogen",
"audit.action.maintenance.create": "Wartung geplant", "audit.action.maintenance.create": "Wartung geplant",
@@ -626,6 +629,8 @@
"error.sso_provider_error": "Der Identity Provider konnte die Anmeldung nicht abschließen.", "error.sso_provider_error": "Der Identity Provider konnte die Anmeldung nicht abschließen.",
"error.sso_required_by_org": "Diese Organisation verlangt die Anmeldung über ihren SSO-Provider.", "error.sso_required_by_org": "Diese Organisation verlangt die Anmeldung über ihren SSO-Provider.",
"error.sso_unavailable": "Für diese Organisation ist kein Single Sign-on verfügbar.", "error.sso_unavailable": "Für diese Organisation ist kein Single Sign-on verfügbar.",
"error.status_in_use": "Updates benutzen diesen Status; er bleibt, damit ihr Verlauf verständlich bleibt. Benenne ihn um oder ändere die Farbe.",
"error.status_name_taken": "Einen Status mit diesem Namen gibt es schon.",
"error.status_page_limit": "Deine Organisation hat ihr Limit von {{.Max}} Statusseiten erreicht.", "error.status_page_limit": "Deine Organisation hat ihr Limit von {{.Max}} Statusseiten erreicht.",
"error.target_is_admin": "Plattform-Admins können hier nicht gesperrt oder gelöscht werden.", "error.target_is_admin": "Plattform-Admins können hier nicht gesperrt oder gelöscht werden.",
"error.token_lifetime_exceeds_policy": { "error.token_lifetime_exceeds_policy": {
@@ -830,6 +835,15 @@
"incident.title_hint": "Erscheint auf Statusseiten; leer zeigt den Namen des Monitors.", "incident.title_hint": "Erscheint auf Statusseiten; leer zeigt den Namen des Monitors.",
"incident.title_label": "Titel", "incident.title_label": "Titel",
"incident.title_placeholder": "Anmeldung langsam", "incident.title_placeholder": "Anmeldung langsam",
"incident_statuses.add": "Status hinzufügen",
"incident_statuses.builtin": "Eingebaut",
"incident_statuses.color": "Farbe",
"incident_statuses.delete_confirm": "Diesen Status löschen? Geht nur, solange kein Update ihn benutzt.",
"incident_statuses.intro": "Status zur Auswahl, wenn ihr ein Update zu einem Ausfall veröffentlicht. Eigene erscheinen in ihrer Farbe in der Konsole und auf Statusseiten.",
"incident_statuses.none": "Noch keine.",
"incident_statuses.own": "Eigene",
"incident_statuses.placeholder": "Warten auf unseren Anbieter",
"incident_statuses.title": "Status für Ausfälle",
"incidents.all": "Alle Vorfälle", "incidents.all": "Alle Vorfälle",
"incidents.all_of_monitor": "Alle Vorfälle dieses Monitors", "incidents.all_of_monitor": "Alle Vorfälle dieses Monitors",
"incidents.none": "Bisher keine Incidents.", "incidents.none": "Bisher keine Incidents.",
@@ -1302,6 +1316,7 @@
"settings.audit": "Wer wann was geändert hat.", "settings.audit": "Wer wann was geändert hat.",
"settings.channels": "Webhooks und E-Mail für Incidents", "settings.channels": "Webhooks und E-Mail für Incidents",
"settings.groups": "Monitore in verschachtelten Gruppen ordnen", "settings.groups": "Monitore in verschachtelten Gruppen ordnen",
"settings.incident_statuses": "Eigene Status mit Farbe für Updates zu Ausfällen.",
"settings.legal": "Impressum und Datenschutzerklärung für deine Statusseiten.", "settings.legal": "Impressum und Datenschutzerklärung für deine Statusseiten.",
"settings.members": "Personen einladen und Rollen vergeben", "settings.members": "Personen einladen und Rollen vergeben",
"settings.org": "Anmelderichtlinien und Token-Laufzeit", "settings.org": "Anmelderichtlinien und Token-Laufzeit",
+15
View File
@@ -92,6 +92,9 @@
"audit.action.incident.title": "Incident renamed", "audit.action.incident.title": "Incident renamed",
"audit.action.incident.update": "Incident update posted", "audit.action.incident.update": "Incident update posted",
"audit.action.incident.update_delete": "Incident update deleted", "audit.action.incident.update_delete": "Incident update deleted",
"audit.action.incident_status.create": "Incident status added",
"audit.action.incident_status.delete": "Incident status deleted",
"audit.action.incident_status.update": "Incident status changed",
"audit.action.invitation.create": "Invitation sent", "audit.action.invitation.create": "Invitation sent",
"audit.action.invitation.delete": "Invitation withdrawn", "audit.action.invitation.delete": "Invitation withdrawn",
"audit.action.maintenance.create": "Maintenance planned", "audit.action.maintenance.create": "Maintenance planned",
@@ -626,6 +629,8 @@
"error.sso_provider_error": "The identity provider could not complete the sign-in.", "error.sso_provider_error": "The identity provider could not complete the sign-in.",
"error.sso_required_by_org": "This organization requires signing in through its SSO provider.", "error.sso_required_by_org": "This organization requires signing in through its SSO provider.",
"error.sso_unavailable": "Single sign-on is not available for this organization.", "error.sso_unavailable": "Single sign-on is not available for this organization.",
"error.status_in_use": "Updates use this status; it stays so their history keeps its meaning. Rename or recolor it instead.",
"error.status_name_taken": "A status with this name exists already.",
"error.status_page_limit": "Your organization has reached its limit of {{.Max}} status pages.", "error.status_page_limit": "Your organization has reached its limit of {{.Max}} status pages.",
"error.target_is_admin": "Platform admins cannot be suspended or deleted here.", "error.target_is_admin": "Platform admins cannot be suspended or deleted here.",
"error.token_lifetime_exceeds_policy": { "error.token_lifetime_exceeds_policy": {
@@ -830,6 +835,15 @@
"incident.title_hint": "Shown on status pages; empty shows the monitor's name.", "incident.title_hint": "Shown on status pages; empty shows the monitor's name.",
"incident.title_label": "Title", "incident.title_label": "Title",
"incident.title_placeholder": "Sign-in is slow", "incident.title_placeholder": "Sign-in is slow",
"incident_statuses.add": "Add status",
"incident_statuses.builtin": "Built in",
"incident_statuses.color": "Color",
"incident_statuses.delete_confirm": "Delete this status? Only possible while no update uses it.",
"incident_statuses.intro": "Statuses to choose from when posting an incident update. Your own appear in their color in the console and on status pages.",
"incident_statuses.none": "None yet.",
"incident_statuses.own": "Your own",
"incident_statuses.placeholder": "Waiting for our provider",
"incident_statuses.title": "Incident statuses",
"incidents.all": "All incidents", "incidents.all": "All incidents",
"incidents.all_of_monitor": "All incidents of this monitor", "incidents.all_of_monitor": "All incidents of this monitor",
"incidents.none": "No incidents so far.", "incidents.none": "No incidents so far.",
@@ -1302,6 +1316,7 @@
"settings.audit": "Who changed what and when.", "settings.audit": "Who changed what and when.",
"settings.channels": "Webhooks and email for incidents", "settings.channels": "Webhooks and email for incidents",
"settings.groups": "Organize monitors in nested groups", "settings.groups": "Organize monitors in nested groups",
"settings.incident_statuses": "Your own statuses with a color for incident updates.",
"settings.legal": "Legal notice and privacy policy for your status pages.", "settings.legal": "Legal notice and privacy policy for your status pages.",
"settings.members": "Invite people and assign roles", "settings.members": "Invite people and assign roles",
"settings.org": "Sign-in policies and token lifetime", "settings.org": "Sign-in policies and token lifetime",
@@ -0,0 +1,48 @@
-- +goose Up
-- Organizations add statuses of their own, with a color, next to the
-- built-in ones. A status in use cannot be deleted: the history would lose
-- its meaning.
CREATE TABLE incident_statuses (
id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
org_id uuid NOT NULL REFERENCES orgs (id) ON DELETE CASCADE,
name text NOT NULL CHECK (length(name) BETWEEN 1 AND 40),
color text NOT NULL CHECK (color ~ '^#[0-9a-f]{6}$'),
created_at timestamptz NOT NULL DEFAULT now(),
UNIQUE (org_id, name)
);
ALTER TABLE incident_statuses ENABLE ROW LEVEL SECURITY;
ALTER TABLE incident_statuses FORCE ROW LEVEL SECURITY;
CREATE POLICY incident_statuses_tenant ON incident_statuses FOR ALL
USING (app_scope_system() OR org_id = app_org_id())
WITH CHECK (app_scope_system() OR org_id = app_org_id());
-- status is a built-in status or 'custom' with status_id naming it.
ALTER TABLE incident_updates DROP CONSTRAINT incident_updates_status_check;
ALTER TABLE incident_updates ADD CONSTRAINT incident_updates_status_check
CHECK (status IN ('investigating', 'identified', 'monitoring', 'resolved', 'custom'));
ALTER TABLE incident_updates ADD COLUMN status_id uuid REFERENCES incident_statuses (id) ON DELETE RESTRICT;
ALTER TABLE incident_updates ADD CONSTRAINT incident_updates_custom_status
CHECK ((status = 'custom') = (status_id IS NOT NULL));
ALTER TABLE incidents DROP CONSTRAINT incidents_status_check;
ALTER TABLE incidents ADD CONSTRAINT incidents_status_check
CHECK (status IN ('investigating', 'identified', 'monitoring', 'resolved', 'custom'));
ALTER TABLE incidents ADD COLUMN status_id uuid REFERENCES incident_statuses (id) ON DELETE RESTRICT;
ALTER TABLE incidents ADD CONSTRAINT incidents_custom_status
CHECK ((status = 'custom') = (status_id IS NOT NULL));
-- +goose Down
DELETE FROM incident_updates WHERE status = 'custom';
UPDATE incidents SET status = NULL WHERE status = 'custom';
ALTER TABLE incidents DROP CONSTRAINT incidents_custom_status;
ALTER TABLE incidents DROP COLUMN status_id;
ALTER TABLE incidents DROP CONSTRAINT incidents_status_check;
ALTER TABLE incidents ADD CONSTRAINT incidents_status_check
CHECK (status IN ('investigating', 'identified', 'monitoring', 'resolved'));
ALTER TABLE incident_updates DROP CONSTRAINT incident_updates_custom_status;
ALTER TABLE incident_updates DROP COLUMN status_id;
ALTER TABLE incident_updates DROP CONSTRAINT incident_updates_status_check;
ALTER TABLE incident_updates ADD CONSTRAINT incident_updates_status_check
CHECK (status IN ('investigating', 'identified', 'monitoring', 'resolved'));
DROP TABLE incident_statuses;
+11
View File
@@ -364,6 +364,10 @@ func TestNestedGroupsAndComponentDetails(t *testing.T) {
{Status: "investigating", Message: "Wir schauen.\n\n<script>alert(1)</script>", At: now.Add(-50 * time.Minute)}, {Status: "investigating", Message: "Wir schauen.\n\n<script>alert(1)</script>", At: now.Add(-50 * time.Minute)},
}, },
}, },
{Component: "Website", StartedAt: now.Add(-2 * time.Hour), Title: "Zahlungen", Status: "custom", StatusName: "Warten auf Anbieter", StatusColor: "#7c3aed"},
},
Maintenance: []agentapi.PageMaintenance{
{Title: "Datenbank-Upgrade", Start: now.Add(24 * time.Hour), End: now.Add(25 * time.Hour), Components: []string{"Website"}},
}, },
} }
@@ -383,6 +387,13 @@ func TestNestedGroupsAndComponentDetails(t *testing.T) {
if strings.Contains(body, "<script>alert") { if strings.Contains(body, "<script>alert") {
t.Error("an update's HTML reached the page") t.Error("an update's HTML reached the page")
} }
if !strings.Contains(body, "Warten auf Anbieter") || !strings.Contains(body, "background-color:#7c3aed") {
t.Error("the own status lacks its name or color")
}
// 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)
}
}) })
t.Run("main page renders nested groups and clickable links", func(t *testing.T) { t.Run("main page renders nested groups and clickable links", func(t *testing.T) {
+111 -13
View File
@@ -13,15 +13,16 @@ import (
) )
const addIncidentUpdate = `-- name: AddIncidentUpdate :one const addIncidentUpdate = `-- name: AddIncidentUpdate :one
INSERT INTO incident_updates (org_id, incident_id, status, message, public, author_id) INSERT INTO incident_updates (org_id, incident_id, status, status_id, message, public, author_id)
VALUES ($1, $2, $3, $4, $5, $6) VALUES ($1, $2, $3, $4, $5, $6, $7)
RETURNING id, org_id, incident_id, status, message, public, author_id, created_at RETURNING id, org_id, incident_id, status, message, public, author_id, created_at, status_id
` `
type AddIncidentUpdateParams struct { type AddIncidentUpdateParams struct {
OrgID uuid.UUID OrgID uuid.UUID
IncidentID uuid.UUID IncidentID uuid.UUID
Status string Status string
StatusID *uuid.UUID
Message string Message string
Public bool Public bool
AuthorID *uuid.UUID AuthorID *uuid.UUID
@@ -32,6 +33,7 @@ func (q *Queries) AddIncidentUpdate(ctx context.Context, arg AddIncidentUpdatePa
arg.OrgID, arg.OrgID,
arg.IncidentID, arg.IncidentID,
arg.Status, arg.Status,
arg.StatusID,
arg.Message, arg.Message,
arg.Public, arg.Public,
arg.AuthorID, arg.AuthorID,
@@ -46,6 +48,7 @@ func (q *Queries) AddIncidentUpdate(ctx context.Context, arg AddIncidentUpdatePa
&i.Public, &i.Public,
&i.AuthorID, &i.AuthorID,
&i.CreatedAt, &i.CreatedAt,
&i.StatusID,
) )
return i, err return i, err
} }
@@ -120,6 +123,29 @@ func (q *Queries) CreateChannel(ctx context.Context, arg CreateChannelParams) (N
return i, err return i, err
} }
const createIncidentStatus = `-- name: CreateIncidentStatus :one
INSERT INTO incident_statuses (org_id, name, color) VALUES ($1, $2, $3) RETURNING id, org_id, name, color, created_at
`
type CreateIncidentStatusParams struct {
OrgID uuid.UUID
Name string
Color string
}
func (q *Queries) CreateIncidentStatus(ctx context.Context, arg CreateIncidentStatusParams) (IncidentStatus, error) {
row := q.db.QueryRow(ctx, createIncidentStatus, arg.OrgID, arg.Name, arg.Color)
var i IncidentStatus
err := row.Scan(
&i.ID,
&i.OrgID,
&i.Name,
&i.Color,
&i.CreatedAt,
)
return i, err
}
const deleteChannel = `-- name: DeleteChannel :execrows const deleteChannel = `-- name: DeleteChannel :execrows
DELETE FROM notification_channels WHERE id = $1 DELETE FROM notification_channels WHERE id = $1
` `
@@ -132,6 +158,18 @@ func (q *Queries) DeleteChannel(ctx context.Context, id uuid.UUID) (int64, error
return result.RowsAffected(), nil return result.RowsAffected(), nil
} }
const deleteIncidentStatus = `-- name: DeleteIncidentStatus :execrows
DELETE FROM incident_statuses WHERE id = $1
`
func (q *Queries) DeleteIncidentStatus(ctx context.Context, id uuid.UUID) (int64, error) {
result, err := q.db.Exec(ctx, deleteIncidentStatus, id)
if err != nil {
return 0, err
}
return result.RowsAffected(), nil
}
const deleteIncidentUpdate = `-- name: DeleteIncidentUpdate :execrows const deleteIncidentUpdate = `-- name: DeleteIncidentUpdate :execrows
DELETE FROM incident_updates WHERE id = $1 AND incident_id = $2 DELETE FROM incident_updates WHERE id = $1 AND incident_id = $2
` `
@@ -193,7 +231,7 @@ func (q *Queries) GetChannel(ctx context.Context, id uuid.UUID) (NotificationCha
} }
const getIncident = `-- name: GetIncident :one const getIncident = `-- name: GetIncident :one
SELECT i.id, i.org_id, i.monitor_id, i.started_at, i.resolved_at, i.cause, i.title, i.status, m.name AS monitor_name, m.group_id AS monitor_group_id SELECT i.id, i.org_id, i.monitor_id, i.started_at, i.resolved_at, i.cause, i.title, i.status, i.status_id, m.name AS monitor_name, m.group_id AS monitor_group_id
FROM incidents i JOIN monitors m ON m.id = i.monitor_id FROM incidents i JOIN monitors m ON m.id = i.monitor_id
WHERE i.id = $1 WHERE i.id = $1
` `
@@ -207,6 +245,7 @@ type GetIncidentRow struct {
Cause []byte Cause []byte
Title string Title string
Status *string Status *string
StatusID *uuid.UUID
MonitorName string MonitorName string
MonitorGroupID *uuid.UUID MonitorGroupID *uuid.UUID
} }
@@ -223,6 +262,7 @@ func (q *Queries) GetIncident(ctx context.Context, id uuid.UUID) (GetIncidentRow
&i.Cause, &i.Cause,
&i.Title, &i.Title,
&i.Status, &i.Status,
&i.StatusID,
&i.MonitorName, &i.MonitorName,
&i.MonitorGroupID, &i.MonitorGroupID,
) )
@@ -230,7 +270,7 @@ func (q *Queries) GetIncident(ctx context.Context, id uuid.UUID) (GetIncidentRow
} }
const incidentsForMonitors = `-- name: IncidentsForMonitors :many const incidentsForMonitors = `-- name: IncidentsForMonitors :many
SELECT id, org_id, monitor_id, started_at, resolved_at, cause, title, status FROM incidents SELECT id, org_id, monitor_id, started_at, resolved_at, cause, title, status, status_id FROM incidents
WHERE monitor_id = ANY ($1::uuid[]) AND (resolved_at IS NULL OR resolved_at > $2) WHERE monitor_id = ANY ($1::uuid[]) AND (resolved_at IS NULL OR resolved_at > $2)
ORDER BY started_at DESC ORDER BY started_at DESC
LIMIT 50 LIMIT 50
@@ -259,6 +299,7 @@ func (q *Queries) IncidentsForMonitors(ctx context.Context, arg IncidentsForMoni
&i.Cause, &i.Cause,
&i.Title, &i.Title,
&i.Status, &i.Status,
&i.StatusID,
); err != nil { ); err != nil {
return nil, err return nil, err
} }
@@ -335,8 +376,38 @@ func (q *Queries) ListChannels(ctx context.Context) ([]NotificationChannel, erro
return items, nil return items, nil
} }
const listIncidentStatuses = `-- name: ListIncidentStatuses :many
SELECT id, org_id, name, color, created_at FROM incident_statuses ORDER BY name
`
func (q *Queries) ListIncidentStatuses(ctx context.Context) ([]IncidentStatus, error) {
rows, err := q.db.Query(ctx, listIncidentStatuses)
if err != nil {
return nil, err
}
defer rows.Close()
items := []IncidentStatus{}
for rows.Next() {
var i IncidentStatus
if err := rows.Scan(
&i.ID,
&i.OrgID,
&i.Name,
&i.Color,
&i.CreatedAt,
); err != nil {
return nil, err
}
items = append(items, i)
}
if err := rows.Err(); err != nil {
return nil, err
}
return items, nil
}
const listIncidentUpdates = `-- name: ListIncidentUpdates :many const listIncidentUpdates = `-- name: ListIncidentUpdates :many
SELECT u.id, u.org_id, u.incident_id, u.status, u.message, u.public, u.author_id, u.created_at, coalesce(nullif(usr.display_name, ''), usr.email::text, '')::text AS author_name SELECT u.id, u.org_id, u.incident_id, u.status, u.message, u.public, u.author_id, u.created_at, u.status_id, coalesce(nullif(usr.display_name, ''), usr.email::text, '')::text AS author_name
FROM incident_updates u LEFT JOIN users usr ON usr.id = u.author_id FROM incident_updates u LEFT JOIN users usr ON usr.id = u.author_id
WHERE u.incident_id = $1 WHERE u.incident_id = $1
ORDER BY u.created_at DESC, u.id DESC ORDER BY u.created_at DESC, u.id DESC
@@ -351,6 +422,7 @@ type ListIncidentUpdatesRow struct {
Public bool Public bool
AuthorID *uuid.UUID AuthorID *uuid.UUID
CreatedAt time.Time CreatedAt time.Time
StatusID *uuid.UUID
AuthorName string AuthorName string
} }
@@ -373,6 +445,7 @@ func (q *Queries) ListIncidentUpdates(ctx context.Context, incidentID uuid.UUID)
&i.Public, &i.Public,
&i.AuthorID, &i.AuthorID,
&i.CreatedAt, &i.CreatedAt,
&i.StatusID,
&i.AuthorName, &i.AuthorName,
); err != nil { ); err != nil {
return nil, err return nil, err
@@ -386,7 +459,7 @@ func (q *Queries) ListIncidentUpdates(ctx context.Context, incidentID uuid.UUID)
} }
const listIncidents = `-- name: ListIncidents :many const listIncidents = `-- name: ListIncidents :many
SELECT i.id, i.org_id, i.monitor_id, i.started_at, i.resolved_at, i.cause, i.title, i.status, m.name AS monitor_name SELECT i.id, i.org_id, i.monitor_id, i.started_at, i.resolved_at, i.cause, i.title, i.status, i.status_id, m.name AS monitor_name
FROM incidents i FROM incidents i
JOIN monitors m ON m.id = i.monitor_id JOIN monitors m ON m.id = i.monitor_id
WHERE ($1::uuid IS NULL OR i.monitor_id = $1) WHERE ($1::uuid IS NULL OR i.monitor_id = $1)
@@ -417,6 +490,7 @@ type ListIncidentsRow struct {
Cause []byte Cause []byte
Title string Title string
Status *string Status *string
StatusID *uuid.UUID
MonitorName string MonitorName string
} }
@@ -447,6 +521,7 @@ func (q *Queries) ListIncidents(ctx context.Context, arg ListIncidentsParams) ([
&i.Cause, &i.Cause,
&i.Title, &i.Title,
&i.Status, &i.Status,
&i.StatusID,
&i.MonitorName, &i.MonitorName,
); err != nil { ); err != nil {
return nil, err return nil, err
@@ -564,7 +639,7 @@ const openIncident = `-- name: OpenIncident :one
INSERT INTO incidents (org_id, monitor_id, started_at, cause) INSERT INTO incidents (org_id, monitor_id, started_at, cause)
VALUES ($1, $2, $3, $4) VALUES ($1, $2, $3, $4)
ON CONFLICT (monitor_id) WHERE resolved_at IS NULL DO NOTHING ON CONFLICT (monitor_id) WHERE resolved_at IS NULL DO NOTHING
RETURNING id, org_id, monitor_id, started_at, resolved_at, cause, title, status RETURNING id, org_id, monitor_id, started_at, resolved_at, cause, title, status, status_id
` `
type OpenIncidentParams struct { type OpenIncidentParams struct {
@@ -591,12 +666,13 @@ func (q *Queries) OpenIncident(ctx context.Context, arg OpenIncidentParams) (Inc
&i.Cause, &i.Cause,
&i.Title, &i.Title,
&i.Status, &i.Status,
&i.StatusID,
) )
return i, err return i, err
} }
const openIncidents = `-- name: OpenIncidents :many const openIncidents = `-- name: OpenIncidents :many
SELECT id, org_id, monitor_id, started_at, resolved_at, cause, title, status FROM incidents WHERE resolved_at IS NULL SELECT id, org_id, monitor_id, started_at, resolved_at, cause, title, status, status_id FROM incidents WHERE resolved_at IS NULL
` `
func (q *Queries) OpenIncidents(ctx context.Context) ([]Incident, error) { func (q *Queries) OpenIncidents(ctx context.Context) ([]Incident, error) {
@@ -617,6 +693,7 @@ func (q *Queries) OpenIncidents(ctx context.Context) ([]Incident, error) {
&i.Cause, &i.Cause,
&i.Title, &i.Title,
&i.Status, &i.Status,
&i.StatusID,
); err != nil { ); err != nil {
return nil, err return nil, err
} }
@@ -629,7 +706,7 @@ func (q *Queries) OpenIncidents(ctx context.Context) ([]Incident, error) {
} }
const publicIncidentUpdates = `-- name: PublicIncidentUpdates :many const publicIncidentUpdates = `-- name: PublicIncidentUpdates :many
SELECT incident_id, status, message, created_at FROM incident_updates SELECT incident_id, status, status_id, message, created_at FROM incident_updates
WHERE incident_id = ANY($1::uuid[]) AND public WHERE incident_id = ANY($1::uuid[]) AND public
ORDER BY created_at DESC, id DESC ORDER BY created_at DESC, id DESC
` `
@@ -637,6 +714,7 @@ ORDER BY created_at DESC, id DESC
type PublicIncidentUpdatesRow struct { type PublicIncidentUpdatesRow struct {
IncidentID uuid.UUID IncidentID uuid.UUID
Status string Status string
StatusID *uuid.UUID
Message string Message string
CreatedAt time.Time CreatedAt time.Time
} }
@@ -654,6 +732,7 @@ func (q *Queries) PublicIncidentUpdates(ctx context.Context, ids []uuid.UUID) ([
if err := rows.Scan( if err := rows.Scan(
&i.IncidentID, &i.IncidentID,
&i.Status, &i.Status,
&i.StatusID,
&i.Message, &i.Message,
&i.CreatedAt, &i.CreatedAt,
); err != nil { ); err != nil {
@@ -668,8 +747,8 @@ func (q *Queries) PublicIncidentUpdates(ctx context.Context, ids []uuid.UUID) ([
} }
const refreshIncidentStatus = `-- name: RefreshIncidentStatus :exec const refreshIncidentStatus = `-- name: RefreshIncidentStatus :exec
UPDATE incidents SET status = ( UPDATE incidents SET (status, status_id) = (
SELECT u.status FROM incident_updates u WHERE u.incident_id = incidents.id SELECT u.status, u.status_id FROM incident_updates u WHERE u.incident_id = incidents.id
ORDER BY u.created_at DESC, u.id DESC LIMIT 1 ORDER BY u.created_at DESC, u.id DESC LIMIT 1
) WHERE incidents.id = $1 ) WHERE incidents.id = $1
` `
@@ -683,7 +762,7 @@ func (q *Queries) RefreshIncidentStatus(ctx context.Context, id uuid.UUID) error
const resolveIncident = `-- name: ResolveIncident :one const resolveIncident = `-- name: ResolveIncident :one
UPDATE incidents SET resolved_at = $1 UPDATE incidents SET resolved_at = $1
WHERE monitor_id = $2 AND resolved_at IS NULL WHERE monitor_id = $2 AND resolved_at IS NULL
RETURNING id, org_id, monitor_id, started_at, resolved_at, cause, title, status RETURNING id, org_id, monitor_id, started_at, resolved_at, cause, title, status, status_id
` `
type ResolveIncidentParams struct { type ResolveIncidentParams struct {
@@ -703,6 +782,7 @@ func (q *Queries) ResolveIncident(ctx context.Context, arg ResolveIncidentParams
&i.Cause, &i.Cause,
&i.Title, &i.Title,
&i.Status, &i.Status,
&i.StatusID,
) )
return i, err return i, err
} }
@@ -757,3 +837,21 @@ func (q *Queries) UpdateChannel(ctx context.Context, arg UpdateChannelParams) (N
) )
return i, err return i, err
} }
const updateIncidentStatus = `-- name: UpdateIncidentStatus :execrows
UPDATE incident_statuses SET name = $1, color = $2 WHERE id = $3
`
type UpdateIncidentStatusParams struct {
Name string
Color string
ID uuid.UUID
}
func (q *Queries) UpdateIncidentStatus(ctx context.Context, arg UpdateIncidentStatusParams) (int64, error) {
result, err := q.db.Exec(ctx, updateIncidentStatus, arg.Name, arg.Color, arg.ID)
if err != nil {
return 0, err
}
return result.RowsAffected(), nil
}
+10
View File
@@ -162,6 +162,15 @@ type Incident struct {
Cause []byte Cause []byte
Title string Title string
Status *string Status *string
StatusID *uuid.UUID
}
type IncidentStatus struct {
ID uuid.UUID
OrgID uuid.UUID
Name string
Color string
CreatedAt time.Time
} }
type IncidentUpdate struct { type IncidentUpdate struct {
@@ -173,6 +182,7 @@ type IncidentUpdate struct {
Public bool Public bool
AuthorID *uuid.UUID AuthorID *uuid.UUID
CreatedAt time.Time CreatedAt time.Time
StatusID *uuid.UUID
} }
type Invitation struct { type Invitation struct {
+4
View File
@@ -65,6 +65,7 @@ type Querier interface {
CreateChannel(ctx context.Context, arg CreateChannelParams) (NotificationChannel, error) CreateChannel(ctx context.Context, arg CreateChannelParams) (NotificationChannel, error)
CreateGroup(ctx context.Context, arg CreateGroupParams) (MonitorGroup, error) CreateGroup(ctx context.Context, arg CreateGroupParams) (MonitorGroup, error)
CreateIdentity(ctx context.Context, arg CreateIdentityParams) error CreateIdentity(ctx context.Context, arg CreateIdentityParams) error
CreateIncidentStatus(ctx context.Context, arg CreateIncidentStatusParams) (IncidentStatus, error)
CreateInvitation(ctx context.Context, arg CreateInvitationParams) (Invitation, error) CreateInvitation(ctx context.Context, arg CreateInvitationParams) (Invitation, error)
CreateMaintenance(ctx context.Context, arg CreateMaintenanceParams) (MaintenanceWindow, error) CreateMaintenance(ctx context.Context, arg CreateMaintenanceParams) (MaintenanceWindow, error)
CreateMonitor(ctx context.Context, arg CreateMonitorParams) (Monitor, error) CreateMonitor(ctx context.Context, arg CreateMonitorParams) (Monitor, error)
@@ -89,6 +90,7 @@ type Querier interface {
DeleteAssignmentsForResource(ctx context.Context, arg DeleteAssignmentsForResourceParams) error DeleteAssignmentsForResource(ctx context.Context, arg DeleteAssignmentsForResourceParams) error
DeleteChannel(ctx context.Context, id uuid.UUID) (int64, error) DeleteChannel(ctx context.Context, id uuid.UUID) (int64, error)
DeleteGroup(ctx context.Context, id uuid.UUID) (int64, error) DeleteGroup(ctx context.Context, id uuid.UUID) (int64, error)
DeleteIncidentStatus(ctx context.Context, id uuid.UUID) (int64, error)
DeleteIncidentUpdate(ctx context.Context, arg DeleteIncidentUpdateParams) (int64, error) DeleteIncidentUpdate(ctx context.Context, arg DeleteIncidentUpdateParams) (int64, error)
DeleteInvitation(ctx context.Context, id uuid.UUID) (int64, error) DeleteInvitation(ctx context.Context, id uuid.UUID) (int64, error)
DeleteInvitationsForEmail(ctx context.Context, email string) error DeleteInvitationsForEmail(ctx context.Context, email string) error
@@ -205,6 +207,7 @@ type Querier interface {
// Newest first, a page from a keyset cursor (see paging.go). // Newest first, a page from a keyset cursor (see paging.go).
ListEvidence(ctx context.Context, arg ListEvidenceParams) ([]ListEvidenceRow, error) ListEvidence(ctx context.Context, arg ListEvidenceParams) ([]ListEvidenceRow, error)
ListGroups(ctx context.Context) ([]MonitorGroup, error) ListGroups(ctx context.Context) ([]MonitorGroup, error)
ListIncidentStatuses(ctx context.Context) ([]IncidentStatus, error)
// Newest first, with the author's name. // Newest first, with the author's name.
ListIncidentUpdates(ctx context.Context, incidentID uuid.UUID) ([]ListIncidentUpdatesRow, error) ListIncidentUpdates(ctx context.Context, incidentID uuid.UUID) ([]ListIncidentUpdatesRow, error)
// Newest first, a page from a keyset cursor (see paging.go); optionally of // Newest first, a page from a keyset cursor (see paging.go); optionally of
@@ -355,6 +358,7 @@ type Querier interface {
UpdateAlertGroup(ctx context.Context, arg UpdateAlertGroupParams) (AlertGroup, error) UpdateAlertGroup(ctx context.Context, arg UpdateAlertGroupParams) (AlertGroup, error)
UpdateChannel(ctx context.Context, arg UpdateChannelParams) (NotificationChannel, error) UpdateChannel(ctx context.Context, arg UpdateChannelParams) (NotificationChannel, error)
UpdateGroup(ctx context.Context, arg UpdateGroupParams) (MonitorGroup, error) UpdateGroup(ctx context.Context, arg UpdateGroupParams) (MonitorGroup, error)
UpdateIncidentStatus(ctx context.Context, arg UpdateIncidentStatusParams) (int64, error)
UpdateMaintenance(ctx context.Context, arg UpdateMaintenanceParams) (MaintenanceWindow, error) UpdateMaintenance(ctx context.Context, arg UpdateMaintenanceParams) (MaintenanceWindow, error)
UpdateMonitor(ctx context.Context, arg UpdateMonitorParams) (Monitor, error) UpdateMonitor(ctx context.Context, arg UpdateMonitorParams) (Monitor, error)
UpdateOrgPolicy(ctx context.Context, arg UpdateOrgPolicyParams) (Org, error) UpdateOrgPolicy(ctx context.Context, arg UpdateOrgPolicyParams) (Org, error)
+17 -5
View File
@@ -106,8 +106,8 @@ WHERE i.id = $1;
UPDATE incidents SET title = sqlc.arg(title) WHERE id = sqlc.arg(id); UPDATE incidents SET title = sqlc.arg(title) WHERE id = sqlc.arg(id);
-- name: AddIncidentUpdate :one -- name: AddIncidentUpdate :one
INSERT INTO incident_updates (org_id, incident_id, status, message, public, author_id) INSERT INTO incident_updates (org_id, incident_id, status, status_id, message, public, author_id)
VALUES ($1, $2, $3, $4, $5, $6) VALUES ($1, $2, $3, $4, $5, $6, $7)
RETURNING *; RETURNING *;
-- name: DeleteIncidentUpdate :execrows -- name: DeleteIncidentUpdate :execrows
@@ -115,8 +115,8 @@ DELETE FROM incident_updates WHERE id = sqlc.arg(id) AND incident_id = sqlc.arg(
-- name: RefreshIncidentStatus :exec -- name: RefreshIncidentStatus :exec
-- The incident shows the status of its latest update. -- The incident shows the status of its latest update.
UPDATE incidents SET status = ( UPDATE incidents SET (status, status_id) = (
SELECT u.status FROM incident_updates u WHERE u.incident_id = incidents.id SELECT u.status, u.status_id FROM incident_updates u WHERE u.incident_id = incidents.id
ORDER BY u.created_at DESC, u.id DESC LIMIT 1 ORDER BY u.created_at DESC, u.id DESC LIMIT 1
) WHERE incidents.id = $1; ) WHERE incidents.id = $1;
@@ -129,6 +129,18 @@ ORDER BY u.created_at DESC, u.id DESC;
-- name: PublicIncidentUpdates :many -- name: PublicIncidentUpdates :many
-- The public updates of incidents shown on a status page, newest first. -- The public updates of incidents shown on a status page, newest first.
SELECT incident_id, status, message, created_at FROM incident_updates SELECT incident_id, status, status_id, message, created_at FROM incident_updates
WHERE incident_id = ANY(sqlc.arg(ids)::uuid[]) AND public WHERE incident_id = ANY(sqlc.arg(ids)::uuid[]) AND public
ORDER BY created_at DESC, id DESC; ORDER BY created_at DESC, id DESC;
-- name: ListIncidentStatuses :many
SELECT * FROM incident_statuses ORDER BY name;
-- name: CreateIncidentStatus :one
INSERT INTO incident_statuses (org_id, name, color) VALUES ($1, $2, $3) RETURNING *;
-- name: UpdateIncidentStatus :execrows
UPDATE incident_statuses SET name = sqlc.arg(name), color = sqlc.arg(color) WHERE id = sqlc.arg(id);
-- name: DeleteIncidentStatus :execrows
DELETE FROM incident_statuses WHERE id = $1;
+3
View File
@@ -249,6 +249,9 @@ templ SettingsIndex(p Page, me Me) {
@settingsLink("/settings/channels", "channels.title", "settings.channels") @settingsLink("/settings/channels", "channels.title", "settings.channels")
} }
@settingsLink("/groups", "groups.title", "settings.groups") @settingsLink("/groups", "groups.title", "settings.groups")
if me.Can["incidents.read"] {
@settingsLink("/settings/incident-statuses", "incident_statuses.title", "settings.incident_statuses")
}
if me.Can["members.read"] { if me.Can["members.read"] {
@settingsLink("/settings/members", "console.nav.members", "settings.members") @settingsLink("/settings/members", "console.nav.members", "settings.members")
@settingsLink("/settings/roles", "console.nav.roles", "settings.roles") @settingsLink("/settings/roles", "console.nav.roles", "settings.roles")
+6
View File
@@ -1200,6 +1200,12 @@ func SettingsIndex(p Page, me Me) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
if me.Can["incidents.read"] {
templ_7745c5c3_Err = settingsLink("/settings/incident-statuses", "incident_statuses.title", "settings.incident_statuses").Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
if me.Can["members.read"] { if me.Can["members.read"] {
templ_7745c5c3_Err = settingsLink("/settings/members", "console.nav.members", "settings.members").Render(ctx, templ_7745c5c3_Buffer) templ_7745c5c3_Err = settingsLink("/settings/members", "console.nav.members", "settings.members").Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
+19 -1
View File
@@ -4,6 +4,21 @@ package web
// usual order. // usual order.
var IncidentStatuses = []string{"investigating", "identified", "monitoring", "resolved"} var IncidentStatuses = []string{"investigating", "identified", "monitoring", "resolved"}
// IncidentStatusInfo is an incident's status as shown: a built-in key, or
// "custom" with the organization's name and color.
type IncidentStatusInfo struct {
Key string
Name string
Color string
}
// CustomIncidentStatus is a status an organization added.
type CustomIncidentStatus struct {
ID string
Name string
Color string
}
// incidentStatusClass colors an incident status: red while it is being // incidentStatusClass colors an incident status: red while it is being
// worked on, amber while watched, green once resolved. // worked on, amber while watched, green once resolved.
func incidentStatusClass(status string) string { func incidentStatusClass(status string) string {
@@ -23,7 +38,8 @@ type IncidentTimelineEntry struct {
// Kind is update, started or resolved. // Kind is update, started or resolved.
Kind string Kind string
// Update fields. // Update fields.
ID, Status, HTML, Author string ID, HTML, Author string
Status IncidentStatusInfo
Public bool Public bool
} }
@@ -34,4 +50,6 @@ type IncidentDetailView struct {
Timeline []IncidentTimelineEntry Timeline []IncidentTimelineEntry
// NextStatus preselects the status of the next update. // NextStatus preselects the status of the next update.
NextStatus string NextStatus string
// Custom are the organization's own statuses to choose from.
Custom []CustomIncidentStatus
} }
+57 -1
View File
@@ -288,7 +288,7 @@ type IncidentRow struct {
Cause []string Cause []string
// Title and Status are what the organization said about it. // Title and Status are what the organization said about it.
Title string Title string
Status string Status IncidentStatusInfo
} }
// MonitorDetailView is the data of a monitor page. // MonitorDetailView is the data of a monitor page.
@@ -1432,6 +1432,9 @@ templ IncidentDetailPage(p Page, me Me, v IncidentDetailView) {
for _, st := range IncidentStatuses { for _, st := range IncidentStatuses {
<option value={ st } selected?={ st == v.NextStatus }>{ i18n.T(ctx, "incident.status."+st) }</option> <option value={ st } selected?={ st == v.NextStatus }>{ i18n.T(ctx, "incident.status."+st) }</option>
} }
for _, st := range v.Custom {
<option value={ st.ID } selected?={ st.ID == v.NextStatus }>{ st.Name }</option>
}
</select> </select>
</label> </label>
<div class="mb-4"> <div class="mb-4">
@@ -1456,3 +1459,56 @@ templ IncidentDetailPage(p Page, me Me, v IncidentDetailView) {
</div> </div>
} }
} }
// IncidentStatusesPage lists the organization's own incident statuses and,
// for those who manage the organization, edits them.
templ IncidentStatusesPage(p Page, me Me, statuses []CustomIncidentStatus, canManage bool) {
@consoleShell(p, me) {
@settingsHeading("incident_statuses.title", "incident_statuses.intro")
<section class="mb-12 max-w-2xl">
@sectionHeading("incident_statuses.builtin")
<ul class="flex flex-wrap gap-4 text-sm">
for _, st := range IncidentStatuses {
<li>@incidentStatusLabel(IncidentStatusInfo{Key: st}, true)</li>
}
</ul>
</section>
<section class="mb-12 max-w-2xl">
@sectionHeading("incident_statuses.own")
if len(statuses) == 0 {
<p class="text-sm text-muted">{ i18n.T(ctx, "incident_statuses.none") }</p>
}
<ul class="divide-y divide-rule border-y border-rule">
for _, st := range statuses {
<li class="py-3">
if canManage {
<form data-api={ "/org/incident-statuses/" + st.ID } data-method="put" data-next="/settings/incident-statuses" class="flex flex-wrap items-center gap-3">
<input type="color" name="color" value={ st.Color } class="h-8 w-10 cursor-pointer border border-rule bg-transparent" aria-label={ i18n.T(ctx, "incident_statuses.color") }/>
<input type="text" name="name" value={ st.Name } maxlength="40" required class="min-w-0 flex-1 border border-rule bg-transparent px-2.5 py-1.5 text-sm outline-none focus:border-ink"/>
<button type="submit" class="border border-ink px-3 py-1.5 text-sm hover:bg-ink hover:text-paper">{ i18n.T(ctx, "common.save") }</button>
<button type="button" data-delete={ "/org/incident-statuses/" + st.ID } data-confirm={ i18n.T(ctx, "incident_statuses.delete_confirm") } class="text-sm text-muted hover:text-down">{ i18n.T(ctx, "incident.delete") }</button>
<p data-error class="hidden w-full text-xs text-down"></p>
</form>
} else {
@incidentStatusLabel(IncidentStatusInfo{Key: "custom", Name: st.Name, Color: st.Color}, true)
}
</li>
}
</ul>
if canManage {
<form data-api="/org/incident-statuses" data-next="/settings/incident-statuses" class="mt-6 flex flex-wrap items-end gap-3">
<label class="block">
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "incident_statuses.color") }</span>
<input type="color" name="color" value="#7c3aed" class="h-9 w-12 cursor-pointer border border-rule bg-transparent"/>
</label>
<label class="block min-w-0 flex-1">
<span class="mb-1 block text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "sso.field.name") }</span>
<input type="text" name="name" maxlength="40" required placeholder={ i18n.T(ctx, "incident_statuses.placeholder") } class="w-full border border-rule bg-transparent px-2.5 py-1.5 text-sm outline-none focus:border-ink"/>
</label>
<button type="submit" class="bg-ink px-3 py-2 text-sm text-paper">{ i18n.T(ctx, "incident_statuses.add") }</button>
<p data-error class="hidden w-full text-xs text-down"></p>
</form>
}
</section>
}
}
+369 -34
View File
@@ -1114,7 +1114,7 @@ type IncidentRow struct {
Cause []string Cause []string
// Title and Status are what the organization said about it. // Title and Status are what the organization said about it.
Title string Title string
Status string Status IncidentStatusInfo
} }
// MonitorDetailView is the data of a monitor page. // MonitorDetailView is the data of a monitor page.
@@ -7175,25 +7175,67 @@ func IncidentDetailPage(p Page, me Me, v IncidentDetailView) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 596, "</option>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 596, "</option> ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 597, "</select></label><div class=\"mb-4\"><span class=\"mb-1 block text-xs font-medium uppercase tracking-wider text-muted\">") for _, st := range v.Custom {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 597, "<option value=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var336 string var templ_7745c5c3_Var336 string
templ_7745c5c3_Var336, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incident.message")) templ_7745c5c3_Var336, templ_7745c5c3_Err = templruntime.NewAttributeExpression(st.ID).Resolve(ctx)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1438, Col: 121} return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1436, Col: 30}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var336)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var336)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 598, "</span>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 598, "\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if st.ID == v.NextStatus {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 599, " selected")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 600, ">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var337 string
templ_7745c5c3_Var337, templ_7745c5c3_Err = templ.JoinStringErrs(st.Name)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1436, Col: 78}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var337))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 601, "</option>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 602, "</select></label><div class=\"mb-4\"><span class=\"mb-1 block text-xs font-medium uppercase tracking-wider text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var338 string
templ_7745c5c3_Var338, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incident.message"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1441, Col: 121}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var338))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 603, "</span>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@@ -7201,7 +7243,7 @@ func IncidentDetailPage(p Page, me Me, v IncidentDetailView) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 599, "</div>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 604, "</div>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@@ -7209,20 +7251,20 @@ func IncidentDetailPage(p Page, me Me, v IncidentDetailView) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 600, "<p class=\"-mt-2 mb-4 ml-6 text-xs text-muted\">") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 605, "<p class=\"-mt-2 mb-4 ml-6 text-xs text-muted\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var337 string var templ_7745c5c3_Var339 string
templ_7745c5c3_Var337, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incident.public_hint")) templ_7745c5c3_Var339, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incident.public_hint"))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1442, Col: 89} return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1445, Col: 89}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var337)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var339))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 601, "</p>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 606, "</p>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@@ -7230,7 +7272,7 @@ func IncidentDetailPage(p Page, me Me, v IncidentDetailView) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 602, "</form><div class=\"mt-10\">") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 607, "</form><div class=\"mt-10\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@@ -7238,33 +7280,33 @@ func IncidentDetailPage(p Page, me Me, v IncidentDetailView) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 603, "<form data-api=\"") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 608, "<form data-api=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var338 string var templ_7745c5c3_Var340 string
templ_7745c5c3_Var338, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/org/incidents/" + v.Row.ID).Resolve(ctx) templ_7745c5c3_Var340, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/org/incidents/" + v.Row.ID).Resolve(ctx)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1447, Col: 51} return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1450, Col: 51}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var338) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var340)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 604, "\" data-method=\"patch\" data-next=\"") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 609, "\" data-method=\"patch\" data-next=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var339 string var templ_7745c5c3_Var341 string
templ_7745c5c3_Var339, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/incidents/" + v.Row.ID).Resolve(ctx) templ_7745c5c3_Var341, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/incidents/" + v.Row.ID).Resolve(ctx)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1447, Col: 110} return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1450, Col: 110}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var339) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var341)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 605, "\">") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 610, "\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@@ -7276,20 +7318,20 @@ func IncidentDetailPage(p Page, me Me, v IncidentDetailView) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 606, "<p class=\"-mt-2 mb-4 text-xs text-muted\">") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 611, "<p class=\"-mt-2 mb-4 text-xs text-muted\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var340 string var templ_7745c5c3_Var342 string
templ_7745c5c3_Var340, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incident.title_hint")) templ_7745c5c3_Var342, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incident.title_hint"))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1450, Col: 84} return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1453, Col: 84}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var340)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var342))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 607, "</p>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 612, "</p>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@@ -7297,12 +7339,12 @@ func IncidentDetailPage(p Page, me Me, v IncidentDetailView) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 608, "</form></div></aside>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 613, "</form></div></aside>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 609, "</div>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 614, "</div>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@@ -7316,4 +7358,297 @@ func IncidentDetailPage(p Page, me Me, v IncidentDetailView) templ.Component {
}) })
} }
// IncidentStatusesPage lists the organization's own incident statuses and,
// for those who manage the organization, edits them.
func IncidentStatusesPage(p Page, me Me, statuses []CustomIncidentStatus, canManage bool) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
return templ_7745c5c3_CtxErr
}
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
ctx = templ.ClearChildren(ctx)
templ_7745c5c3_Var344 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Err = settingsHeading("incident_statuses.title", "incident_statuses.intro").Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 615, "<section class=\"mb-12 max-w-2xl\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = sectionHeading("incident_statuses.builtin").Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 616, "<ul class=\"flex flex-wrap gap-4 text-sm\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, st := range IncidentStatuses {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 617, "<li>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = incidentStatusLabel(IncidentStatusInfo{Key: st}, true).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 618, "</li>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 619, "</ul></section><section class=\"mb-12 max-w-2xl\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = sectionHeading("incident_statuses.own").Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if len(statuses) == 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 620, "<p class=\"text-sm text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var345 string
templ_7745c5c3_Var345, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incident_statuses.none"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1479, Col: 73}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var345))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 621, "</p>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 622, "<ul class=\"divide-y divide-rule border-y border-rule\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for _, st := range statuses {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 623, "<li class=\"py-3\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if canManage {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 624, "<form data-api=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var346 string
templ_7745c5c3_Var346, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/org/incident-statuses/" + st.ID).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1485, Col: 57}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var346)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 625, "\" data-method=\"put\" data-next=\"/settings/incident-statuses\" class=\"flex flex-wrap items-center gap-3\"><input type=\"color\" name=\"color\" value=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var347 string
templ_7745c5c3_Var347, templ_7745c5c3_Err = templruntime.NewAttributeExpression(st.Color).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1486, Col: 57}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var347)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 626, "\" class=\"h-8 w-10 cursor-pointer border border-rule bg-transparent\" aria-label=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var348 string
templ_7745c5c3_Var348, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "incident_statuses.color")).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1486, Col: 177}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var348)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 627, "\"> <input type=\"text\" name=\"name\" value=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var349 string
templ_7745c5c3_Var349, templ_7745c5c3_Err = templruntime.NewAttributeExpression(st.Name).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1487, Col: 54}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var349)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 628, "\" maxlength=\"40\" required class=\"min-w-0 flex-1 border border-rule bg-transparent px-2.5 py-1.5 text-sm outline-none focus:border-ink\"> <button type=\"submit\" class=\"border border-ink px-3 py-1.5 text-sm hover:bg-ink hover:text-paper\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var350 string
templ_7745c5c3_Var350, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "common.save"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1488, Col: 134}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var350))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 629, "</button> <button type=\"button\" data-delete=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var351 string
templ_7745c5c3_Var351, templ_7745c5c3_Err = templruntime.NewAttributeExpression("/org/incident-statuses/" + st.ID).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1489, Col: 77}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var351)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 630, "\" data-confirm=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var352 string
templ_7745c5c3_Var352, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "incident_statuses.delete_confirm")).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1489, Col: 142}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var352)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 631, "\" class=\"text-sm text-muted hover:text-down\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var353 string
templ_7745c5c3_Var353, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incident.delete"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1489, Col: 220}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var353))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 632, "</button><p data-error class=\"hidden w-full text-xs text-down\"></p></form>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
} else {
templ_7745c5c3_Err = incidentStatusLabel(IncidentStatusInfo{Key: "custom", Name: st.Name, Color: st.Color}, true).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 633, "</li>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 634, "</ul>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if canManage {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 635, "<form data-api=\"/org/incident-statuses\" data-next=\"/settings/incident-statuses\" class=\"mt-6 flex flex-wrap items-end gap-3\"><label class=\"block\"><span class=\"mb-1 block text-xs font-medium uppercase tracking-wider text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var354 string
templ_7745c5c3_Var354, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incident_statuses.color"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1501, Col: 127}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var354))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 636, "</span> <input type=\"color\" name=\"color\" value=\"#7c3aed\" class=\"h-9 w-12 cursor-pointer border border-rule bg-transparent\"></label> <label class=\"block min-w-0 flex-1\"><span class=\"mb-1 block text-xs font-medium uppercase tracking-wider text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var355 string
templ_7745c5c3_Var355, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "sso.field.name"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1505, Col: 118}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var355))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 637, "</span> <input type=\"text\" name=\"name\" maxlength=\"40\" required placeholder=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var356 string
templ_7745c5c3_Var356, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "incident_statuses.placeholder")).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1506, Col: 119}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var356)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 638, "\" class=\"w-full border border-rule bg-transparent px-2.5 py-1.5 text-sm outline-none focus:border-ink\"></label> <button type=\"submit\" class=\"bg-ink px-3 py-2 text-sm text-paper\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var357 string
templ_7745c5c3_Var357, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incident_statuses.add"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/monitors.templ`, Line: 1508, Col: 109}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var357))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 639, "</button><p data-error class=\"hidden w-full text-xs text-down\"></p></form>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 640, "</section>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var344), templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate var _ = templruntime.GeneratedTemplate
+14 -8
View File
@@ -92,8 +92,8 @@ templ PublicStatusPage(s agentapi.PageSnapshot, a PublicAssets) {
} }
</section> </section>
} }
@pageMaintenance(i18n.T(ctx, "page.maintenance_upcoming"), s.Upcoming(a.Now))
@publicIncidents(s.Incidents) @publicIncidents(s.Incidents)
@pageMaintenance(i18n.T(ctx, "page.maintenance_upcoming"), s.Upcoming(a.Now))
} }
} }
@@ -244,8 +244,8 @@ templ PublicComponentPage(s agentapi.PageSnapshot, comp agentapi.Component, a Pu
<span>{ i18n.T(ctx, "page.today") }</span> <span>{ i18n.T(ctx, "page.today") }</span>
</div> </div>
</section> </section>
@pageMaintenance(i18n.T(ctx, "page.maintenance_upcoming"), upcoming)
@publicIncidents(s.IncidentsForComponent(comp.Name)) @publicIncidents(s.IncidentsForComponent(comp.Name))
@pageMaintenance(i18n.T(ctx, "page.maintenance_upcoming"), upcoming)
} }
} }
@@ -295,7 +295,7 @@ templ publicIncidents(incidents []agentapi.PageIncident) {
for _, inc := range incidents { for _, inc := range incidents {
<li class="py-3"> <li class="py-3">
<div class="flex flex-wrap items-baseline gap-x-4 gap-y-1"> <div class="flex flex-wrap items-baseline gap-x-4 gap-y-1">
@incidentStatusLabel(inc.Status, inc.ResolvedAt == nil) @incidentStatusLabel(IncidentStatusInfo{Key: inc.Status, Name: inc.StatusName, Color: inc.StatusColor}, inc.ResolvedAt == nil)
if inc.Title != "" { if inc.Title != "" {
<span class="font-medium">{ inc.Title }</span> <span class="font-medium">{ inc.Title }</span>
<span class="text-xs text-muted">{ inc.Component }</span> <span class="text-xs text-muted">{ inc.Component }</span>
@@ -315,7 +315,7 @@ templ publicIncidents(incidents []agentapi.PageIncident) {
for _, u := range inc.Updates { for _, u := range inc.Updates {
<li> <li>
<p class="text-xs"> <p class="text-xs">
@incidentStatusLabel(u.Status, true) @incidentStatusLabel(IncidentStatusInfo{Key: u.Status, Name: u.StatusName, Color: u.StatusColor}, true)
<span class="font-mono text-muted">{ " · " + u.At.UTC().Format("2006-01-02 15:04") + " UTC" }</span> <span class="font-mono text-muted">{ " · " + u.At.UTC().Format("2006-01-02 15:04") + " UTC" }</span>
</p> </p>
<div class="legal-text mt-1"> <div class="legal-text mt-1">
@@ -333,11 +333,17 @@ templ publicIncidents(incidents []agentapi.PageIncident) {
} }
// incidentStatusLabel names an incident's status: what the organization // incidentStatusLabel names an incident's status: what the organization
// said, or ongoing or resolved when it said nothing. // said, in its own color for its own statuses, or ongoing or resolved when
templ incidentStatusLabel(status string, open bool) { // it said nothing.
templ incidentStatusLabel(st IncidentStatusInfo, open bool) {
switch { switch {
case status != "": case st.Key == "custom":
<span class={ "font-medium", incidentStatusClass(status) }>{ i18n.T(ctx, "incident.status."+status) }</span> <span class="inline-flex items-center gap-1.5 font-medium">
<span class="inline-block size-2 rounded-full" style={ "background-color:" + st.Color }></span>
{ st.Name }
</span>
case st.Key != "":
<span class={ "font-medium", incidentStatusClass(st.Key) }>{ i18n.T(ctx, "incident.status."+st.Key) }</span>
case open: case open:
<span class="font-medium text-down">{ i18n.T(ctx, "incidents.ongoing") }</span> <span class="font-medium text-down">{ i18n.T(ctx, "incidents.ongoing") }</span>
default: default:
+133 -101
View File
@@ -381,11 +381,11 @@ func PublicStatusPage(s agentapi.PageSnapshot, a PublicAssets) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = pageMaintenance(i18n.T(ctx, "page.maintenance_upcoming"), s.Upcoming(a.Now)).Render(ctx, templ_7745c5c3_Buffer) templ_7745c5c3_Err = publicIncidents(s.Incidents).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = publicIncidents(s.Incidents).Render(ctx, templ_7745c5c3_Buffer) templ_7745c5c3_Err = pageMaintenance(i18n.T(ctx, "page.maintenance_upcoming"), s.Upcoming(a.Now)).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@@ -1134,11 +1134,11 @@ func PublicComponentPage(s agentapi.PageSnapshot, comp agentapi.Component, a Pub
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = pageMaintenance(i18n.T(ctx, "page.maintenance_upcoming"), upcoming).Render(ctx, templ_7745c5c3_Buffer) templ_7745c5c3_Err = publicIncidents(s.IncidentsForComponent(comp.Name)).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = publicIncidents(s.IncidentsForComponent(comp.Name)).Render(ctx, templ_7745c5c3_Buffer) templ_7745c5c3_Err = pageMaintenance(i18n.T(ctx, "page.maintenance_upcoming"), upcoming).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@@ -1367,7 +1367,7 @@ func publicIncidents(incidents []agentapi.PageIncident) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = incidentStatusLabel(inc.Status, inc.ResolvedAt == nil).Render(ctx, templ_7745c5c3_Buffer) templ_7745c5c3_Err = incidentStatusLabel(IncidentStatusInfo{Key: inc.Status, Name: inc.StatusName, Color: inc.StatusColor}, inc.ResolvedAt == nil).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@@ -1471,7 +1471,7 @@ func publicIncidents(incidents []agentapi.PageIncident) templ.Component {
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = incidentStatusLabel(u.Status, true).Render(ctx, templ_7745c5c3_Buffer) templ_7745c5c3_Err = incidentStatusLabel(IncidentStatusInfo{Key: u.Status, Name: u.StatusName, Color: u.StatusColor}, true).Render(ctx, templ_7745c5c3_Buffer)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@@ -1525,8 +1525,9 @@ func publicIncidents(incidents []agentapi.PageIncident) templ.Component {
} }
// incidentStatusLabel names an incident's status: what the organization // incidentStatusLabel names an incident's status: what the organization
// said, or ongoing or resolved when it said nothing. // said, in its own color for its own statuses, or ongoing or resolved when
func incidentStatusLabel(status string, open bool) templ.Component { // it said nothing.
func incidentStatusLabel(st IncidentStatusInfo, open bool) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
@@ -1544,30 +1545,61 @@ func incidentStatusLabel(status string, open bool) templ.Component {
ctx = templ.InitializeContext(ctx) ctx = templ.InitializeContext(ctx)
ctx = templ.ClearChildren(ctx) ctx = templ.ClearChildren(ctx)
switch { switch {
case status != "": case st.Key == "custom":
{ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 124, "<span class=\"inline-flex items-center gap-1.5 font-medium\"><span class=\"inline-block size-2 rounded-full\" style=\"")
templ_7745c5c3_ElementWriter := templ_7745c5c3_Buffer
templ_7745c5c3_Buffer := templ.GetBuffer()
var templ_7745c5c3_ElementScripts []templ.ComponentScript
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 124, "<span class=\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var69 = []any{"font-medium", incidentStatusClass(status)} var templ_7745c5c3_Var69 string
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_ElementWriter, templ_7745c5c3_Var69...) templ_7745c5c3_Var69, templ_7745c5c3_Err = templruntime.SanitizeStyleAttributeValues("background-color:" + st.Color)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 342, Col: 89}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var69))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 125, "\"></span> ")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var70 string var templ_7745c5c3_Var70 string
templ_7745c5c3_Var70, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.CSSClasses(templ_7745c5c3_Var69).String()).Resolve(ctx) templ_7745c5c3_Var70, templ_7745c5c3_Err = templ.JoinStringErrs(st.Name)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 1, Col: 0} return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 343, Col: 13}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var70) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var70))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 125, "\"") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 126, "</span>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
case st.Key != "":
{
templ_7745c5c3_ElementWriter := templ_7745c5c3_Buffer
templ_7745c5c3_Buffer := templ.GetBuffer()
var templ_7745c5c3_ElementScripts []templ.ComponentScript
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 127, "<span class=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var71 = []any{"font-medium", incidentStatusClass(st.Key)}
templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_ElementWriter, templ_7745c5c3_Var71...)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var72 string
templ_7745c5c3_Var72, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.CSSClasses(templ_7745c5c3_Var71).String()).Resolve(ctx)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 1, Col: 0}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var72)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 128, "\"")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@@ -1581,56 +1613,56 @@ func incidentStatusLabel(status string, open bool) templ.Component {
} }
templ.ReleaseBuffer(templ_7745c5c3_Buffer) templ.ReleaseBuffer(templ_7745c5c3_Buffer)
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 126, ">") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 129, ">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var71 string
templ_7745c5c3_Var71, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incident.status."+status))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 340, Col: 102}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var71))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 127, "</span>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
case open:
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 128, "<span class=\"font-medium text-down\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var72 string
templ_7745c5c3_Var72, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incidents.ongoing"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 342, Col: 73}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var72))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 129, "</span>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
default:
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 130, "<span class=\"text-up\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var73 string var templ_7745c5c3_Var73 string
templ_7745c5c3_Var73, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incidents.resolved")) templ_7745c5c3_Var73, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incident.status."+st.Key))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 344, Col: 60} return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 346, Col: 102}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var73)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var73))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 131, "</span>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 130, "</span>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
case open:
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 131, "<span class=\"font-medium text-down\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var74 string
templ_7745c5c3_Var74, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incidents.ongoing"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 348, Col: 73}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var74))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 132, "</span>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
default:
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 133, "<span class=\"text-up\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var75 string
templ_7745c5c3_Var75, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incidents.resolved"))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 350, Col: 60}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var75))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 134, "</span>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@@ -1657,25 +1689,25 @@ func pageMaintenance(heading string, items []agentapi.PageMaintenance) templ.Com
ctx = templ.InitializeContext(ctx) ctx = templ.InitializeContext(ctx)
ctx = templ.ClearChildren(ctx) ctx = templ.ClearChildren(ctx)
if len(items) > 0 { if len(items) > 0 {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 132, "<section class=\"mb-12\"><h2 class=\"mb-3 text-xs font-medium uppercase tracking-wider text-muted\">") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 135, "<section class=\"mb-12\"><h2 class=\"mb-3 text-xs font-medium uppercase tracking-wider text-muted\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var75 string var templ_7745c5c3_Var77 string
templ_7745c5c3_Var75, templ_7745c5c3_Err = templ.JoinStringErrs(heading) templ_7745c5c3_Var77, templ_7745c5c3_Err = templ.JoinStringErrs(heading)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 351, Col: 85} return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 357, Col: 85}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var75)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var77))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 133, "</h2><ul class=\"divide-y divide-rule border-y border-rule text-sm\">") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 136, "</h2><ul class=\"divide-y divide-rule border-y border-rule text-sm\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
for _, m := range items { for _, m := range items {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 134, "<li class=\"py-3\"><div class=\"flex flex-wrap items-baseline gap-x-4 gap-y-1\"><span class=\"flex items-center gap-2 font-medium\">") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 137, "<li class=\"py-3\"><div class=\"flex flex-wrap items-baseline gap-x-4 gap-y-1\"><span class=\"flex items-center gap-2 font-medium\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@@ -1683,51 +1715,51 @@ func pageMaintenance(heading string, items []agentapi.PageMaintenance) templ.Com
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 135, " ") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 138, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var76 string
templ_7745c5c3_Var76, templ_7745c5c3_Err = templ.JoinStringErrs(m.Title)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 358, Col: 17}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var76))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 136, "</span> <span class=\"ml-auto font-mono text-xs text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var77 string
templ_7745c5c3_Var77, templ_7745c5c3_Err = templ.JoinStringErrs(m.Start.UTC().Format("2006-01-02 15:04") + " – " + m.End.UTC().Format("15:04") + " UTC")
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 361, Col: 99}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var77))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 137, "</span></div><p class=\"ml-4 mt-1 text-xs text-muted\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var78 string var templ_7745c5c3_Var78 string
templ_7745c5c3_Var78, templ_7745c5c3_Err = templ.JoinStringErrs(strings.Join(m.Components, ", ")) templ_7745c5c3_Var78, templ_7745c5c3_Err = templ.JoinStringErrs(m.Title)
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 364, Col: 80} return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 364, Col: 17}
} }
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var78)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var78))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 138, "</p>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 139, "</span> <span class=\"ml-auto font-mono text-xs text-muted\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var79 string
templ_7745c5c3_Var79, templ_7745c5c3_Err = templ.JoinStringErrs(m.Start.UTC().Format("2006-01-02 15:04") + " – " + m.End.UTC().Format("15:04") + " UTC")
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/public.templ`, Line: 367, Col: 99}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var79))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 140, "</span></div><p class=\"ml-4 mt-1 text-xs text-muted\">")
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}
}
_, 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, "</p>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
if m.Description != "" { if m.Description != "" {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 139, "<div class=\"legal-text ml-4 mt-2 text-muted\">") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 142, "<div class=\"legal-text ml-4 mt-2 text-muted\">")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
@@ -1735,17 +1767,17 @@ func pageMaintenance(heading string, items []agentapi.PageMaintenance) templ.Com
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 140, "</div>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 143, "</div>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 141, "</li>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 144, "</li>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
} }
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 142, "</ul></section>") templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 145, "</ul></section>")
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }