feat(console): set an incident's status right in the incident list
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 12m19s
ci / test (pull_request) Successful in 12m58s
ci / build (pull_request) Successful in 15m32s
ci / image (pull_request) Successful in 4m29s
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 12m19s
ci / test (pull_request) Successful in 12m58s
ci / build (pull_request) Successful in 15m32s
ci / image (pull_request) Successful in 4m29s
Each row of the incident list offers "Set status" to those who may write the monitor's incidents: a status (built-in or own, the next one preselected), an optional message and whether it shows on status pages. An update may now just change the status, without a message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
2409a919c3
commit
437b6e934f
9 files changed
+1966
-1693
No files matched your search
@@ -47,6 +47,16 @@ func (cs customStatuses) info(key *string, id *uuid.UUID) web.IncidentStatusInfo
|
||||
return web.IncidentStatusInfo{Key: *key}
|
||||
}
|
||||
|
||||
// list returns the statuses for a form, by name.
|
||||
func (cs customStatuses) list() []web.CustomIncidentStatus {
|
||||
out := make([]web.CustomIncidentStatus, 0, len(cs))
|
||||
for _, st := range cs {
|
||||
out = append(out, web.CustomIncidentStatus{ID: st.ID.String(), Name: st.Name, Color: st.Color})
|
||||
}
|
||||
slices.SortFunc(out, func(a, b web.CustomIncidentStatus) int { return strings.Compare(a.Name, b.Name) })
|
||||
return out
|
||||
}
|
||||
|
||||
// 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 {
|
||||
@@ -207,14 +217,16 @@ func (s *Server) setIncidentTitle(c *gin.Context) {
|
||||
|
||||
type incidentUpdateRequest struct {
|
||||
// Status is a built-in status or the ID of a custom one.
|
||||
Status string `json:"status" binding:"required"`
|
||||
Message string `json:"message" binding:"required,max=5000"`
|
||||
Status string `json:"status" binding:"required"`
|
||||
// Message is Markdown; empty just changes the status.
|
||||
Message string `json:"message" binding:"max=5000"`
|
||||
// Public shows the update on status pages; otherwise it is an internal
|
||||
// note. Defaults to public.
|
||||
Public *bool `json:"public"`
|
||||
}
|
||||
|
||||
// addIncidentUpdate tells what is going on: a status and a message.
|
||||
// addIncidentUpdate tells what is going on: a status and, usually, a
|
||||
// message.
|
||||
func (s *Server) addIncidentUpdate(c *gin.Context) {
|
||||
var req incidentUpdateRequest
|
||||
if !bind(c, &req) {
|
||||
@@ -233,7 +245,7 @@ func (s *Server) addIncidentUpdate(c *gin.Context) {
|
||||
}
|
||||
key, statusID = "custom", &id
|
||||
}
|
||||
if (statusID == nil && !slices.Contains(web.IncidentStatuses, key)) || req.Message == "" {
|
||||
if statusID == nil && !slices.Contains(web.IncidentStatuses, key) {
|
||||
fail(c, http.StatusUnprocessableEntity, "invalid_input")
|
||||
return
|
||||
}
|
||||
@@ -345,10 +357,7 @@ func (s *Server) incidentDetailView(c *gin.Context, p *principal, page web.Page,
|
||||
v.Timeline = append(v.Timeline, x.e)
|
||||
}
|
||||
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) })
|
||||
v.Custom = d.statuses.list()
|
||||
return web.IncidentDetailPage(page, me, v), nil
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user