feat(limits): limit the monitors shown on one status page
Platform admins set a default for how many monitors a status page may show, and an override per organization, like the other limits. Saving a page with more gives 422 page_monitor_limit; a page beyond a lowered limit keeps its monitors but cannot grow. The page editor names the limit and the organization's usage lists it. 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
4cde0f7e56
commit
ca852c8299
17 files changed
+611
-416
No files matched your search
@@ -698,6 +698,16 @@ func (s *Server) setPageMonitors(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// A page beyond a lowered limit may keep its monitors but not add any.
|
||||
if max := s.orgLimits(ctx, p.Org).MonitorsPerPage; max > 0 && len(req.Monitors) > max {
|
||||
had, err := q.CountStatusPageMonitors(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if int64(len(req.Monitors)) > had {
|
||||
return limitError{"page_monitor_limit", max}
|
||||
}
|
||||
}
|
||||
if err := q.ClearStatusPageMonitors(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -725,6 +735,7 @@ func (s *Server) setPageMonitors(c *gin.Context) {
|
||||
case isForeignKeyViolation(err), isUniqueViolation(err, "status_page_monitors_pkey"):
|
||||
// Unknown monitors, monitors of other orgs and duplicates.
|
||||
fail(c, http.StatusUnprocessableEntity, "invalid_monitor")
|
||||
case failLimit(c, err):
|
||||
case err != nil:
|
||||
internalError(c, err)
|
||||
default:
|
||||
|
||||
Reference in new issue
Block a user