diff --git a/internal/api/access.go b/internal/api/access.go index 076c4e7..435e6dc 100644 --- a/internal/api/access.go +++ b/internal/api/access.go @@ -123,6 +123,9 @@ func (s *Server) resolvePrincipal(c *gin.Context) (*principal, int, string, erro if err != nil { return nil, 0, "", err } + if p.Org.SuspendedAt != nil { + return nil, http.StatusForbidden, "org_suspended", nil + } if code := policyViolation(p.Org, p.Grants.Owner, sess); code != "" { return nil, http.StatusForbidden, code, nil } diff --git a/internal/api/apidocs.go b/internal/api/apidocs.go index 4a1aaed..d215ebb 100644 --- a/internal/api/apidocs.go +++ b/internal/api/apidocs.go @@ -241,6 +241,23 @@ var endpoints = []endpoint{ {method: "PUT", path: "/api/v1/admin/checker-network", tag: "Platform", summary: "Let platform checkers check private addresses or not", description: "Unset, they may on self-hosted installations and may not in the cloud edition. Applies from each checker's next poll.", perm: "platform admin", req: checkerNetwork{}, status: http.StatusNoContent}, + {method: "GET", path: "/api/v1/admin/status-pages", tag: "Platform", summary: "Public and suspended status pages with organization and owner", + description: "Newest first, at most 500. `q` searches title, slug, domain, organization and owner email.", + perm: "platform admin", resp: obj{"status_pages": []moderatedPage{}}}, + {method: "PUT", path: "/api/v1/admin/status-pages/:id/suspension", tag: "Platform", summary: "Suspend or reinstate a status page", + description: "A suspended page is not served; status page servers drop it when they next ask for it.", + perm: "platform admin", req: suspensionRequest{}, status: http.StatusNoContent}, + {method: "DELETE", path: "/api/v1/admin/status-pages/:id", tag: "Platform", summary: "Delete a status page", perm: "platform admin", status: http.StatusNoContent}, + {method: "PUT", path: "/api/v1/admin/orgs/:id/suspension", tag: "Platform", summary: "Suspend or reinstate an organization", + description: "A suspended organization's monitors are not checked, its status pages are not served, heartbeats and Alertmanager webhooks are refused, and its members and API tokens get 403 org_suspended.", + perm: "platform admin", req: suspensionRequest{}, status: http.StatusNoContent}, + {method: "DELETE", path: "/api/v1/admin/orgs/:id", tag: "Platform", summary: "Delete an organization with all its data", perm: "platform admin", status: http.StatusNoContent}, + {method: "PUT", path: "/api/v1/admin/users/:id/suspension", tag: "Platform", summary: "Suspend or reinstate an account", + description: "A suspended account is signed out everywhere and can neither sign in nor use its API tokens. Platform admins cannot be suspended.", + perm: "platform admin", req: suspensionRequest{}, status: http.StatusNoContent}, + {method: "DELETE", path: "/api/v1/admin/users/:id", tag: "Platform", summary: "Delete an account", + description: "Organizations only the account belongs to are deleted with it; owning one shared with others gives 409 owns_shared_orgs. Platform admins cannot be deleted.", + perm: "platform admin", status: http.StatusNoContent}, {method: "GET", path: "/api/v1/admin/regions", tag: "Platform", summary: "List platform regions", perm: "platform admin", resp: obj{"regions": []regionView{}}}, {method: "POST", path: "/api/v1/admin/regions", tag: "Platform", summary: "Create a platform region", perm: "platform admin", diff --git a/internal/api/audit.go b/internal/api/audit.go index 774123a..0aaf800 100644 --- a/internal/api/audit.go +++ b/internal/api/audit.go @@ -89,16 +89,22 @@ var auditActions = map[string]string{ "POST /api/v1/org/tokens": "token.create", "DELETE /api/v1/org/tokens/:id": "token.delete", - "PUT /api/v1/admin/legal/:kind": "platform.legal_update", - "PUT /api/v1/org/legal/:kind": "org.legal_update", - "PUT /api/v1/admin/check-types": "platform.check_types_update", - "PUT /api/v1/admin/checker-network": "platform.checker_network_update", - "PUT /api/v1/org/check-types": "org.check_types_update", - "PATCH /api/v1/org/agents/:id": "agent.update", - "POST /api/v1/admin/regions": "platform.region_create", - "DELETE /api/v1/admin/regions/:id": "platform.region_delete", - "POST /api/v1/admin/agents": "platform.agent_create", - "DELETE /api/v1/admin/agents/:id": "platform.agent_delete", + "PUT /api/v1/admin/legal/:kind": "platform.legal_update", + "PUT /api/v1/org/legal/:kind": "org.legal_update", + "PUT /api/v1/admin/check-types": "platform.check_types_update", + "PUT /api/v1/admin/checker-network": "platform.checker_network_update", + "PUT /api/v1/admin/status-pages/:id/suspension": "platform.status_page_suspension", + "DELETE /api/v1/admin/status-pages/:id": "platform.status_page_delete", + "PUT /api/v1/admin/orgs/:id/suspension": "platform.org_suspension", + "DELETE /api/v1/admin/orgs/:id": "platform.org_delete", + "PUT /api/v1/admin/users/:id/suspension": "platform.user_suspension", + "DELETE /api/v1/admin/users/:id": "platform.user_delete", + "PUT /api/v1/org/check-types": "org.check_types_update", + "PATCH /api/v1/org/agents/:id": "agent.update", + "POST /api/v1/admin/regions": "platform.region_create", + "DELETE /api/v1/admin/regions/:id": "platform.region_delete", + "POST /api/v1/admin/agents": "platform.agent_create", + "DELETE /api/v1/admin/agents/:id": "platform.agent_delete", } // Failed attempts of these actions are recorded too. diff --git a/internal/api/auth.go b/internal/api/auth.go index ac4a354..0af810f 100644 --- a/internal/api/auth.go +++ b/internal/api/auth.go @@ -155,10 +155,15 @@ func (s *Server) login(c *gin.Context) { internalError(c, err) return } - if !ok || user.DisabledAt != nil { + if !ok { invalidCredentials(c) return } + // Only someone who knows the password learns of the suspension. + if user.DisabledAt != nil { + fail(c, http.StatusForbidden, "account_suspended") + return + } if rehash { s.rehashPassword(ctx, user.ID, req.Password) } @@ -243,6 +248,10 @@ func (s *Server) finishLogin(c *gin.Context, userID uuid.UUID, method auth.Metho internalError(c, err) return } + if user.DisabledAt != nil { + fail(c, http.StatusForbidden, "account_suspended") + return + } var org uuid.UUID if len(orgs) > 0 { org = orgs[0].ID diff --git a/internal/api/console.go b/internal/api/console.go index 00d4a89..24f948b 100644 --- a/internal/api/console.go +++ b/internal/api/console.go @@ -819,7 +819,7 @@ func (s *Server) statusPagesView(c *gin.Context, p *principal, page web.Page, me } v.Pages = append(v.Pages, web.PageRow{ ID: r.ID.String(), Title: r.Title, Slug: r.Slug, Published: r.Published, - URL: s.pageURL(r), Domain: deref(r.CustomDomain), + URL: s.pageURL(r), Domain: deref(r.CustomDomain), Suspended: r.SuspendedAt != nil, }) } return web.StatusPagesPage(page, me, v), nil @@ -865,6 +865,7 @@ func (s *Server) statusPageEditor(c *gin.Context, p *principal, page web.Page, m e := web.PageEditor{ ID: row.ID.String(), Title: row.Title, Slug: row.Slug, Description: row.Description, Published: row.Published, ShowDetails: row.ShowComponentDetails, + Suspended: row.SuspendedAt != nil, SuspendedReason: row.SuspendedReason, Accent: v.Theme.Accent, LogoURL: v.Theme.LogoURL, CSS: v.Theme.CSS, URL: s.pageURL(row), Domain: deref(row.CustomDomain), DomainVerified: v.DomainVerified, HasOrgGroups: len(orgGroups) > 0, diff --git a/internal/api/gdpr.go b/internal/api/gdpr.go index eb1aca4..eec6d2f 100644 --- a/internal/api/gdpr.go +++ b/internal/api/gdpr.go @@ -609,8 +609,28 @@ func (s *Server) deleteAccount(c *gin.Context) { fail(c, http.StatusForbidden, "confirmation_failed") return } - var shared []string - var orgsDeleted int + shared, orgsDeleted, err := s.eraseAccount(ctx, u) + if err != nil { + internalError(c, err) + return + } + if len(shared) > 0 { + c.JSON(http.StatusConflict, gin.H{ + "error": "owns_shared_orgs", "message": i18n.T(ctx, "error.owns_shared_orgs"), "organizations": shared, + }) + return + } + auth.ClearCookie(c) + // Kept as proof of erasure, without saying whose. + s.writeAudit(c, store.InsertAuditEventParams{Kind: "platform", Action: "account.delete", Status: http.StatusOK}, + map[string]any{"organizations_deleted": orgsDeleted}) + c.JSON(http.StatusOK, gin.H{"status": "deleted"}) +} + +// eraseAccount deletes u with the organizations only u belongs to and +// ends u's sessions. If u owns organizations shared with others, nothing +// is deleted and their slugs are returned. +func (s *Server) eraseAccount(ctx context.Context, u store.User) (shared []string, orgsDeleted int, err error) { err = s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error { owned, err := q.OwnedOrgs(ctx, u.ID) if err != nil { @@ -643,24 +663,13 @@ func (s *Server) deleteAccount(c *gin.Context) { } return nil }) - if err != nil { - internalError(c, err) - return - } - if len(shared) > 0 { - c.JSON(http.StatusConflict, gin.H{ - "error": "owns_shared_orgs", "message": i18n.T(ctx, "error.owns_shared_orgs"), "organizations": shared, - }) - return + if err != nil || len(shared) > 0 { + return shared, 0, err } if err := s.sessions.DeleteAllForUser(ctx, u.ID); err != nil { s.log.ErrorContext(ctx, "ending sessions of deleted account failed", "error", err) } - auth.ClearCookie(c) - // Kept as proof of erasure, without saying whose. - s.writeAudit(c, store.InsertAuditEventParams{Kind: "platform", Action: "account.delete", Status: http.StatusOK}, - map[string]any{"organizations_deleted": orgsDeleted}) - c.JSON(http.StatusOK, gin.H{"status": "deleted"}) + return nil, orgsDeleted, nil } type orgDeletionRequest struct { diff --git a/internal/api/moderation.go b/internal/api/moderation.go new file mode 100644 index 0000000..a452ab1 --- /dev/null +++ b/internal/api/moderation.go @@ -0,0 +1,307 @@ +package api + +import ( + "errors" + "net/http" + "strings" + "time" + + "github.com/gin-gonic/gin" + "github.com/google/uuid" + "github.com/jackc/pgx/v5" + + "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" + "git.zb-server.de/ZB-Server/uptimesebi/internal/store" + "git.zb-server.de/ZB-Server/uptimesebi/internal/tenant" + "git.zb-server.de/ZB-Server/uptimesebi/internal/web" +) + +// Platform admins moderate public status pages and the organizations and +// accounts behind them: suspending hides or stops them and can be undone, +// deleting cannot. Suspended pages leave status page servers when these +// next ask for them, within half a minute. + +type moderatedPage struct { + ID uuid.UUID `json:"id"` + Slug string `json:"slug"` + Title string `json:"title"` + Published bool `json:"published"` + Domain string `json:"custom_domain,omitempty"` + SuspendedAt *time.Time `json:"suspended_at"` + Reason string `json:"suspended_reason,omitempty"` + CreatedAt time.Time `json:"created_at"` + Org moderatedOrg `json:"org"` + Owner *moderatedUser `json:"owner"` +} + +type moderatedOrg struct { + ID uuid.UUID `json:"id"` + Slug string `json:"slug"` + Name string `json:"name"` + SuspendedAt *time.Time `json:"suspended_at"` + Reason string `json:"suspended_reason,omitempty"` +} + +type moderatedUser struct { + ID uuid.UUID `json:"id"` + Email string `json:"email"` + SuspendedAt *time.Time `json:"suspended_at"` + Reason string `json:"suspended_reason,omitempty"` + // Admin marks platform admins, who cannot be suspended or deleted. + Admin bool `json:"admin,omitempty"` +} + +const moderationRows = 500 + +func (s *Server) moderatedPages(c *gin.Context) ([]moderatedPage, error) { + ctx := c.Request.Context() + var rows []store.AdminListStatusPagesRow + err := s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error { + var err error + rows, err = q.AdminListStatusPages(ctx, store.AdminListStatusPagesParams{ + Search: truncate(strings.TrimSpace(c.Query("q")), 200), MaxRows: moderationRows, + }) + return err + }) + out := make([]moderatedPage, len(rows)) + for i, r := range rows { + p := &out[i] + p.ID, p.Slug, p.Title, p.Published, p.SuspendedAt, p.Reason, p.CreatedAt = r.ID, r.Slug, r.Title, r.Published, r.SuspendedAt, r.SuspendedReason, r.CreatedAt + if r.CustomDomain != nil && r.DomainVerifiedAt != nil { + p.Domain = *r.CustomDomain + } + p.Org = moderatedOrg{r.OrgID, r.OrgSlug, r.OrgName, r.OrgSuspendedAt, r.OrgSuspendedReason} + if r.OwnerID != uuid.Nil { + p.Owner = &moderatedUser{r.OwnerID, r.OwnerEmail, r.OwnerDisabledAt, r.OwnerDisabledReason, r.OwnerIsAdmin} + } + } + return out, err +} + +func (s *Server) adminListStatusPages(c *gin.Context) { + pages, err := s.moderatedPages(c) + if err != nil { + internalError(c, err) + return + } + c.JSON(http.StatusOK, gin.H{"status_pages": pages}) +} + +type suspensionRequest struct { + Suspended bool `json:"suspended"` + Reason string `json:"reason" binding:"max=500"` +} + +// suspension binds a suspension request and the target ID. +func suspension(c *gin.Context) (uuid.UUID, suspensionRequest, bool) { + id, err := uuid.Parse(c.Param("id")) + if err != nil { + fail(c, http.StatusNotFound, "not_found") + return uuid.Nil, suspensionRequest{}, false + } + var req suspensionRequest + if !bind(c, &req) { + return uuid.Nil, req, false + } + req.Reason = strings.TrimSpace(req.Reason) + auditDetail(c, "suspended", req.Suspended) + if req.Reason != "" { + auditDetail(c, "reason", req.Reason) + } + return id, req, true +} + +// moderated finishes a moderation request: 404 for unknown targets. +func moderated(c *gin.Context, err error) bool { + if errors.Is(err, pgx.ErrNoRows) { + fail(c, http.StatusNotFound, "not_found") + return false + } + if err != nil { + internalError(c, err) + return false + } + return true +} + +func (s *Server) adminSuspendStatusPage(c *gin.Context) { + id, req, ok := suspension(c) + if !ok { + return + } + ctx := c.Request.Context() + err := s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error { + row, err := q.SuspendStatusPage(ctx, store.SuspendStatusPageParams{ID: id, Suspend: req.Suspended, Reason: req.Reason}) + auditDetail(c, "slug", row.Slug) + return err + }) + if moderated(c, err) { + c.Status(http.StatusNoContent) + } +} + +func (s *Server) adminDeleteStatusPage(c *gin.Context) { + id, err := uuid.Parse(c.Param("id")) + if err != nil { + fail(c, http.StatusNotFound, "not_found") + return + } + ctx := c.Request.Context() + err = s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error { + page, err := q.GetStatusPage(ctx, id) + if err != nil { + return err + } + auditDetail(c, "slug", page.Slug) + _, err = q.DeleteStatusPage(ctx, id) + return err + }) + if moderated(c, err) { + c.Status(http.StatusNoContent) + } +} + +func (s *Server) adminSuspendOrg(c *gin.Context) { + id, req, ok := suspension(c) + if !ok { + return + } + ctx := c.Request.Context() + err := s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error { + row, err := q.SuspendOrg(ctx, store.SuspendOrgParams{ID: id, Suspend: req.Suspended, Reason: req.Reason}) + if err != nil { + return err + } + auditDetail(c, "slug", row.Slug) + if !req.Suspended { + return q.RestartHeartbeatWait(ctx, id) + } + return nil + }) + if !moderated(c, err) { + return + } + // Monitors leave or rejoin the schedule with its next reconciliation. + c.Status(http.StatusNoContent) +} + +func (s *Server) adminDeleteOrg(c *gin.Context) { + id, err := uuid.Parse(c.Param("id")) + if err != nil { + fail(c, http.StatusNotFound, "not_found") + return + } + ctx := c.Request.Context() + err = s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error { + org, err := q.GetOrg(ctx, id) + if err != nil { + return err + } + auditDetail(c, "slug", org.Slug) + auditDetail(c, "name", org.Name) + return purgeOrg(ctx, q, id) + }) + if moderated(c, err) { + c.Status(http.StatusNoContent) + } +} + +// moderatedUser loads the target account, refusing platform admins: they +// would otherwise lock each other, or themselves, out. +func (s *Server) moderatedUser(c *gin.Context) (store.User, bool) { + id, err := uuid.Parse(c.Param("id")) + if err != nil { + fail(c, http.StatusNotFound, "not_found") + return store.User{}, false + } + u, err := s.loadUser(c.Request.Context(), id) + if !moderated(c, err) { + return u, false + } + auditDetail(c, "email", u.Email) + if u.IsAdmin { + fail(c, http.StatusConflict, "target_is_admin") + return u, false + } + return u, true +} + +func (s *Server) adminSuspendUser(c *gin.Context) { + id, req, ok := suspension(c) + if !ok { + return + } + u, ok := s.moderatedUser(c) + if !ok { + return + } + ctx := c.Request.Context() + err := s.db.Tx(ctx, tenant.System(), func(q *store.Queries) error { + _, err := q.SuspendUser(ctx, store.SuspendUserParams{ID: id, Suspend: req.Suspended, Reason: req.Reason}) + return err + }) + if !moderated(c, err) { + return + } + if req.Suspended { + if err := s.sessions.DeleteAllForUser(ctx, u.ID); err != nil { + internalError(c, err) + return + } + } + c.Status(http.StatusNoContent) +} + +func (s *Server) adminDeleteUser(c *gin.Context) { + u, ok := s.moderatedUser(c) + if !ok { + return + } + ctx := c.Request.Context() + shared, orgsDeleted, err := s.eraseAccount(ctx, u) + if err != nil { + internalError(c, err) + return + } + if len(shared) > 0 { + c.JSON(http.StatusConflict, gin.H{ + "error": "owns_shared_orgs", "message": i18n.T(ctx, "error.user_owns_shared_orgs"), "organizations": shared, + }) + return + } + auditDetail(c, "organizations_deleted", orgsDeleted) + c.Status(http.StatusNoContent) +} + +func (s *Server) moderationView(c *gin.Context) (web.ModerationView, error) { + pages, err := s.moderatedPages(c) + v := web.ModerationView{Search: strings.TrimSpace(c.Query("q")), Limited: len(pages) == moderationRows} + state := func(at *time.Time, reason string) string { + switch { + case at == nil: + return "" + case reason == "": + return "-" + } + return reason + } + for _, p := range pages { + u := strings.TrimSuffix(s.cfg.StatusPageURL, "/") + "/" + p.Slug + if p.Domain != "" { + u = "https://" + p.Domain + "/" + } + mp := web.ModeratedPage{ + ID: p.ID.String(), Title: p.Title, Slug: p.Slug, URL: u, Created: p.CreatedAt.Format(time.DateOnly), + Published: p.Published, Suspended: state(p.SuspendedAt, p.Reason), + Org: web.ModeratedTarget{ID: p.Org.ID.String(), Name: p.Org.Name, Detail: p.Org.Slug, Suspended: state(p.Org.SuspendedAt, p.Org.Reason)}, + } + if p.Domain != "" { + mp.Slug = p.Domain + } + if p.Owner != nil { + mp.Owner = &web.ModeratedTarget{ID: p.Owner.ID.String(), Name: p.Owner.Email, Suspended: state(p.Owner.SuspendedAt, p.Owner.Reason), Admin: p.Owner.Admin} + } + v.Pages = append(v.Pages, mp) + } + return v, err +} diff --git a/internal/api/moderation_test.go b/internal/api/moderation_test.go new file mode 100644 index 0000000..685d915 --- /dev/null +++ b/internal/api/moderation_test.go @@ -0,0 +1,195 @@ +package api_test + +import ( + "context" + "errors" + "io" + "net/http" + "strings" + "testing" + + "git.zb-server.de/ZB-Server/uptimesebi/internal/agentapi" + "git.zb-server.de/ZB-Server/uptimesebi/internal/store" + "git.zb-server.de/ZB-Server/uptimesebi/internal/tenant" +) + +const testPassword = "correct horse battery" + +func TestModeration(t *testing.T) { + e := newEnv(t) + ctx := context.Background() + admin := e.browser(t) + admin.signup("admin@"+uniq("mod")+".test", uniq("mod-admin-")) + if err := tenant.New(e.dbPool).Tx(ctx, tenant.Global(), func(q *store.Queries) error { + return q.MakeAdmin(ctx, admin.userIDSelf()) + }); err != nil { + t.Fatal(err) + } + + ownerEmail := "owner@" + uniq("mod") + ".test" + owner := e.browser(t) + owner.signup(ownerEmail, uniq("mod-org-")) + slug := uniq("acme-") + _, page := owner.do("POST", "/api/v1/org/statuspages", map[string]any{"slug": slug, "title": "Acme Status", "published": true}) + _, draft := owner.do("POST", "/api/v1/org/statuspages", map[string]any{"slug": uniq("draft-"), "title": "Draft", "published": false}) + _, hb := owner.do("POST", "/api/v1/org/monitors", map[string]any{"name": "Backup", "type": "heartbeat", "interval_seconds": 3600}) + _, region := e.platformChecker(t, uniq("eu-")) + _, web := owner.do("POST", "/api/v1/org/monitors", map[string]any{"name": "Web", "type": "tcp", "target": "example.com:443", "interval_seconds": 60, "regions": []string{region}}) + scheduled := func() bool { + var rows []store.ListEnabledMonitorsForScheduleRow + _ = tenant.New(e.dbPool).Tx(ctx, tenant.System(), func(q *store.Queries) error { + var err error + rows, err = q.ListEnabledMonitorsForSchedule(ctx) + return err + }) + for _, r := range rows { + if r.ID.String() == web["id"] { + return true + } + } + return false + } + _, tok := owner.do("POST", "/api/v1/org/tokens", map[string]any{"name": "ci", "permissions": []string{"monitors.read"}}) + api := &browser{t: t, base: owner.base, hc: e.srv.Client(), bearer: tok["token"].(string)} + sp := e.statuspageClient(t, nil) + served := func() bool { + _, err := sp.Page(ctx, "", slug) + if err != nil && !errors.Is(err, agentapi.ErrNotFound) { + t.Fatal(err) + } + return err == nil + } + // Pings of paused monitors are answered, so cron jobs do not fail, but + // not recorded. + recorded := func() bool { + resp, err := e.srv.Client().Post(e.srv.URL+"/hb/"+hb["target"].(string), "text/plain", nil) + if err != nil { + t.Fatal(err) + } + b, _ := io.ReadAll(resp.Body) + _ = resp.Body.Close() + return resp.StatusCode == http.StatusOK && !strings.Contains(string(b), "paused") + } + + // Only admins see the list; it holds published pages with their + // organization and owner, and search narrows it. + if st, _ := owner.do("GET", "/api/v1/admin/status-pages", nil); st != http.StatusForbidden { + t.Errorf("non-admin listing = %d", st) + } + _, list := admin.do("GET", "/api/v1/admin/status-pages?q="+slug, nil) + raw := mustJSON(list) + if !strings.Contains(raw, slug) || !strings.Contains(raw, ownerEmail) || strings.Contains(raw, draft["slug"].(string)) { + t.Fatalf("list = %s", raw) + } + pg := list["status_pages"].([]any)[0].(map[string]any) + orgID := pg["org"].(map[string]any)["id"].(string) + userID := pg["owner"].(map[string]any)["id"].(string) + if _, other := admin.do("GET", "/api/v1/admin/status-pages?q=no-such-page-"+slug, nil); len(other["status_pages"].([]any)) != 0 { + t.Error("search does not narrow the list") + } + if !served() { + t.Fatal("the page is not served before suspension") + } + + // A suspended page goes offline and its organization learns why. + suspend := func(path string, on bool, reason string) { + t.Helper() + if st, body := admin.do("PUT", "/api/v1/admin/"+path+"/suspension", map[string]any{"suspended": on, "reason": reason}); st != http.StatusNoContent { + t.Fatalf("suspend %s = %d %v", path, st, body) + } + } + suspend("status-pages/"+page["id"].(string), true, "phishing") + if served() { + t.Error("a suspended page is served") + } + _, pages := owner.do("GET", "/api/v1/org/statuspages", nil) + if raw := mustJSON(pages); !strings.Contains(raw, `"suspended":true`) || !strings.Contains(raw, `"suspended_reason":"phishing"`) { + t.Errorf("the organization does not see the suspension: %s", raw) + } + if _, _, html := owner.page("/statuspages"); !strings.Contains(html, "suspended by the operator") { + t.Error("the page list does not mark the suspension") + } + suspend("status-pages/"+page["id"].(string), false, "") + if !served() { + t.Error("a reinstated page is not served") + } + + // A suspended organization is locked out, checks and pages stop. + suspend("orgs/"+orgID, true, "unpaid") + st, body := owner.do("GET", "/api/v1/org/monitors", nil) + expect(t, "member of a suspended org", st, body, http.StatusForbidden, "org_suspended") + st, body = api.do("GET", "/api/v1/org/monitors", nil) + expect(t, "token of a suspended org", st, body, http.StatusForbidden, "org_suspended") + if served() { + t.Error("a suspended organization's page is served") + } + if recorded() { + t.Error("a heartbeat of a suspended org is recorded") + } + if scheduled() { + t.Error("monitors of a suspended org are scheduled") + } + if _, _, html := owner.page("/"); !strings.Contains(html, "The operator suspended this organization") || !strings.Contains(html, "unpaid") { + t.Error("the console does not explain the suspension") + } + suspend("orgs/"+orgID, false, "") + if st, _ := owner.do("GET", "/api/v1/org/monitors", nil); st != http.StatusOK || !scheduled() { + t.Errorf("member of a reinstated org = %d, scheduled = %v", st, scheduled()) + } + if !recorded() { + t.Error("a heartbeat after reinstatement is not recorded") + } + + // A suspended account is signed out and kept out, tokens included. + suspend("users/"+userID, true, "") + if st, _ := owner.do("GET", "/api/v1/me", nil); st != http.StatusUnauthorized { + t.Errorf("session of a suspended account = %d", st) + } + if st, _ := api.do("GET", "/api/v1/org/monitors", nil); st != http.StatusUnauthorized { + t.Errorf("token of a suspended account = %d", st) + } + fresh := e.browser(t) + st, body = fresh.do("POST", "/api/v1/auth/login", map[string]any{"email": ownerEmail, "password": testPassword}) + expect(t, "sign-in of a suspended account", st, body, http.StatusForbidden, "account_suspended") + if st, _ := e.browser(t).do("POST", "/api/v1/auth/login", map[string]any{"email": ownerEmail, "password": "wrong password"}); st != http.StatusUnauthorized { + t.Error("a wrong password reveals the suspension") + } + suspend("users/"+userID, false, "") + if st, _ := fresh.do("POST", "/api/v1/auth/login", map[string]any{"email": ownerEmail, "password": testPassword}); st != http.StatusOK { + t.Errorf("sign-in after reinstatement = %d", st) + } + + // Admins are out of reach, also for themselves. + st, body = admin.do("PUT", "/api/v1/admin/users/"+admin.userIDSelf().String()+"/suspension", map[string]any{"suspended": true}) + expect(t, "suspend an admin", st, body, http.StatusConflict, "target_is_admin") + st, body = admin.do("DELETE", "/api/v1/admin/users/"+admin.userIDSelf().String(), nil) + expect(t, "delete an admin", st, body, http.StatusConflict, "target_is_admin") + + // An owner of a shared organization cannot be deleted before it. + fresh.do("POST", "/api/v1/me/org", map[string]any{"org_id": orgID}) + e.joinVia(t, fresh.invite("m@"+uniq("mod")+".test", fresh.roleID("viewer"))) + st, body = admin.do("DELETE", "/api/v1/admin/users/"+userID, nil) + expect(t, "delete the owner of a shared org", st, body, http.StatusConflict, "owns_shared_orgs") + + // Deleting: page, organization, account. + if st, _ := admin.do("DELETE", "/api/v1/admin/status-pages/"+page["id"].(string), nil); st != http.StatusNoContent || served() { + t.Errorf("delete page = %d", st) + } + if st, _ := admin.do("DELETE", "/api/v1/admin/orgs/"+orgID, nil); st != http.StatusNoContent { + t.Errorf("delete org = %d", st) + } + if st, body := admin.do("DELETE", "/api/v1/admin/users/"+userID, nil); st != http.StatusNoContent { + t.Errorf("delete account = %d %v", st, body) + } + if st, _ := e.browser(t).do("POST", "/api/v1/auth/login", map[string]any{"email": ownerEmail, "password": testPassword}); st != http.StatusUnauthorized { + t.Error("the deleted account can still sign in") + } + if st, _ := admin.do("DELETE", "/api/v1/admin/orgs/"+orgID, nil); st != http.StatusNotFound { + t.Error("deleting a deleted org is not 404") + } + + // The admin page shows the list. + if _, _, html := admin.page("/admin"); !strings.Contains(html, `id="moderation"`) { + t.Error("the admin page lacks the status page list") + } +} diff --git a/internal/api/pages.go b/internal/api/pages.go index c3ea6af..98f3390 100644 --- a/internal/api/pages.go +++ b/internal/api/pages.go @@ -50,7 +50,7 @@ var flashErrors = map[ssoError]bool{ "sso_unavailable": true, "sso_provider_error": true, "sso_expired": true, "sso_denied": true, "sso_not_member": true, "sso_not_provisioned": true, "sso_link_required": true, "sso_identity_taken": true, "invalid_credentials": true, - "totp_required_by_org": true, "sso_required_by_org": true, + "totp_required_by_org": true, "sso_required_by_org": true, "account_suspended": true, } func (s *Server) pageFor(c *gin.Context, titleID string) web.Page { @@ -134,6 +134,10 @@ func (s *Server) consoleMe(c *gin.Context, sess *auth.Session) (web.Me, *princip if err != nil || !member { return me, nil, err } + if p.Org.SuspendedAt != nil { + me.OrgSuspended, me.SuspendedReason = true, p.Org.SuspendedReason + return me, nil, nil + } for _, perm := range authz.All { me.Can[string(perm)] = p.Grants.Can(perm) } @@ -502,7 +506,12 @@ func (s *Server) adminPage(c *gin.Context) { for _, t := range check.Types { types = append(types, web.CheckTypeOption{Type: string(t), Enabled: !off[string(t)]}) } - web.Render(c, http.StatusOK, web.AdminPage(s.pageFor(c, "admin.title"), me, v, storageView(c, stats), types, s.platformPrivate(ctx))) + mod, err := s.moderationView(c) + if err != nil { + internalError(c, err) + return + } + web.Render(c, http.StatusOK, web.AdminPage(s.pageFor(c, "admin.title"), me, v, storageView(c, stats), types, s.platformPrivate(ctx), mod)) } func (s *Server) buildRegionsView(ctx context.Context, regions []store.Region, agents []store.ListAgentsRow, apiBase, next string, manageable func(store.Region) bool) (web.RegionsView, error) { diff --git a/internal/api/server.go b/internal/api/server.go index 421a9ce..07a4892 100644 --- a/internal/api/server.go +++ b/internal/api/server.go @@ -167,6 +167,13 @@ func (s *Server) Mount(r gin.IRouter) { admin.GET("/check-types", s.adminListCheckTypes) admin.PUT("/check-types", s.adminSetCheckTypes) admin.GET("/checker-network", s.adminGetCheckerNetwork) + admin.GET("/status-pages", s.adminListStatusPages) + admin.PUT("/status-pages/:id/suspension", s.adminSuspendStatusPage) + admin.DELETE("/status-pages/:id", s.adminDeleteStatusPage) + admin.PUT("/orgs/:id/suspension", s.adminSuspendOrg) + admin.DELETE("/orgs/:id", s.adminDeleteOrg) + admin.PUT("/users/:id/suspension", s.adminSuspendUser) + admin.DELETE("/users/:id", s.adminDeleteUser) admin.PUT("/checker-network", s.adminSetCheckerNetwork) admin.GET("/legal", s.adminListLegal) admin.PUT("/legal/:kind", s.adminSaveLegal) diff --git a/internal/api/sso.go b/internal/api/sso.go index 5a823f9..115d185 100644 --- a/internal/api/sso.go +++ b/internal/api/sso.go @@ -255,7 +255,7 @@ func (s *Server) ssoCallback(c *gin.Context) { return } if user.DisabledAt != nil { - s.ssoAbort(c, uuid.Nil, "invalid_credentials") + s.ssoAbort(c, uuid.Nil, "account_suspended") return } if old := auth.Current(c); old != nil { diff --git a/internal/api/statuspages.go b/internal/api/statuspages.go index 2a8b14c..102b8d7 100644 --- a/internal/api/statuspages.go +++ b/internal/api/statuspages.go @@ -392,6 +392,10 @@ type statusPageView struct { DomainVerified bool `json:"domain_verified"` // DomainRecord is the TXT record that proves control of CustomDomain. DomainRecord *dnsRecord `json:"domain_record,omitempty"` + // Suspended is set when platform admins took the page offline; it is + // not served whatever Published says. + Suspended bool `json:"suspended,omitempty"` + SuspendedReason string `json:"suspended_reason,omitempty"` } type dnsRecord struct { @@ -405,6 +409,7 @@ func viewStatusPage(p store.StatusPage) statusPageView { ID: p.ID, Slug: p.Slug, Title: p.Title, Description: p.Description, Published: p.Published, ShowComponentDetails: p.ShowComponentDetails, CustomDomain: p.CustomDomain, DomainVerified: p.DomainVerifiedAt != nil, + Suspended: p.SuspendedAt != nil, SuspendedReason: p.SuspendedReason, } _ = json.Unmarshal(p.Theme, &v.Theme) if p.CustomDomain != nil { diff --git a/internal/api/tokens.go b/internal/api/tokens.go index 6539c9e..c1d4b52 100644 --- a/internal/api/tokens.go +++ b/internal/api/tokens.go @@ -79,6 +79,16 @@ func (s *Server) tokenPrincipal(ctx context.Context, tok string) (*principal, in if err != nil { return nil, 0, "", err } + if p.Org.SuspendedAt != nil { + return nil, http.StatusForbidden, "org_suspended", nil + } + // Tokens act for their creator and stop with the creator's account. + if u, err := s.loadUser(ctx, row.UserID); err != nil || u.DisabledAt != nil { + if err != nil && !errors.Is(err, pgx.ErrNoRows) { + return nil, 0, "", err + } + return nil, http.StatusUnauthorized, "unauthenticated", nil + } p.UserID, p.TokenID = row.UserID, row.ID p.Grants = p.Grants.Restrict(authz.NewSet(row.Permissions...)) return p, 0, "", nil diff --git a/internal/i18n/i18n_test.go b/internal/i18n/i18n_test.go index 43addaf..97c64e0 100644 --- a/internal/i18n/i18n_test.go +++ b/internal/i18n/i18n_test.go @@ -152,25 +152,28 @@ func TestEveryMailEventHasTexts(t *testing.T) { func TestDynamicFamilies(t *testing.T) { en := catalogKeys(t)["en"] families := map[string][]string{ - "status.": {"up", "degraded", "down", "unknown", "paused", "maintenance"}, - "monitors.type_": {"http", "tcp", "tls", "dns", "icmp", "json", "prometheus", "postgres", "mysql", "mssql", "mongodb", "redis", "mqtt", "kafka", "rabbitmq", "grpc", "smtp", "radius", "snmp", "steam", "minecraft", "docker", "heartbeat", "alertmanager"}, - "agents.kind_": {"checker", "statuspage"}, - "page.status.": {"operational", "degraded", "outage", "unknown", "maintenance"}, - "page.component.": {"operational", "degraded", "outage", "unknown", "maintenance"}, - "storage.level_": {"raw", "1h", "1d"}, - "legal.": {"imprint", "privacy"}, - "monitors.op_": {"eq", "ne", "gt", "ge", "lt", "le", "contains", "exists", "absent"}, - "evidence.stage_": {"dns", "connect", "tls", "response", "body"}, - "evidence.phase_": {"dns", "connect", "tls", "wait", "download"}, - "monitors.db_database_": {"postgres", "mysql", "mssql", "mongodb", "redis"}, - "monitors.broker_hint_": {"mqtt", "kafka", "rabbitmq"}, - "monitors.snmp_cond_": {"any", "eq", "ne", "contains", "gt", "ge", "lt", "le"}, - "monitors.minecraft_": {"java", "bedrock", "hint", "edition"}, - "monitors.db_tls_": {"require", "verify", "disable"}, - "weekday.": {"0", "1", "2", "3", "4", "5", "6"}, - "md.": {"heading", "bold", "italic", "strike", "link", "ul", "ol", "quote", "code", "codeblock", "table", "hr"}, - "maintenance.recurrence_": {"none", "daily", "weekly", "monthly"}, - "storage.job_": {"compression", "retention", "refresh_continuous_aggregate", "job_stat_history_retention"}, + "status.": {"up", "degraded", "down", "unknown", "paused", "maintenance"}, + "monitors.type_": {"http", "tcp", "tls", "dns", "icmp", "json", "prometheus", "postgres", "mysql", "mssql", "mongodb", "redis", "mqtt", "kafka", "rabbitmq", "grpc", "smtp", "radius", "snmp", "steam", "minecraft", "docker", "heartbeat", "alertmanager"}, + "agents.kind_": {"checker", "statuspage"}, + "page.status.": {"operational", "degraded", "outage", "unknown", "maintenance"}, + "page.component.": {"operational", "degraded", "outage", "unknown", "maintenance"}, + "storage.level_": {"raw", "1h", "1d"}, + "legal.": {"imprint", "privacy"}, + "monitors.op_": {"eq", "ne", "gt", "ge", "lt", "le", "contains", "exists", "absent"}, + "evidence.stage_": {"dns", "connect", "tls", "response", "body"}, + "evidence.phase_": {"dns", "connect", "tls", "wait", "download"}, + "monitors.db_database_": {"postgres", "mysql", "mssql", "mongodb", "redis"}, + "monitors.broker_hint_": {"mqtt", "kafka", "rabbitmq"}, + "monitors.snmp_cond_": {"any", "eq", "ne", "contains", "gt", "ge", "lt", "le"}, + "monitors.minecraft_": {"java", "bedrock", "hint", "edition"}, + "monitors.db_tls_": {"require", "verify", "disable"}, + "moderation.target_": {"page", "org", "owner"}, + "moderation.delete_": {"page", "org", "owner"}, + "moderation.delete_confirm_": {"page", "org", "owner"}, + "weekday.": {"0", "1", "2", "3", "4", "5", "6"}, + "md.": {"heading", "bold", "italic", "strike", "link", "ul", "ol", "quote", "code", "codeblock", "table", "hr"}, + "maintenance.recurrence_": {"none", "daily", "weekly", "monthly"}, + "storage.job_": {"compression", "retention", "refresh_continuous_aggregate", "job_stat_history_retention"}, } // Notification services name their type, group and settings. families["channels.type_"] = []string{"webhook", "email"} diff --git a/internal/i18n/locales/de.json b/internal/i18n/locales/de.json index 6f97aea..8533485 100644 --- a/internal/i18n/locales/de.json +++ b/internal/i18n/locales/de.json @@ -97,8 +97,14 @@ "audit.action.platform.check_types_update": "Check-Typen geändert", "audit.action.platform.checker_network_update": "Checker-Netzwerk geändert", "audit.action.platform.legal_update": "Rechtstext der Plattform geändert", + "audit.action.platform.org_delete": "Organisation durch Admin gelöscht", + "audit.action.platform.org_suspension": "Organisation gesperrt oder entsperrt", "audit.action.platform.region_create": "Plattform-Region erstellt", "audit.action.platform.region_delete": "Plattform-Region gelöscht", + "audit.action.platform.status_page_delete": "Statusseite durch Admin gelöscht", + "audit.action.platform.status_page_suspension": "Statusseite gesperrt oder entsperrt", + "audit.action.platform.user_delete": "Account durch Admin gelöscht", + "audit.action.platform.user_suspension": "Account gesperrt oder entsperrt", "audit.action.region.create": "Region erstellt", "audit.action.region.delete": "Region gelöscht", "audit.action.role.create": "Rolle erstellt", @@ -448,7 +454,9 @@ "console.nav.settings": "Einstellungen", "console.nav.sso": "SSO", "console.nav.tokens": "API-Tokens", + "console.org_suspended": "Der Betreiber hat diese Organisation gesperrt: Ihre Monitore werden nicht geprüft und ihre Statusseiten sind offline.", "console.sso_required_action": "Mit SSO anmelden", + "console.suspended_reason": "Grund: {{.Reason}}", "console.totp_missing_action": "Jetzt einrichten", "email.opened.body": "{{.Monitor}} ({{.Target}}) ist in allen Regionen nicht erreichbar seit {{.Since}}.\n\nLetzte Fehler:\n{{.Cause}}\n\nDu erhältst diese Nachricht, weil ein Benachrichtigungskanal deiner Organisation diese Adresse nutzt.", "email.opened.subject": "[DOWN] {{.Monitor}}", @@ -456,6 +464,7 @@ "email.resolved.subject": "[UP] {{.Monitor}}", "email.test.body": "Dies ist ein Test. Wenn du ihn lesen kannst, funktioniert der Kanal.", "email.test.subject": "Testbenachrichtigung von UptimeSebi", + "error.account_suspended": "Dieser Account ist gesperrt. Wende dich an den Betreiber.", "error.agent_protocol_unsupported": "Diese Agent-Version wird von der API nicht unterstützt. Bitte den Agent aktualisieren.", "error.alert_group_not_deletable": "Die Gruppe existiert nicht oder ist die geschützte Standardgruppe.", "error.all_check_types_disabled": "Lass mindestens einen Check-Typ eingeschaltet.", @@ -499,8 +508,8 @@ "error.invalid_method": "Nur GET- und HEAD-Anfragen werden unterstützt.", "error.invalid_monitor": "Einer der Monitore existiert nicht oder ist doppelt aufgeführt.", "error.invalid_permissions": "Mindestens eine Berechtigung auswählen.", - "error.invalid_quiet_hours": "Prüfe Startzeit, Endzeit und Wochentage der Ruhezeiten.", "error.invalid_query": "Gib eine PromQL-Abfrage mit höchstens 2000 Zeichen ein.", + "error.invalid_quiet_hours": "Prüfe Startzeit, Endzeit und Wochentage der Ruhezeiten.", "error.invalid_record": "Nicht unterstützter DNS-Record-Typ.", "error.invalid_region": "Unbekannte Region.", "error.invalid_region_key": "Regions-Schlüssel haben 1–40 Zeichen: a–z, 0–9 und Bindestrich.", @@ -524,6 +533,7 @@ "error.no_password": "Konto ohne Passwort.", "error.not_found": "Nicht gefunden.", "error.org_not_found": "Organisation nicht gefunden.", + "error.org_suspended": "Der Betreiber hat diese Organisation gesperrt.", "error.owner_cannot_be_removed": "Der Owner kann nicht entfernt werden.", "error.owner_has_all_permissions": "Der Owner hat bereits alle Berechtigungen.", "error.owns_shared_orgs": "Du besitzt Organisationen mit weiteren Mitgliedern. Übergib oder lösche sie zuerst.", @@ -553,6 +563,7 @@ "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_unavailable": "Für diese Organisation ist kein Single Sign-on verfügbar.", + "error.target_is_admin": "Plattform-Admins können hier nicht gesperrt oder gelöscht werden.", "error.token_lifetime_exceeds_policy": { "one": "Tokens in dieser Organisation müssen innerhalb von {{.Count}} Tag ablaufen.", "other": "Tokens in dieser Organisation müssen innerhalb von {{.Count}} Tagen ablaufen." @@ -562,6 +573,7 @@ "error.totp_setup_expired": "Einrichtung abgelaufen, bitte neu starten.", "error.unauthenticated": "Anmeldung erforderlich.", "error.unsupported_locale": "Sprache wird nicht unterstützt.", + "error.user_owns_shared_orgs": "Dem Account gehören Organisationen mit weiteren Mitgliedern. Lösche diese zuerst oder übertrage sie.", "evidence.body": "Antwort-Body", "evidence.body_binary": "Binärer Inhalt, nicht gespeichert.", "evidence.body_empty": "Leer.", @@ -805,6 +817,31 @@ "members.scope_org": "gesamte Organisation", "members.title": "Mitglieder", "members.unassign": "Rolle entfernen", + "moderation.actions": "Sperren oder löschen …", + "moderation.created": "Erstellt", + "moderation.delete_confirm_org": "Organisation {{.Name}} mit allen Monitoren, Ergebnissen und Statusseiten endgültig löschen?", + "moderation.delete_confirm_owner": "Account {{.Name}} endgültig löschen? Organisationen, in denen nur er Mitglied ist, werden mitgelöscht.", + "moderation.delete_confirm_page": "Statusseite {{.Name}} endgültig löschen?", + "moderation.delete_org": "Organisation löschen", + "moderation.delete_owner": "Account löschen", + "moderation.delete_page": "Statusseite löschen", + "moderation.intro": "Alle veröffentlichten Statusseiten und alle gesperrten Seiten, Organisationen und Accounts, jeweils mit Organisation und Inhaber. Sperren lässt sich rückgängig machen und zeigt der Organisation den Grund; Löschen ist endgültig.", + "moderation.limited": "Nur die neuesten 500 werden angezeigt; die Suche grenzt ein.", + "moderation.none": "Keine Statusseite gefunden.", + "moderation.org": "Organisation", + "moderation.owner": "Inhaber", + "moderation.owner_is_admin": "Der Inhaber ist Plattform-Admin und kann hier nicht gesperrt oder gelöscht werden.", + "moderation.page": "Statusseite", + "moderation.reason": "Grund (optional)", + "moderation.reinstate": "Entsperren", + "moderation.search": "Titel, Adresse, Organisation oder E-Mail", + "moderation.search_button": "Suchen", + "moderation.suspend": "Sperren", + "moderation.suspended": "Gesperrt", + "moderation.target_org": "Organisation", + "moderation.target_owner": "Inhaber-Account", + "moderation.target_page": "Statusseite", + "moderation.title": "Öffentliche Statusseiten", "monitors.alertmanager_hint": "Ausgefallen, solange ein Alert feuert, der alle Matcher erfüllt. Alerts kommen über einen Empfänger:", "monitors.assertion_op": "Operator", "monitors.assertion_path": "Pfad", @@ -1031,6 +1068,8 @@ "pages.show_details": "Monitor-Details beim Anklicken anzeigen", "pages.show_details_hint": "Erlaubt Besuchern eine Detailansicht mit 24h-Verlauf, Latenz, SLA und Regionen-Status. Ziele, Fehlermeldungen und Zugangsdaten bleiben immer privat.", "pages.slug": "Kurzname (URL)", + "pages.suspended": "vom Betreiber gesperrt", + "pages.suspended_notice": "Der Betreiber hat diese Statusseite gesperrt; sie bleibt offline, bis er sie wieder freigibt.", "pages.theme": "Theme", "pages.title": "Statuspages", "pages.value": "Wert", diff --git a/internal/i18n/locales/en.json b/internal/i18n/locales/en.json index 08c27c5..a0294eb 100644 --- a/internal/i18n/locales/en.json +++ b/internal/i18n/locales/en.json @@ -97,8 +97,14 @@ "audit.action.platform.check_types_update": "Check types changed", "audit.action.platform.checker_network_update": "Checker network changed", "audit.action.platform.legal_update": "Platform legal document changed", + "audit.action.platform.org_delete": "Organization deleted by admin", + "audit.action.platform.org_suspension": "Organization suspended or reinstated", "audit.action.platform.region_create": "Platform region created", "audit.action.platform.region_delete": "Platform region deleted", + "audit.action.platform.status_page_delete": "Status page deleted by admin", + "audit.action.platform.status_page_suspension": "Status page suspended or reinstated", + "audit.action.platform.user_delete": "Account deleted by admin", + "audit.action.platform.user_suspension": "Account suspended or reinstated", "audit.action.region.create": "Region created", "audit.action.region.delete": "Region deleted", "audit.action.role.create": "Role created", @@ -448,7 +454,9 @@ "console.nav.settings": "Settings", "console.nav.sso": "SSO", "console.nav.tokens": "API tokens", + "console.org_suspended": "The operator suspended this organization: its monitors are not checked and its status pages are offline.", "console.sso_required_action": "Sign in with SSO", + "console.suspended_reason": "Reason: {{.Reason}}", "console.totp_missing_action": "Set up now", "email.opened.body": "{{.Monitor}} ({{.Target}}) is down in all of its regions since {{.Since}}.\n\nLast errors:\n{{.Cause}}\n\nYou receive this because a notification channel of your organization is set up for this address.", "email.opened.subject": "[DOWN] {{.Monitor}}", @@ -456,6 +464,7 @@ "email.resolved.subject": "[UP] {{.Monitor}}", "email.test.body": "This is a test. If you can read it, the channel works.", "email.test.subject": "Test notification from UptimeSebi", + "error.account_suspended": "This account is suspended. Contact the operator.", "error.agent_protocol_unsupported": "This agent version is not supported by the API. Please update the agent.", "error.alert_group_not_deletable": "The group does not exist or is the protected default group.", "error.all_check_types_disabled": "Leave at least one check type on.", @@ -499,8 +508,8 @@ "error.invalid_method": "Only GET and HEAD requests are supported.", "error.invalid_monitor": "One of the monitors does not exist or is listed twice.", "error.invalid_permissions": "Choose at least one permission.", - "error.invalid_quiet_hours": "Check start time, end time and weekdays of the quiet hours.", "error.invalid_query": "Enter a PromQL query of at most 2000 characters.", + "error.invalid_quiet_hours": "Check start time, end time and weekdays of the quiet hours.", "error.invalid_record": "Unsupported DNS record type.", "error.invalid_region": "Unknown region.", "error.invalid_region_key": "Region keys use 1–40 characters: a–z, 0–9 and hyphen.", @@ -524,6 +533,7 @@ "error.no_password": "This account has no password.", "error.not_found": "Not found.", "error.org_not_found": "Organization not found.", + "error.org_suspended": "The operator suspended this organization.", "error.owner_cannot_be_removed": "The owner cannot be removed.", "error.owner_has_all_permissions": "The owner already has every permission.", "error.owns_shared_orgs": "You own organizations with other members. Hand them over or delete them first.", @@ -553,6 +563,7 @@ "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_unavailable": "Single sign-on is not available for this organization.", + "error.target_is_admin": "Platform admins cannot be suspended or deleted here.", "error.token_lifetime_exceeds_policy": { "one": "Tokens in this organization must expire within {{.Count}} day.", "other": "Tokens in this organization must expire within {{.Count}} days." @@ -562,6 +573,7 @@ "error.totp_setup_expired": "Setup expired, please start again.", "error.unauthenticated": "Authentication required.", "error.unsupported_locale": "Unsupported language.", + "error.user_owns_shared_orgs": "The account owns organizations with other members. Delete those or hand them over first.", "evidence.body": "Response body", "evidence.body_binary": "Binary content, not stored.", "evidence.body_empty": "Empty.", @@ -805,6 +817,31 @@ "members.scope_org": "whole organization", "members.title": "Members", "members.unassign": "Remove role", + "moderation.actions": "Suspend or delete …", + "moderation.created": "Created", + "moderation.delete_confirm_org": "Delete the organization {{.Name}} with all its monitors, results and status pages for good?", + "moderation.delete_confirm_owner": "Delete the account {{.Name}} for good? Organizations only it belongs to go with it.", + "moderation.delete_confirm_page": "Delete the status page {{.Name}} for good?", + "moderation.delete_org": "Delete organization", + "moderation.delete_owner": "Delete account", + "moderation.delete_page": "Delete status page", + "moderation.intro": "Every published status page, and every page, organization or account that is suspended, with the organization and its owner behind it. Suspending can be undone and shows the reason to the organization; deleting cannot be undone.", + "moderation.limited": "Only the newest 500 are shown; search to narrow down.", + "moderation.none": "No status page matches.", + "moderation.org": "Organization", + "moderation.owner": "Owner", + "moderation.owner_is_admin": "The owner is a platform admin and cannot be suspended or deleted here.", + "moderation.page": "Status page", + "moderation.reason": "Reason (optional)", + "moderation.reinstate": "Reinstate", + "moderation.search": "Title, address, organization or email", + "moderation.search_button": "Search", + "moderation.suspend": "Suspend", + "moderation.suspended": "Suspended", + "moderation.target_org": "Organization", + "moderation.target_owner": "Owner account", + "moderation.target_page": "Status page", + "moderation.title": "Public status pages", "monitors.alertmanager_hint": "Down while an alert matching all matchers fires. Alerts arrive through a receiver:", "monitors.assertion_op": "Operator", "monitors.assertion_path": "Path", @@ -1031,6 +1068,8 @@ "pages.show_details": "Show component details on click", "pages.show_details_hint": "Lets visitors open a detail view with 24h history, latency, SLA and region status. Targets, errors and credentials always stay private.", "pages.slug": "Short name (URL)", + "pages.suspended": "suspended by the operator", + "pages.suspended_notice": "The operator suspended this status page; it is offline until they reinstate it.", "pages.theme": "Theme", "pages.title": "Status pages", "pages.value": "Value", diff --git a/internal/migrations/sql/00042_suspensions.sql b/internal/migrations/sql/00042_suspensions.sql new file mode 100644 index 0000000..ea5138a --- /dev/null +++ b/internal/migrations/sql/00042_suspensions.sql @@ -0,0 +1,16 @@ +-- +goose Up +-- Platform admins suspend status pages, organizations and accounts, for +-- instance over abuse. Suspension hides or stops them without deleting +-- anything; users.disabled_at already marks suspended accounts. +ALTER TABLE status_pages ADD COLUMN suspended_at timestamptz; +ALTER TABLE status_pages ADD COLUMN suspended_reason text NOT NULL DEFAULT '' CHECK (length(suspended_reason) <= 500); +ALTER TABLE orgs ADD COLUMN suspended_at timestamptz; +ALTER TABLE orgs ADD COLUMN suspended_reason text NOT NULL DEFAULT '' CHECK (length(suspended_reason) <= 500); +ALTER TABLE users ADD COLUMN disabled_reason text NOT NULL DEFAULT '' CHECK (length(disabled_reason) <= 500); + +-- +goose Down +ALTER TABLE users DROP COLUMN disabled_reason; +ALTER TABLE orgs DROP COLUMN suspended_reason; +ALTER TABLE orgs DROP COLUMN suspended_at; +ALTER TABLE status_pages DROP COLUMN suspended_reason; +ALTER TABLE status_pages DROP COLUMN suspended_at; diff --git a/internal/store/alertmanager.sql.go b/internal/store/alertmanager.sql.go index 7dd9ed7..bc1107b 100644 --- a/internal/store/alertmanager.sql.go +++ b/internal/store/alertmanager.sql.go @@ -17,6 +17,7 @@ SELECT m.id, m.org_id, m.name, m.group_id, m.interval_seconds, m.confirmations, coalesce((SELECT max(r.time) FROM check_results r WHERE r.org_id = m.org_id AND r.monitor_id = m.id AND r.time > now() - interval '2 days'), 'epoch')::timestamptz AS last_result FROM monitors m +JOIN orgs o ON o.id = m.org_id AND o.suspended_at IS NULL WHERE m.type = 'alertmanager' AND m.enabled AND ($1::uuid IS NULL OR m.org_id = $1) ` @@ -65,6 +66,7 @@ func (q *Queries) AlertmanagerMonitors(ctx context.Context, orgID *uuid.UUID) ([ const alertmanagerReceiverByHash = `-- name: AlertmanagerReceiverByHash :one UPDATE alertmanager_receivers SET last_received_at = now() WHERE token_hash = $1 + AND NOT EXISTS (SELECT 1 FROM orgs o WHERE o.id = alertmanager_receivers.org_id AND o.suspended_at IS NOT NULL) RETURNING id, org_id ` diff --git a/internal/store/heartbeats.sql.go b/internal/store/heartbeats.sql.go index 898b38a..1524940 100644 --- a/internal/store/heartbeats.sql.go +++ b/internal/store/heartbeats.sql.go @@ -13,8 +13,9 @@ import ( ) const heartbeatMonitor = `-- name: HeartbeatMonitor :one -SELECT id, org_id, interval_seconds, confirmations, enabled -FROM monitors WHERE type = 'heartbeat' AND target = $1 +SELECT m.id, m.org_id, m.interval_seconds, m.confirmations, coalesce(m.enabled AND o.suspended_at IS NULL, false)::boolean AS enabled +FROM monitors m JOIN orgs o ON o.id = m.org_id +WHERE m.type = 'heartbeat' AND m.target = $1 ` type HeartbeatMonitorRow struct { @@ -45,6 +46,7 @@ SELECT m.id, m.org_id, m.interval_seconds, m.confirmations, greatest(m.updated_at, coalesce((SELECT max(r.time) FROM check_results r WHERE r.org_id = m.org_id AND r.monitor_id = m.id AND r.time > now() - interval '3 days'), m.updated_at))::timestamptz AS waiting_since FROM monitors m +JOIN orgs o ON o.id = m.org_id AND o.suspended_at IS NULL WHERE m.type = 'heartbeat' AND m.enabled ` diff --git a/internal/store/models.go b/internal/store/models.go index 17bcd5a..4cbb1f1 100644 --- a/internal/store/models.go +++ b/internal/store/models.go @@ -284,6 +284,8 @@ type Org struct { RequireSso bool ApiTokenMaxDays *int32 DisabledCheckTypes []string + SuspendedAt *time.Time + SuspendedReason string } type PlatformSetting struct { @@ -357,6 +359,8 @@ type StatusPage struct { CreatedAt time.Time UpdatedAt time.Time ShowComponentDetails bool + SuspendedAt *time.Time + SuspendedReason string } type StatusPageGroup struct { @@ -381,17 +385,18 @@ type StatusPageMonitor struct { } type User struct { - ID uuid.UUID - Email string - DisplayName string - PasswordHash *string - DisabledAt *time.Time - CreatedAt time.Time - UpdatedAt time.Time - TotpSecret []byte - TotpEnabledAt *time.Time - Locale *string - IsAdmin bool + ID uuid.UUID + Email string + DisplayName string + PasswordHash *string + DisabledAt *time.Time + CreatedAt time.Time + UpdatedAt time.Time + TotpSecret []byte + TotpEnabledAt *time.Time + Locale *string + IsAdmin bool + DisabledReason string } type UserIdentity struct { diff --git a/internal/store/moderation.sql.go b/internal/store/moderation.sql.go new file mode 100644 index 0000000..3da9468 --- /dev/null +++ b/internal/store/moderation.sql.go @@ -0,0 +1,201 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.31.1 +// source: moderation.sql + +package store + +import ( + "context" + "time" + + "github.com/google/uuid" +) + +const adminListStatusPages = `-- name: AdminListStatusPages :many +SELECT p.id, p.slug, p.title, p.published, p.custom_domain, p.domain_verified_at, + p.suspended_at, p.suspended_reason, p.created_at, + o.id AS org_id, o.slug AS org_slug, o.name AS org_name, o.suspended_at AS org_suspended_at, o.suspended_reason AS org_suspended_reason, + coalesce(ow.id, '00000000-0000-0000-0000-000000000000'::uuid)::uuid AS owner_id, + coalesce(ow.email::text, '')::text AS owner_email, ow.disabled_at AS owner_disabled_at, + coalesce(ow.disabled_reason, '')::text AS owner_disabled_reason, coalesce(ow.is_admin, false)::boolean AS owner_is_admin +FROM status_pages p +JOIN orgs o ON o.id = p.org_id +LEFT JOIN LATERAL ( + SELECT u.id, u.email, u.disabled_at, u.disabled_reason, u.is_admin FROM memberships m JOIN users u ON u.id = m.user_id + WHERE m.org_id = o.id AND m.is_owner ORDER BY m.created_at LIMIT 1 +) ow ON true +WHERE (p.published OR p.suspended_at IS NOT NULL OR o.suspended_at IS NOT NULL) + AND ($1::text = '' + OR p.title ILIKE '%' || $1 || '%' OR p.slug::text ILIKE '%' || $1 || '%' + OR coalesce(p.custom_domain::text, '') ILIKE '%' || $1 || '%' + OR o.name ILIKE '%' || $1 || '%' OR o.slug::text ILIKE '%' || $1 || '%' + OR coalesce(ow.email::text, '') ILIKE '%' || $1 || '%') +ORDER BY p.created_at DESC +LIMIT $2 +` + +type AdminListStatusPagesParams struct { + Search string + MaxRows int32 +} + +type AdminListStatusPagesRow struct { + ID uuid.UUID + Slug string + Title string + Published bool + CustomDomain *string + DomainVerifiedAt *time.Time + SuspendedAt *time.Time + SuspendedReason string + CreatedAt time.Time + OrgID uuid.UUID + OrgSlug string + OrgName string + OrgSuspendedAt *time.Time + OrgSuspendedReason string + OwnerID uuid.UUID + OwnerEmail string + OwnerDisabledAt *time.Time + OwnerDisabledReason string + OwnerIsAdmin bool +} + +// System scope: public status pages and suspended ones, with their +// organization and its owner, newest first, matching search in title, +// slug, domain, organization or owner email. +func (q *Queries) AdminListStatusPages(ctx context.Context, arg AdminListStatusPagesParams) ([]AdminListStatusPagesRow, error) { + rows, err := q.db.Query(ctx, adminListStatusPages, arg.Search, arg.MaxRows) + if err != nil { + return nil, err + } + defer rows.Close() + items := []AdminListStatusPagesRow{} + for rows.Next() { + var i AdminListStatusPagesRow + if err := rows.Scan( + &i.ID, + &i.Slug, + &i.Title, + &i.Published, + &i.CustomDomain, + &i.DomainVerifiedAt, + &i.SuspendedAt, + &i.SuspendedReason, + &i.CreatedAt, + &i.OrgID, + &i.OrgSlug, + &i.OrgName, + &i.OrgSuspendedAt, + &i.OrgSuspendedReason, + &i.OwnerID, + &i.OwnerEmail, + &i.OwnerDisabledAt, + &i.OwnerDisabledReason, + &i.OwnerIsAdmin, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} + +const restartHeartbeatWait = `-- name: RestartHeartbeatWait :exec +UPDATE monitors SET updated_at = now() WHERE org_id = $1 AND type = 'heartbeat' +` + +// Heartbeats of an organization wait afresh after its suspension, during +// which pings were refused. +func (q *Queries) RestartHeartbeatWait(ctx context.Context, orgID uuid.UUID) error { + _, err := q.db.Exec(ctx, restartHeartbeatWait, orgID) + return err +} + +const suspendOrg = `-- name: SuspendOrg :one +UPDATE orgs SET suspended_at = CASE WHEN $1::boolean THEN coalesce(suspended_at, now()) END, + suspended_reason = CASE WHEN $1::boolean THEN $2::text ELSE '' END +WHERE id = $3 +RETURNING id, slug, name +` + +type SuspendOrgParams struct { + Suspend bool + Reason string + ID uuid.UUID +} + +type SuspendOrgRow struct { + ID uuid.UUID + Slug string + Name string +} + +func (q *Queries) SuspendOrg(ctx context.Context, arg SuspendOrgParams) (SuspendOrgRow, error) { + row := q.db.QueryRow(ctx, suspendOrg, arg.Suspend, arg.Reason, arg.ID) + var i SuspendOrgRow + err := row.Scan(&i.ID, &i.Slug, &i.Name) + return i, err +} + +const suspendStatusPage = `-- name: SuspendStatusPage :one +UPDATE status_pages SET suspended_at = CASE WHEN $1::boolean THEN coalesce(suspended_at, now()) END, + suspended_reason = CASE WHEN $1::boolean THEN $2::text ELSE '' END +WHERE id = $3 +RETURNING id, org_id, slug, custom_domain +` + +type SuspendStatusPageParams struct { + Suspend bool + Reason string + ID uuid.UUID +} + +type SuspendStatusPageRow struct { + ID uuid.UUID + OrgID uuid.UUID + Slug string + CustomDomain *string +} + +func (q *Queries) SuspendStatusPage(ctx context.Context, arg SuspendStatusPageParams) (SuspendStatusPageRow, error) { + row := q.db.QueryRow(ctx, suspendStatusPage, arg.Suspend, arg.Reason, arg.ID) + var i SuspendStatusPageRow + err := row.Scan( + &i.ID, + &i.OrgID, + &i.Slug, + &i.CustomDomain, + ) + return i, err +} + +const suspendUser = `-- name: SuspendUser :one +UPDATE users SET disabled_at = CASE WHEN $1::boolean THEN coalesce(disabled_at, now()) END, + disabled_reason = CASE WHEN $1::boolean THEN $2::text ELSE '' END +WHERE id = $3 +RETURNING id, email, is_admin +` + +type SuspendUserParams struct { + Suspend bool + Reason string + ID uuid.UUID +} + +type SuspendUserRow struct { + ID uuid.UUID + Email string + IsAdmin bool +} + +func (q *Queries) SuspendUser(ctx context.Context, arg SuspendUserParams) (SuspendUserRow, error) { + row := q.db.QueryRow(ctx, suspendUser, arg.Suspend, arg.Reason, arg.ID) + var i SuspendUserRow + err := row.Scan(&i.ID, &i.Email, &i.IsAdmin) + return i, err +} diff --git a/internal/store/monitors.sql.go b/internal/store/monitors.sql.go index 91301d3..5b469d2 100644 --- a/internal/store/monitors.sql.go +++ b/internal/store/monitors.sql.go @@ -156,6 +156,7 @@ const listEnabledMonitorsForSchedule = `-- name: ListEnabledMonitorsForSchedule SELECT m.id, m.interval_seconds, array_agg(r.region_id::text ORDER BY r.region_id)::text[] AS regions FROM monitors m JOIN monitor_regions r ON r.monitor_id = m.id +JOIN orgs o ON o.id = m.org_id AND o.suspended_at IS NULL WHERE m.enabled GROUP BY m.id, m.interval_seconds ` @@ -253,6 +254,7 @@ func (q *Queries) MonitorRegions(ctx context.Context, monitorID uuid.UUID) ([]uu const monitorsForJobs = `-- name: MonitorsForJobs :many SELECT m.id, m.org_id, m.name, m.type, m.target, m.interval_seconds, m.timeout_ms, m.config, m.enabled, m.created_at, m.updated_at, m.confirmations, m.group_id FROM monitors m JOIN monitor_regions r ON r.monitor_id = m.id AND r.region_id = $1 +JOIN orgs o ON o.id = m.org_id AND o.suspended_at IS NULL WHERE m.id = ANY ($2::uuid[]) AND m.enabled AND ($3::uuid IS NULL OR m.org_id = $3) ` @@ -305,6 +307,7 @@ SELECT m.id, m.org_id, m.name, m.target, m.interval_seconds, m.confirmations, (SELECT array_agg(r2.region_id::text ORDER BY r2.region_id) FROM monitor_regions r2 WHERE r2.monitor_id = m.id)::text[] AS regions FROM monitors m JOIN monitor_regions r ON r.monitor_id = m.id AND r.region_id = $1 +JOIN orgs o ON o.id = m.org_id AND o.suspended_at IS NULL WHERE m.id = ANY ($2::uuid[]) AND m.enabled AND ($3::uuid IS NULL OR m.org_id = $3) ` diff --git a/internal/store/orgs.sql.go b/internal/store/orgs.sql.go index 40a9122..bd3dd2d 100644 --- a/internal/store/orgs.sql.go +++ b/internal/store/orgs.sql.go @@ -13,7 +13,7 @@ import ( const createOrg = `-- name: CreateOrg :one INSERT INTO orgs (id, slug, name) VALUES ($1, $2, $3) -RETURNING id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types +RETURNING id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types, suspended_at, suspended_reason ` type CreateOrgParams struct { @@ -35,6 +35,8 @@ func (q *Queries) CreateOrg(ctx context.Context, arg CreateOrgParams) (Org, erro &i.RequireSso, &i.ApiTokenMaxDays, &i.DisabledCheckTypes, + &i.SuspendedAt, + &i.SuspendedReason, ) return i, err } @@ -52,7 +54,7 @@ func (q *Queries) DeleteOrg(ctx context.Context, id uuid.UUID) (int64, error) { } const getOrg = `-- name: GetOrg :one -SELECT id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types FROM orgs WHERE id = $1 +SELECT id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types, suspended_at, suspended_reason FROM orgs WHERE id = $1 ` func (q *Queries) GetOrg(ctx context.Context, id uuid.UUID) (Org, error) { @@ -68,12 +70,14 @@ func (q *Queries) GetOrg(ctx context.Context, id uuid.UUID) (Org, error) { &i.RequireSso, &i.ApiTokenMaxDays, &i.DisabledCheckTypes, + &i.SuspendedAt, + &i.SuspendedReason, ) return i, err } const getOrgBySlug = `-- name: GetOrgBySlug :one -SELECT id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types FROM orgs WHERE slug = $1 +SELECT id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types, suspended_at, suspended_reason FROM orgs WHERE slug = $1 ` func (q *Queries) GetOrgBySlug(ctx context.Context, slug string) (Org, error) { @@ -89,12 +93,14 @@ func (q *Queries) GetOrgBySlug(ctx context.Context, slug string) (Org, error) { &i.RequireSso, &i.ApiTokenMaxDays, &i.DisabledCheckTypes, + &i.SuspendedAt, + &i.SuspendedReason, ) return i, err } const listOrgs = `-- name: ListOrgs :many -SELECT id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types FROM orgs ORDER BY name +SELECT id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types, suspended_at, suspended_reason FROM orgs ORDER BY name ` func (q *Queries) ListOrgs(ctx context.Context) ([]Org, error) { @@ -116,6 +122,8 @@ func (q *Queries) ListOrgs(ctx context.Context) ([]Org, error) { &i.RequireSso, &i.ApiTokenMaxDays, &i.DisabledCheckTypes, + &i.SuspendedAt, + &i.SuspendedReason, ); err != nil { return nil, err } @@ -144,7 +152,7 @@ func (q *Queries) SetOrgDisabledCheckTypes(ctx context.Context, arg SetOrgDisabl const updateOrgPolicy = `-- name: UpdateOrgPolicy :one UPDATE orgs SET require_totp = $2, require_sso = $3, api_token_max_days = $4, updated_at = now() WHERE id = $1 -RETURNING id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types +RETURNING id, slug, name, created_at, updated_at, require_totp, require_sso, api_token_max_days, disabled_check_types, suspended_at, suspended_reason ` type UpdateOrgPolicyParams struct { @@ -172,6 +180,8 @@ func (q *Queries) UpdateOrgPolicy(ctx context.Context, arg UpdateOrgPolicyParams &i.RequireSso, &i.ApiTokenMaxDays, &i.DisabledCheckTypes, + &i.SuspendedAt, + &i.SuspendedReason, ) return i, err } diff --git a/internal/store/querier.go b/internal/store/querier.go index 01d98ec..0101cce 100644 --- a/internal/store/querier.go +++ b/internal/store/querier.go @@ -19,6 +19,10 @@ type Querier interface { AddMonitorAlertGroup(ctx context.Context, arg AddMonitorAlertGroupParams) (int64, error) AddMonitorRegion(ctx context.Context, arg AddMonitorRegionParams) error AddStatusPageMonitor(ctx context.Context, arg AddStatusPageMonitorParams) error + // System scope: public status pages and suspended ones, with their + // organization and its owner, newest first, matching search in title, + // slug, domain, organization or owner email. + AdminListStatusPages(ctx context.Context, arg AdminListStatusPagesParams) ([]AdminListStatusPagesRow, error) AgentInstancesByID(ctx context.Context, ids []uuid.UUID) ([]AgentInstancesByIDRow, error) // System scope: enabled alertmanager monitors of org, with when they last // recorded a result. @@ -251,6 +255,9 @@ type Querier interface { ReparentStatusPageGroupChildren(ctx context.Context, arg ReparentStatusPageGroupChildrenParams) error ReparentStatusPageGroupMonitors(ctx context.Context, arg ReparentStatusPageGroupMonitorsParams) error ResolveIncident(ctx context.Context, arg ResolveIncidentParams) (Incident, error) + // Heartbeats of an organization wait afresh after its suspension, during + // which pings were refused. + RestartHeartbeatWait(ctx context.Context, orgID uuid.UUID) error // The organization's latest results run by one checker instance. ResultsByChecker(ctx context.Context, arg ResultsByCheckerParams) ([]ResultsByCheckerRow, error) ScrubAuditEmail(ctx context.Context, email string) error @@ -271,6 +278,9 @@ type Querier interface { StorageGet(ctx context.Context, arg StorageGetParams) (StorageGetRow, error) StorageList(ctx context.Context, arg StorageListParams) ([]StorageListRow, error) StoragePut(ctx context.Context, arg StoragePutParams) error + SuspendOrg(ctx context.Context, arg SuspendOrgParams) (SuspendOrgRow, error) + SuspendStatusPage(ctx context.Context, arg SuspendStatusPageParams) (SuspendStatusPageRow, error) + SuspendUser(ctx context.Context, arg SuspendUserParams) (SuspendUserRow, error) TouchAPIToken(ctx context.Context, id uuid.UUID) error TouchAgent(ctx context.Context, arg TouchAgentParams) error // Writes at most once a minute per instance; agents poll far more often. diff --git a/internal/store/queries/alertmanager.sql b/internal/store/queries/alertmanager.sql index 5778f23..3484b3a 100644 --- a/internal/store/queries/alertmanager.sql +++ b/internal/store/queries/alertmanager.sql @@ -13,6 +13,7 @@ DELETE FROM alertmanager_receivers WHERE id = $1; -- System scope: the receiver a webhook token belongs to. UPDATE alertmanager_receivers SET last_received_at = now() WHERE token_hash = $1 + AND NOT EXISTS (SELECT 1 FROM orgs o WHERE o.id = alertmanager_receivers.org_id AND o.suspended_at IS NOT NULL) RETURNING id, org_id; -- name: UpsertAlertmanagerAlert :exec @@ -41,6 +42,7 @@ SELECT m.id, m.org_id, m.name, m.group_id, m.interval_seconds, m.confirmations, coalesce((SELECT max(r.time) FROM check_results r WHERE r.org_id = m.org_id AND r.monitor_id = m.id AND r.time > now() - interval '2 days'), 'epoch')::timestamptz AS last_result FROM monitors m +JOIN orgs o ON o.id = m.org_id AND o.suspended_at IS NULL WHERE m.type = 'alertmanager' AND m.enabled AND (sqlc.narg(org_id)::uuid IS NULL OR m.org_id = sqlc.narg(org_id)); -- name: LatestResultForMonitor :one diff --git a/internal/store/queries/heartbeats.sql b/internal/store/queries/heartbeats.sql index fd27453..04d139e 100644 --- a/internal/store/queries/heartbeats.sql +++ b/internal/store/queries/heartbeats.sql @@ -1,7 +1,8 @@ -- name: HeartbeatMonitor :one -- System scope: the monitor a ping token belongs to. -SELECT id, org_id, interval_seconds, confirmations, enabled -FROM monitors WHERE type = 'heartbeat' AND target = $1; +SELECT m.id, m.org_id, m.interval_seconds, m.confirmations, coalesce(m.enabled AND o.suspended_at IS NULL, false)::boolean AS enabled +FROM monitors m JOIN orgs o ON o.id = m.org_id +WHERE m.type = 'heartbeat' AND m.target = $1; -- name: HeartbeatsDue :many -- System scope: enabled heartbeat monitors with their grace period and @@ -13,4 +14,5 @@ SELECT m.id, m.org_id, m.interval_seconds, m.confirmations, greatest(m.updated_at, coalesce((SELECT max(r.time) FROM check_results r WHERE r.org_id = m.org_id AND r.monitor_id = m.id AND r.time > now() - interval '3 days'), m.updated_at))::timestamptz AS waiting_since FROM monitors m +JOIN orgs o ON o.id = m.org_id AND o.suspended_at IS NULL WHERE m.type = 'heartbeat' AND m.enabled; diff --git a/internal/store/queries/moderation.sql b/internal/store/queries/moderation.sql new file mode 100644 index 0000000..5da78b3 --- /dev/null +++ b/internal/store/queries/moderation.sql @@ -0,0 +1,48 @@ +-- name: AdminListStatusPages :many +-- System scope: public status pages and suspended ones, with their +-- organization and its owner, newest first, matching search in title, +-- slug, domain, organization or owner email. +SELECT p.id, p.slug, p.title, p.published, p.custom_domain, p.domain_verified_at, + p.suspended_at, p.suspended_reason, p.created_at, + o.id AS org_id, o.slug AS org_slug, o.name AS org_name, o.suspended_at AS org_suspended_at, o.suspended_reason AS org_suspended_reason, + coalesce(ow.id, '00000000-0000-0000-0000-000000000000'::uuid)::uuid AS owner_id, + coalesce(ow.email::text, '')::text AS owner_email, ow.disabled_at AS owner_disabled_at, + coalesce(ow.disabled_reason, '')::text AS owner_disabled_reason, coalesce(ow.is_admin, false)::boolean AS owner_is_admin +FROM status_pages p +JOIN orgs o ON o.id = p.org_id +LEFT JOIN LATERAL ( + SELECT u.id, u.email, u.disabled_at, u.disabled_reason, u.is_admin FROM memberships m JOIN users u ON u.id = m.user_id + WHERE m.org_id = o.id AND m.is_owner ORDER BY m.created_at LIMIT 1 +) ow ON true +WHERE (p.published OR p.suspended_at IS NOT NULL OR o.suspended_at IS NOT NULL) + AND (sqlc.arg(search)::text = '' + OR p.title ILIKE '%' || sqlc.arg(search) || '%' OR p.slug::text ILIKE '%' || sqlc.arg(search) || '%' + OR coalesce(p.custom_domain::text, '') ILIKE '%' || sqlc.arg(search) || '%' + OR o.name ILIKE '%' || sqlc.arg(search) || '%' OR o.slug::text ILIKE '%' || sqlc.arg(search) || '%' + OR coalesce(ow.email::text, '') ILIKE '%' || sqlc.arg(search) || '%') +ORDER BY p.created_at DESC +LIMIT sqlc.arg(max_rows); + +-- name: SuspendStatusPage :one +UPDATE status_pages SET suspended_at = CASE WHEN sqlc.arg(suspend)::boolean THEN coalesce(suspended_at, now()) END, + suspended_reason = CASE WHEN sqlc.arg(suspend)::boolean THEN sqlc.arg(reason)::text ELSE '' END +WHERE id = sqlc.arg(id) +RETURNING id, org_id, slug, custom_domain; + +-- name: SuspendOrg :one +UPDATE orgs SET suspended_at = CASE WHEN sqlc.arg(suspend)::boolean THEN coalesce(suspended_at, now()) END, + suspended_reason = CASE WHEN sqlc.arg(suspend)::boolean THEN sqlc.arg(reason)::text ELSE '' END +WHERE id = sqlc.arg(id) +RETURNING id, slug, name; + +-- name: SuspendUser :one +UPDATE users SET disabled_at = CASE WHEN sqlc.arg(suspend)::boolean THEN coalesce(disabled_at, now()) END, + disabled_reason = CASE WHEN sqlc.arg(suspend)::boolean THEN sqlc.arg(reason)::text ELSE '' END +WHERE id = sqlc.arg(id) +RETURNING id, email, is_admin; + +-- name: RestartHeartbeatWait :exec +-- Heartbeats of an organization wait afresh after its suspension, during +-- which pings were refused. +UPDATE monitors SET updated_at = now() WHERE org_id = $1 AND type = 'heartbeat'; + diff --git a/internal/store/queries/monitors.sql b/internal/store/queries/monitors.sql index 8e59479..4745b8f 100644 --- a/internal/store/queries/monitors.sql +++ b/internal/store/queries/monitors.sql @@ -36,6 +36,7 @@ INSERT INTO monitor_regions (monitor_id, org_id, region_id) VALUES ($1, $2, $3); SELECT m.id, m.interval_seconds, array_agg(r.region_id::text ORDER BY r.region_id)::text[] AS regions FROM monitors m JOIN monitor_regions r ON r.monitor_id = m.id +JOIN orgs o ON o.id = m.org_id AND o.suspended_at IS NULL WHERE m.enabled GROUP BY m.id, m.interval_seconds; @@ -45,6 +46,7 @@ GROUP BY m.id, m.interval_seconds; -- org-owned checker only ever sees its org's monitors. SELECT m.* FROM monitors m JOIN monitor_regions r ON r.monitor_id = m.id AND r.region_id = sqlc.arg(region_id) +JOIN orgs o ON o.id = m.org_id AND o.suspended_at IS NULL WHERE m.id = ANY (sqlc.arg(ids)::uuid[]) AND m.enabled AND (sqlc.narg(agent_org)::uuid IS NULL OR m.org_id = sqlc.narg(agent_org)); @@ -55,5 +57,6 @@ SELECT m.id, m.org_id, m.name, m.target, m.interval_seconds, m.confirmations, (SELECT array_agg(r2.region_id::text ORDER BY r2.region_id) FROM monitor_regions r2 WHERE r2.monitor_id = m.id)::text[] AS regions FROM monitors m JOIN monitor_regions r ON r.monitor_id = m.id AND r.region_id = sqlc.arg(region_id) +JOIN orgs o ON o.id = m.org_id AND o.suspended_at IS NULL WHERE m.id = ANY (sqlc.arg(ids)::uuid[]) AND m.enabled AND (sqlc.narg(agent_org)::uuid IS NULL OR m.org_id = sqlc.narg(agent_org)); diff --git a/internal/store/queries/status_pages.sql b/internal/store/queries/status_pages.sql index e68d083..e64caa6 100644 --- a/internal/store/queries/status_pages.sql +++ b/internal/store/queries/status_pages.sql @@ -89,6 +89,7 @@ DELETE FROM status_page_groups WHERE page_id = $1; -- System scope: resolves a request to a page by verified custom domain or -- by slug. SELECT * FROM status_pages -WHERE published +WHERE published AND suspended_at IS NULL + AND NOT EXISTS (SELECT 1 FROM orgs o WHERE o.id = status_pages.org_id AND o.suspended_at IS NOT NULL) AND ((sqlc.narg(host)::citext IS NOT NULL AND custom_domain = sqlc.narg(host) AND domain_verified_at IS NOT NULL) OR (sqlc.narg(slug)::citext IS NOT NULL AND slug = sqlc.narg(slug))); diff --git a/internal/store/status_pages.sql.go b/internal/store/status_pages.sql.go index 754ba3d..eb55da7 100644 --- a/internal/store/status_pages.sql.go +++ b/internal/store/status_pages.sql.go @@ -60,7 +60,7 @@ func (q *Queries) ClearStatusPageMonitors(ctx context.Context, pageID uuid.UUID) const createStatusPage = `-- name: CreateStatusPage :one INSERT INTO status_pages (org_id, slug, title, description, published, show_component_details, domain_token, theme) VALUES ($1, $2, $3, $4, $5, $6, $7, $8) -RETURNING id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details +RETURNING id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details, suspended_at, suspended_reason ` type CreateStatusPageParams struct { @@ -100,6 +100,8 @@ func (q *Queries) CreateStatusPage(ctx context.Context, arg CreateStatusPagePara &i.CreatedAt, &i.UpdatedAt, &i.ShowComponentDetails, + &i.SuspendedAt, + &i.SuspendedReason, ) return i, err } @@ -170,8 +172,9 @@ func (q *Queries) DeleteStatusPageGroup(ctx context.Context, arg DeleteStatusPag } const findPublishedPage = `-- name: FindPublishedPage :one -SELECT id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details FROM status_pages -WHERE published +SELECT id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details, suspended_at, suspended_reason FROM status_pages +WHERE published AND suspended_at IS NULL + AND NOT EXISTS (SELECT 1 FROM orgs o WHERE o.id = status_pages.org_id AND o.suspended_at IS NOT NULL) AND (($1::citext IS NOT NULL AND custom_domain = $1 AND domain_verified_at IS NOT NULL) OR ($2::citext IS NOT NULL AND slug = $2)) ` @@ -200,12 +203,14 @@ func (q *Queries) FindPublishedPage(ctx context.Context, arg FindPublishedPagePa &i.CreatedAt, &i.UpdatedAt, &i.ShowComponentDetails, + &i.SuspendedAt, + &i.SuspendedReason, ) return i, err } const getStatusPage = `-- name: GetStatusPage :one -SELECT id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details FROM status_pages WHERE id = $1 +SELECT id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details, suspended_at, suspended_reason FROM status_pages WHERE id = $1 ` func (q *Queries) GetStatusPage(ctx context.Context, id uuid.UUID) (StatusPage, error) { @@ -225,6 +230,8 @@ func (q *Queries) GetStatusPage(ctx context.Context, id uuid.UUID) (StatusPage, &i.CreatedAt, &i.UpdatedAt, &i.ShowComponentDetails, + &i.SuspendedAt, + &i.SuspendedReason, ) return i, err } @@ -265,7 +272,7 @@ func (q *Queries) ListStatusPageGroups(ctx context.Context, pageID uuid.UUID) ([ } const listStatusPages = `-- name: ListStatusPages :many -SELECT id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details FROM status_pages ORDER BY title +SELECT id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details, suspended_at, suspended_reason FROM status_pages ORDER BY title ` func (q *Queries) ListStatusPages(ctx context.Context) ([]StatusPage, error) { @@ -291,6 +298,8 @@ func (q *Queries) ListStatusPages(ctx context.Context) ([]StatusPage, error) { &i.CreatedAt, &i.UpdatedAt, &i.ShowComponentDetails, + &i.SuspendedAt, + &i.SuspendedReason, ); err != nil { return nil, err } @@ -349,7 +358,7 @@ UPDATE status_pages SET domain_verified_at = CASE WHEN custom_domain IS NOT DISTINCT FROM $1 THEN domain_verified_at END, updated_at = now() WHERE id = $2 -RETURNING id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details +RETURNING id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details, suspended_at, suspended_reason ` type SetStatusPageDomainParams struct { @@ -375,6 +384,8 @@ func (q *Queries) SetStatusPageDomain(ctx context.Context, arg SetStatusPageDoma &i.CreatedAt, &i.UpdatedAt, &i.ShowComponentDetails, + &i.SuspendedAt, + &i.SuspendedReason, ) return i, err } @@ -460,7 +471,7 @@ SET slug = $2, theme = $7, updated_at = now() WHERE id = $1 -RETURNING id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details +RETURNING id, org_id, slug, title, description, published, custom_domain, domain_token, domain_verified_at, theme, created_at, updated_at, show_component_details, suspended_at, suspended_reason ` type UpdateStatusPageParams struct { @@ -498,6 +509,8 @@ func (q *Queries) UpdateStatusPage(ctx context.Context, arg UpdateStatusPagePara &i.CreatedAt, &i.UpdatedAt, &i.ShowComponentDetails, + &i.SuspendedAt, + &i.SuspendedReason, ) return i, err } diff --git a/internal/store/users.sql.go b/internal/store/users.sql.go index d74976a..549cedc 100644 --- a/internal/store/users.sql.go +++ b/internal/store/users.sql.go @@ -24,7 +24,7 @@ func (q *Queries) AnyUserExists(ctx context.Context) (bool, error) { const createUser = `-- name: CreateUser :one INSERT INTO users (email, display_name, password_hash, locale) VALUES ($1, $2, $3, $4) -RETURNING id, email, display_name, password_hash, disabled_at, created_at, updated_at, totp_secret, totp_enabled_at, locale, is_admin +RETURNING id, email, display_name, password_hash, disabled_at, created_at, updated_at, totp_secret, totp_enabled_at, locale, is_admin, disabled_reason ` type CreateUserParams struct { @@ -54,6 +54,7 @@ func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, e &i.TotpEnabledAt, &i.Locale, &i.IsAdmin, + &i.DisabledReason, ) return i, err } @@ -94,7 +95,7 @@ func (q *Queries) EnableTOTP(ctx context.Context, arg EnableTOTPParams) error { } const getUser = `-- name: GetUser :one -SELECT id, email, display_name, password_hash, disabled_at, created_at, updated_at, totp_secret, totp_enabled_at, locale, is_admin FROM users WHERE id = $1 +SELECT id, email, display_name, password_hash, disabled_at, created_at, updated_at, totp_secret, totp_enabled_at, locale, is_admin, disabled_reason FROM users WHERE id = $1 ` func (q *Queries) GetUser(ctx context.Context, id uuid.UUID) (User, error) { @@ -112,12 +113,13 @@ func (q *Queries) GetUser(ctx context.Context, id uuid.UUID) (User, error) { &i.TotpEnabledAt, &i.Locale, &i.IsAdmin, + &i.DisabledReason, ) return i, err } const getUserByEmail = `-- name: GetUserByEmail :one -SELECT id, email, display_name, password_hash, disabled_at, created_at, updated_at, totp_secret, totp_enabled_at, locale, is_admin FROM users WHERE email = $1 +SELECT id, email, display_name, password_hash, disabled_at, created_at, updated_at, totp_secret, totp_enabled_at, locale, is_admin, disabled_reason FROM users WHERE email = $1 ` func (q *Queries) GetUserByEmail(ctx context.Context, email string) (User, error) { @@ -135,6 +137,7 @@ func (q *Queries) GetUserByEmail(ctx context.Context, email string) (User, error &i.TotpEnabledAt, &i.Locale, &i.IsAdmin, + &i.DisabledReason, ) return i, err } diff --git a/internal/web/console.templ b/internal/web/console.templ index 14e0ed9..d1c3e55 100644 --- a/internal/web/console.templ +++ b/internal/web/console.templ @@ -23,6 +23,10 @@ type Me struct { IsAdmin bool // HasPassword is false for accounts that only sign in through SSO. HasPassword bool + // OrgSuspended is set when platform admins suspended the active + // organization, with SuspendedReason as they gave it. + OrgSuspended bool + SuspendedReason string } // Org is one entry of the organization switcher. @@ -67,6 +71,16 @@ templ consoleShell(p Page, me Me) { + if me.OrgSuspended { + + } switch me.Policy { case "totp_required_by_org": @policyBanner("error.totp_required_by_org", "console.totp_missing_action", "/settings/security") diff --git a/internal/web/console_templ.go b/internal/web/console_templ.go index 4f7867e..103d387 100644 --- a/internal/web/console_templ.go +++ b/internal/web/console_templ.go @@ -32,6 +32,10 @@ type Me struct { IsAdmin bool // HasPassword is false for accounts that only sign in through SSO. HasPassword bool + // OrgSuspended is set when platform admins suspended the active + // organization, with SuspendedReason as they gave it. + OrgSuspended bool + SuspendedReason string } // Org is one entry of the organization switcher. @@ -93,7 +97,7 @@ func consoleShell(p Page, me Me) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templruntime.NewAttributeExpression(o.ID).Resolve(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 44, Col: 27} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 48, Col: 27} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var3) if templ_7745c5c3_Err != nil { @@ -116,7 +120,7 @@ func consoleShell(p Page, me Me) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(o.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 44, Col: 73} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 48, Col: 73} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -139,7 +143,7 @@ func consoleShell(p Page, me Me) templ.Component { var templ_7745c5c3_Var5 string templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(me.Orgs[0].Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 48, Col: 47} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 52, Col: 47} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { @@ -157,7 +161,7 @@ func consoleShell(p Page, me Me) templ.Component { var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.monitors.title")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 51, Col: 90} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 55, Col: 90} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { @@ -175,7 +179,7 @@ func consoleShell(p Page, me Me) templ.Component { var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.title")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 53, Col: 91} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 57, Col: 91} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -194,7 +198,7 @@ func consoleShell(p Page, me Me) templ.Component { var templ_7745c5c3_Var8 string templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "incidents.title")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 56, Col: 93} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 60, Col: 93} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { @@ -207,7 +211,7 @@ func consoleShell(p Page, me Me) templ.Component { var templ_7745c5c3_Var9 string templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "maintenance.title")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 57, Col: 97} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 61, Col: 97} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { @@ -225,7 +229,7 @@ func consoleShell(p Page, me Me) templ.Component { var templ_7745c5c3_Var10 string templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.settings")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 61, Col: 96} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 65, Col: 96} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { @@ -243,7 +247,7 @@ func consoleShell(p Page, me Me) templ.Component { var templ_7745c5c3_Var11 string templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.admin")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 63, Col: 93} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 67, Col: 93} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { @@ -261,7 +265,7 @@ func consoleShell(p Page, me Me) templ.Component { var templ_7745c5c3_Var12 string templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.nav.logout")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 65, Col: 94} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 69, Col: 94} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) if templ_7745c5c3_Err != nil { @@ -279,6 +283,44 @@ func consoleShell(p Page, me Me) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } + if me.OrgSuspended { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var13 string + templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.org_suspended")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 77, Col: 51} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if me.SuspendedReason != "" { + var templ_7745c5c3_Var14 string + templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(" " + i18n.T(ctx, "console.suspended_reason", "Reason", me.SuspendedReason)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 79, Col: 83} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } switch me.Policy { case "totp_required_by_org": templ_7745c5c3_Err = policyBanner("error.totp_required_by_org", "console.totp_missing_action", "/settings/security").Render(ctx, templ_7745c5c3_Buffer) @@ -291,7 +333,7 @@ func consoleShell(p Page, me Me) templ.Component { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -303,7 +345,7 @@ func consoleShell(p Page, me Me) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -340,7 +382,7 @@ func Security(p Page, me Me, identities []Identity, canLink bool, activity []Aud } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var14 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var16 := 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 { @@ -352,51 +394,51 @@ func Security(p Page, me Me, identities []Identity, canLink bool, activity []Aud }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var15 string - templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.title")) + var templ_7745c5c3_Var17 string + templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.title")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 91, Col: 72} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 105, Col: 72} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var16 string - templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.heading")) + var templ_7745c5c3_Var18 string + templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.heading")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 93, Col: 114} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 107, Col: 114} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if me.TOTP { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "

● ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "

● ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var17 string - templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.active")) + var templ_7745c5c3_Var19 string + templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.active")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 95, Col: 98} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 109, Col: 98} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -404,25 +446,25 @@ func Security(p Page, me Me, identities []Identity, canLink bool, activity []Aud 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, 32, "

= 3)} - templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_ElementWriter, templ_7745c5c3_Var18...) + var templ_7745c5c3_Var20 = []any{"mb-6 text-sm", templ.KV("text-down", me.RecoveryCodesLeft < 3), templ.KV("text-muted", me.RecoveryCodesLeft >= 3)} + templ_7745c5c3_Err = templ.RenderCSSItems(ctx, templ_7745c5c3_ElementWriter, templ_7745c5c3_Var20...) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var19 string - templ_7745c5c3_Var19, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.CSSClasses(templ_7745c5c3_Var18).String()).Resolve(ctx) + var templ_7745c5c3_Var21 string + templ_7745c5c3_Var21, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.CSSClasses(templ_7745c5c3_Var20).String()).Resolve(ctx) if templ_7745c5c3_Err != nil { return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 1, Col: 0} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var19) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var21) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "\"") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "\"") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -436,33 +478,33 @@ func Security(p Page, me Me, identities []Identity, canLink bool, activity []Aud } templ.ReleaseBuffer(templ_7745c5c3_Buffer) } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, ">") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, ">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var20 string - templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.recovery.left", "Count", me.RecoveryCodesLeft)) + var templ_7745c5c3_Var22 string + templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.recovery.left", "Count", me.RecoveryCodesLeft)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 97, Col: 75} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 111, Col: 75} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var21 string - templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.recovery.regenerate")) + var templ_7745c5c3_Var23 string + templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.recovery.regenerate")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 100, Col: 116} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 114, Col: 116} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -486,20 +528,20 @@ func Security(p Page, me Me, identities []Identity, canLink bool, activity []Aud if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var22 string - templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.disable")) + var templ_7745c5c3_Var24 string + templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.disable")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 110, Col: 109} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 124, Col: 109} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -519,51 +561,51 @@ func Security(p Page, me Me, identities []Identity, canLink bool, activity []Aud if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } else { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "

● ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var23 string - templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.totp.inactive")) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 119, Col: 105} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 45, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var26 string - templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.sso.heading")) + var templ_7745c5c3_Var28 string + templ_7745c5c3_Var28, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.sso.heading")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 136, Col: 113} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 150, Col: 113} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var28)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 46, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if len(identities) == 0 { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 47, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 51, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var27 string - templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.sso.none")) + var templ_7745c5c3_Var29 string + templ_7745c5c3_Var29, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.sso.none")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 138, Col: 73} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 152, Col: 73} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var29)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 48, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 52, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } else { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } if canLink { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 54, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 59, "\" class=\"inline-block 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_Var31 string - templ_7745c5c3_Var31, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.sso.link")) + var templ_7745c5c3_Var33 string + templ_7745c5c3_Var33, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.sso.link")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 147, Col: 190} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 161, Col: 190} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var33)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 56, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 60, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 57, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 61, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -705,20 +747,20 @@ func Security(p Page, me Me, identities []Identity, canLink bool, activity []Aud if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 58, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 62, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var32 string - templ_7745c5c3_Var32, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.activity_intro")) + var templ_7745c5c3_Var34 string + templ_7745c5c3_Var34, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "security.activity_intro")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 152, Col: 88} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 166, Col: 88} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var32)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var34)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 59, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 63, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -726,7 +768,7 @@ func Security(p Page, me Me, identities []Identity, canLink bool, activity []Aud if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 60, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 64, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -736,7 +778,7 @@ func Security(p Page, me Me, identities []Identity, canLink bool, activity []Aud } return nil }) - templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var14), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var16), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -763,33 +805,33 @@ func recoveryOutput() templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 61, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -814,46 +856,46 @@ func policyBanner(msgID, actionID, href string) templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 64, "

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var37 string - templ_7745c5c3_Var37, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, msgID)) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 172, Col: 23} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var37)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 65, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 68, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var39 string - templ_7745c5c3_Var39, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, actionID)) + templ_7745c5c3_Var39, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, msgID)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 173, Col: 95} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 186, Col: 23} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var39)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 67, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 69, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var41 string + templ_7745c5c3_Var41, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, actionID)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 187, Col: 95} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var41)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 71, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -878,46 +920,46 @@ func settingsLink(href, titleID, hintID string) templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 68, "") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var42 string - templ_7745c5c3_Var42, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, titleID)) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 180, Col: 56} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var42)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 70, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 72, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 73, "\" class=\"block border border-rule p-4 hover:border-ink\">") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var44 string + templ_7745c5c3_Var44, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, titleID)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 194, Col: 56} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var44)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 74, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var45 string + templ_7745c5c3_Var45, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, hintID)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/console.templ`, Line: 195, Col: 67} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var45)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 75, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -943,7 +985,7 @@ func SettingsIndex(p Page, me Me) templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var45 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var47 := 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 { @@ -959,7 +1001,7 @@ func SettingsIndex(p Page, me Me) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 72, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 76, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1025,13 +1067,13 @@ func SettingsIndex(p Page, me Me) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 73, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 77, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) - templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var45), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var47), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/internal/web/regions.templ b/internal/web/regions.templ index c333504..e44f7b9 100644 --- a/internal/web/regions.templ +++ b/internal/web/regions.templ @@ -1,6 +1,10 @@ package web -import "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" +import ( + "net/url" + + "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" +) // Region is a row in a region list. type Region struct { @@ -159,13 +163,14 @@ templ RegionsPage(p Page, me Me, v RegionsView) { } } -templ AdminPage(p Page, me Me, v RegionsView, storage StorageView, checkTypes []CheckTypeOption, platformPrivate bool) { +templ AdminPage(p Page, me Me, v RegionsView, storage StorageView, checkTypes []CheckTypeOption, platformPrivate bool, mod ModerationView) { @consoleShell(p, me) { @settingsHeading("admin.title", "admin.intro")

{ i18n.T(ctx, "audit.platform_title") } { i18n.T(ctx, "legal.platform_title") }

+ @moderationSection(mod) @regionsBody(v) @checkerNetworkSection(platformPrivate) @checkTypesSection(checkTypes, "/admin/check-types", "/admin", "admin.check_types_intro") @@ -211,3 +216,159 @@ templ checkTypesSection(types []CheckTypeOption, api, next, introID string) { } + +// ModerationView lists public status pages for platform admins. +type ModerationView struct { + Search string + Pages []ModeratedPage + // Limited is set when more pages match than are shown. + Limited bool +} + +// ModeratedPage is a status page with the organization and account +// behind it. +type ModeratedPage struct { + ID, Title, Slug, URL, Created string + Published bool + Suspended string + Org ModeratedTarget + Owner *ModeratedTarget +} + +// ModeratedTarget is an organization or account that can be suspended or +// deleted. Suspended holds the reason, or "-" without one, when suspended. +type ModeratedTarget struct { + ID, Name, Detail, Suspended string + // Admin marks platform admins, who are out of reach here. + Admin bool +} + +func (v ModerationView) next() string { + if v.Search == "" { + return "/admin#moderation" + } + return "/admin?q=" + url.QueryEscape(v.Search) + "#moderation" +} + +templ moderationSection(v ModerationView) { +
+ @sectionHeading("moderation.title") +

{ i18n.T(ctx, "moderation.intro") }

+
+ + +
+ if len(v.Pages) == 0 { +

{ i18n.T(ctx, "moderation.none") }

+ } else { +
+ + + + + + + + + + + for _, pg := range v.Pages { + + + + + + + + + + } + +
{ i18n.T(ctx, "moderation.page") }{ i18n.T(ctx, "moderation.org") }{ i18n.T(ctx, "moderation.owner") }{ i18n.T(ctx, "moderation.created") }
+ { pg.Title } + { pg.Slug } + @moderationState(pg.Suspended, !pg.Published) + + { pg.Org.Name } + { pg.Org.Detail } + @moderationState(pg.Org.Suspended, false) + + if pg.Owner != nil { + { pg.Owner.Name } + @moderationState(pg.Owner.Suspended, false) + } else { + – + } + { pg.Created }
+
+ { i18n.T(ctx, "moderation.actions") } +
+ @moderationActions("page", "/admin/status-pages/"+pg.ID, pg.Suspended, pg.Title, v.next()) + @moderationActions("org", "/admin/orgs/"+pg.Org.ID, pg.Org.Suspended, pg.Org.Name, v.next()) + if pg.Owner != nil && pg.Owner.Admin { +

{ i18n.T(ctx, "moderation.owner_is_admin") }

+ } else if pg.Owner != nil { + @moderationActions("owner", "/admin/users/"+pg.Owner.ID, pg.Owner.Suspended, pg.Owner.Name, v.next()) + } +
+
+
+
+ if v.Limited { +

{ i18n.T(ctx, "moderation.limited") }

+ } + } +
+} + +templ moderationState(suspended string, draft bool) { + if suspended != "" { + + { i18n.T(ctx, "moderation.suspended") } + if suspended != "-" { + { "· " + suspended } + } + + } else if draft { + { i18n.T(ctx, "pages.draft") } + } +} + +// moderationActions suspends, reinstates or deletes one target; kind is +// "page", "org" or "owner". +templ moderationActions(kind, api, suspended, name, next string) { +
+

{ i18n.T(ctx, "moderation.target_"+kind) }

+
+ @formError() + if suspended != "" { + + + } else { + + + + } +
+ +
+} diff --git a/internal/web/regions_templ.go b/internal/web/regions_templ.go index 78471b3..3a66ad4 100644 --- a/internal/web/regions_templ.go +++ b/internal/web/regions_templ.go @@ -9,7 +9,11 @@ package web import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" -import "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" +import ( + "net/url" + + "git.zb-server.de/ZB-Server/uptimesebi/internal/i18n" +) // Region is a row in a region list. type Region struct { @@ -81,7 +85,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var2 string templ_7745c5c3_Var2, 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/regions.templ`, Line: 49, Col: 70} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 53, Col: 70} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { @@ -94,7 +98,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var3 string templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "regions.key")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 50, Col: 67} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 54, Col: 67} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -107,7 +111,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var4 string templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "regions.owner")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 51, Col: 69} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 55, Col: 69} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -120,7 +124,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var5 string templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "regions.instances")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 52, Col: 73} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 56, Col: 73} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { @@ -138,7 +142,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(r.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 59, Col: 38} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 63, Col: 38} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { @@ -151,7 +155,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(r.Key) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 60, Col: 55} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 64, Col: 55} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -169,7 +173,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var8 string templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "regions.platform")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 63, Col: 66} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 67, Col: 66} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { @@ -183,7 +187,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var9 string templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "regions.own")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 65, Col: 36} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 69, Col: 36} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { @@ -237,7 +241,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var12 string templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "regions.live", "Count", int(r.Instances))) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 69, Col: 171} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 73, Col: 171} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) if templ_7745c5c3_Err != nil { @@ -255,7 +259,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var13 string templ_7745c5c3_Var13, templ_7745c5c3_Err = templruntime.NewAttributeExpression(v.APIBase + "/regions/" + r.ID).Resolve(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 73, Col: 74} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 77, Col: 74} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var13) if templ_7745c5c3_Err != nil { @@ -268,7 +272,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var14 string templ_7745c5c3_Var14, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "regions.delete_confirm")).Resolve(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 73, Col: 129} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 77, Col: 129} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var14) if templ_7745c5c3_Err != nil { @@ -281,7 +285,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var15 string templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "regions.delete")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 73, Col: 198} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 77, Col: 198} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) if templ_7745c5c3_Err != nil { @@ -312,7 +316,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var16 string templ_7745c5c3_Var16, templ_7745c5c3_Err = templruntime.NewAttributeExpression(v.APIBase + "/regions").Resolve(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 84, Col: 42} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 88, Col: 42} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var16) if templ_7745c5c3_Err != nil { @@ -325,7 +329,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var17 string templ_7745c5c3_Var17, templ_7745c5c3_Err = templruntime.NewAttributeExpression(v.Next).Resolve(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 84, Col: 63} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 88, Col: 63} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var17) if templ_7745c5c3_Err != nil { @@ -366,7 +370,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var18 string templ_7745c5c3_Var18, templ_7745c5c3_Err = templruntime.NewAttributeExpression(v.APIBase + "/agents").Resolve(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 93, Col: 41} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 97, Col: 41} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var18) if templ_7745c5c3_Err != nil { @@ -391,7 +395,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var19 string templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "agents.kind")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 97, Col: 114} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 101, Col: 114} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19)) if templ_7745c5c3_Err != nil { @@ -404,7 +408,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var20 string templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "agents.kind_checker")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 99, Col: 66} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 103, Col: 66} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20)) if templ_7745c5c3_Err != nil { @@ -417,7 +421,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var21 string templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "agents.kind_statuspage")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 100, Col: 72} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 104, Col: 72} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21)) if templ_7745c5c3_Err != nil { @@ -430,7 +434,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var22 string templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "agents.region")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 104, Col: 116} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 108, Col: 116} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22)) if templ_7745c5c3_Err != nil { @@ -443,7 +447,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var23 string templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "agents.no_region")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 106, Col: 56} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 110, Col: 56} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23)) if templ_7745c5c3_Err != nil { @@ -461,7 +465,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var24 string templ_7745c5c3_Var24, templ_7745c5c3_Err = templruntime.NewAttributeExpression(r.ID).Resolve(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 108, Col: 27} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 112, Col: 27} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var24) if templ_7745c5c3_Err != nil { @@ -474,7 +478,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var25 string templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(r.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 108, Col: 38} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 112, Col: 38} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25)) if templ_7745c5c3_Err != nil { @@ -501,7 +505,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var26 string templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "agents.allow_private_hint")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 114, Col: 93} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 118, Col: 93} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26)) if templ_7745c5c3_Err != nil { @@ -523,7 +527,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var27 string templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "agents.token_now")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 118, Col: 62} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 122, Col: 62} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27)) if templ_7745c5c3_Err != nil { @@ -554,7 +558,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var28 string templ_7745c5c3_Var28, templ_7745c5c3_Err = templ.JoinStringErrs(a.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 131, Col: 15} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 135, Col: 15} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var28)) if templ_7745c5c3_Err != nil { @@ -567,7 +571,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var29 string templ_7745c5c3_Var29, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "agents.kind_"+a.Kind)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 132, Col: 71} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 136, Col: 71} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var29)) if templ_7745c5c3_Err != nil { @@ -585,7 +589,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var30 string templ_7745c5c3_Var30, templ_7745c5c3_Err = templ.JoinStringErrs(a.Region) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 134, Col: 46} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 138, Col: 46} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var30)) if templ_7745c5c3_Err != nil { @@ -603,7 +607,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var31 string templ_7745c5c3_Var31, templ_7745c5c3_Err = templ.JoinStringErrs(a.Prefix) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 136, Col: 66} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 140, Col: 66} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31)) if templ_7745c5c3_Err != nil { @@ -616,7 +620,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var32 string templ_7745c5c3_Var32, templ_7745c5c3_Err = templ.JoinStringErrs(a.LastSeen) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 136, Col: 87} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 140, Col: 87} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var32)) if templ_7745c5c3_Err != nil { @@ -634,7 +638,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var33 string templ_7745c5c3_Var33, templ_7745c5c3_Err = templruntime.NewAttributeExpression(v.APIBase + "/agents/" + a.ID).Resolve(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 139, Col: 53} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 143, Col: 53} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var33) if templ_7745c5c3_Err != nil { @@ -657,7 +661,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var34 string templ_7745c5c3_Var34, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "agents.allow_private_short")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 142, Col: 52} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 146, Col: 52} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var34)) if templ_7745c5c3_Err != nil { @@ -675,7 +679,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var35 string templ_7745c5c3_Var35, templ_7745c5c3_Err = templruntime.NewAttributeExpression(v.APIBase + "/agents/" + a.ID).Resolve(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 147, Col: 71} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 151, Col: 71} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var35) if templ_7745c5c3_Err != nil { @@ -688,7 +692,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var36 string templ_7745c5c3_Var36, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "agents.revoke_confirm")).Resolve(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 147, Col: 125} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 151, Col: 125} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var36) if templ_7745c5c3_Err != nil { @@ -701,7 +705,7 @@ func regionsBody(v RegionsView) templ.Component { var templ_7745c5c3_Var37 string templ_7745c5c3_Var37, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "members.revoke")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 147, Col: 194} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 151, Col: 194} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var37)) if templ_7745c5c3_Err != nil { @@ -768,7 +772,7 @@ func RegionsPage(p Page, me Me, v RegionsView) templ.Component { }) } -func AdminPage(p Page, me Me, v RegionsView, storage StorageView, checkTypes []CheckTypeOption, platformPrivate bool) templ.Component { +func AdminPage(p Page, me Me, v RegionsView, storage StorageView, checkTypes []CheckTypeOption, platformPrivate bool, mod ModerationView) 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 { @@ -808,7 +812,7 @@ func AdminPage(p Page, me Me, v RegionsView, storage StorageView, checkTypes []C var templ_7745c5c3_Var42 string templ_7745c5c3_Var42, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "audit.platform_title")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 166, Col: 100} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 170, Col: 100} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var42)) if templ_7745c5c3_Err != nil { @@ -821,7 +825,7 @@ func AdminPage(p Page, me Me, v RegionsView, storage StorageView, checkTypes []C var templ_7745c5c3_Var43 string templ_7745c5c3_Var43, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "legal.platform_title")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 167, Col: 100} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 171, Col: 100} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var43)) if templ_7745c5c3_Err != nil { @@ -831,6 +835,10 @@ func AdminPage(p Page, me Me, v RegionsView, storage StorageView, checkTypes []C if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } + templ_7745c5c3_Err = moderationSection(mod).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } templ_7745c5c3_Err = regionsBody(v).Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err @@ -907,7 +915,7 @@ func checkerNetworkSection(allow bool) templ.Component { var templ_7745c5c3_Var45 string templ_7745c5c3_Var45, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "admin.platform_private_hint")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 188, Col: 87} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 193, Col: 87} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var45)) if templ_7745c5c3_Err != nil { @@ -920,7 +928,7 @@ func checkerNetworkSection(allow bool) templ.Component { var templ_7745c5c3_Var46 string templ_7745c5c3_Var46, 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/regions.templ`, Line: 189, Col: 129} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 194, Col: 129} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var46)) if templ_7745c5c3_Err != nil { @@ -968,7 +976,7 @@ func checkTypesSection(types []CheckTypeOption, api, next, introID string) templ var templ_7745c5c3_Var48 string templ_7745c5c3_Var48, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, introID)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 199, Col: 59} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 204, Col: 59} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var48)) if templ_7745c5c3_Err != nil { @@ -981,7 +989,7 @@ func checkTypesSection(types []CheckTypeOption, api, next, introID string) templ var templ_7745c5c3_Var49 string templ_7745c5c3_Var49, templ_7745c5c3_Err = templruntime.NewAttributeExpression(api).Resolve(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 200, Col: 22} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 205, Col: 22} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var49) if templ_7745c5c3_Err != nil { @@ -994,7 +1002,7 @@ func checkTypesSection(types []CheckTypeOption, api, next, introID string) templ var templ_7745c5c3_Var50 string templ_7745c5c3_Var50, templ_7745c5c3_Err = templruntime.NewAttributeExpression(next).Resolve(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 200, Col: 59} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 205, Col: 59} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var50) if templ_7745c5c3_Err != nil { @@ -1020,7 +1028,7 @@ func checkTypesSection(types []CheckTypeOption, api, next, introID string) templ var templ_7745c5c3_Var51 string templ_7745c5c3_Var51, templ_7745c5c3_Err = templruntime.NewAttributeExpression(t.Type).Resolve(ctx) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 205, Col: 58} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 210, Col: 58} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var51) if templ_7745c5c3_Err != nil { @@ -1043,7 +1051,7 @@ func checkTypesSection(types []CheckTypeOption, api, next, introID string) templ var templ_7745c5c3_Var52 string templ_7745c5c3_Var52, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "monitors.type_"+t.Type)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 206, Col: 44} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 211, Col: 44} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var52)) if templ_7745c5c3_Err != nil { @@ -1061,7 +1069,7 @@ func checkTypesSection(types []CheckTypeOption, api, next, introID string) templ var templ_7745c5c3_Var53 string templ_7745c5c3_Var53, 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/regions.templ`, Line: 210, Col: 129} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 215, Col: 129} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var53)) if templ_7745c5c3_Err != nil { @@ -1075,4 +1083,689 @@ func checkTypesSection(types []CheckTypeOption, api, next, introID string) templ }) } +// ModerationView lists public status pages for platform admins. +type ModerationView struct { + Search string + Pages []ModeratedPage + // Limited is set when more pages match than are shown. + Limited bool +} + +// ModeratedPage is a status page with the organization and account +// behind it. +type ModeratedPage struct { + ID, Title, Slug, URL, Created string + Published bool + Suspended string + Org ModeratedTarget + Owner *ModeratedTarget +} + +// ModeratedTarget is an organization or account that can be suspended or +// deleted. Suspended holds the reason, or "-" without one, when suspended. +type ModeratedTarget struct { + ID, Name, Detail, Suspended string + // Admin marks platform admins, who are out of reach here. + Admin bool +} + +func (v ModerationView) next() string { + if v.Search == "" { + return "/admin#moderation" + } + return "/admin?q=" + url.QueryEscape(v.Search) + "#moderation" +} + +func moderationSection(v ModerationView) 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_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 84, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = sectionHeading("moderation.title").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 85, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var55 string + templ_7745c5c3_Var55, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "moderation.intro")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 256, Col: 80} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var55)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 86, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if len(v.Pages) == 0 { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 91, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var60 string + templ_7745c5c3_Var60, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "moderation.none")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 269, Col: 65} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var60)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 92, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 93, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + for _, pg := range v.Pages { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 98, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 115, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var61 string + templ_7745c5c3_Var61, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "moderation.page")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 275, Col: 73} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var61)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 94, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var62 string + templ_7745c5c3_Var62, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "moderation.org")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 276, Col: 72} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var62)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 95, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var63 string + templ_7745c5c3_Var63, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "moderation.owner")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 277, Col: 74} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var63)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 96, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var64 string + templ_7745c5c3_Var64, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "moderation.created")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 278, Col: 76} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var64)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 97, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var66 string + templ_7745c5c3_Var66, templ_7745c5c3_Err = templ.JoinStringErrs(pg.Title) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 285, Col: 119} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var66)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 100, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var67 string + templ_7745c5c3_Var67, templ_7745c5c3_Err = templ.JoinStringErrs(pg.Slug) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 286, Col: 67} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var67)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 101, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = moderationState(pg.Suspended, !pg.Published).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 102, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var68 string + templ_7745c5c3_Var68, templ_7745c5c3_Err = templ.JoinStringErrs(pg.Org.Name) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 290, Col: 22} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var68)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 103, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var69 string + templ_7745c5c3_Var69, templ_7745c5c3_Err = templ.JoinStringErrs(pg.Org.Detail) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 291, Col: 73} + } + _, 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, 104, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = moderationState(pg.Org.Suspended, false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 105, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if pg.Owner != nil { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 106, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var70 string + templ_7745c5c3_Var70, templ_7745c5c3_Err = templ.JoinStringErrs(pg.Owner.Name) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 296, Col: 49} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var70)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 107, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = moderationState(pg.Owner.Suspended, false).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 108, "–") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 109, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var71 string + templ_7745c5c3_Var71, templ_7745c5c3_Err = templ.JoinStringErrs(pg.Created) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 302, Col: 73} + } + _, 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, 110, "
") + 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, "moderation.actions")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 307, Col: 103} + } + _, 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, 111, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = moderationActions("page", "/admin/status-pages/"+pg.ID, pg.Suspended, pg.Title, v.next()).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = moderationActions("org", "/admin/orgs/"+pg.Org.ID, pg.Org.Suspended, pg.Org.Name, v.next()).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if pg.Owner != nil && pg.Owner.Admin { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 112, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var73 string + templ_7745c5c3_Var73, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "moderation.owner_is_admin")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 312, Col: 84} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var73)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 113, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else if pg.Owner != nil { + templ_7745c5c3_Err = moderationActions("owner", "/admin/users/"+pg.Owner.ID, pg.Owner.Suspended, pg.Owner.Name, v.next()).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 114, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if v.Limited { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 116, "

") + 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, "moderation.limited")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 325, Col: 74} + } + _, 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, 117, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 118, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +func moderationState(suspended string, draft 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) + if suspended != "" { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 119, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var76 string + templ_7745c5c3_Var76, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "moderation.suspended")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 334, Col: 40} + } + _, 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, 120, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if suspended != "-" { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 121, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var77 string + templ_7745c5c3_Var77, templ_7745c5c3_Err = templ.JoinStringErrs("· " + suspended) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 336, Col: 60} + } + _, 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, 122, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 123, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else if draft { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 124, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var78 string + templ_7745c5c3_Var78, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.draft")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 340, Col: 81} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var78)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 125, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + return nil + }) +} + +// moderationActions suspends, reinstates or deletes one target; kind is +// "page", "org" or "owner". +func moderationActions(kind, api, suspended, name, next string) 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_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 126, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var80 string + templ_7745c5c3_Var80, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "moderation.target_"+kind)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/regions.templ`, Line: 348, Col: 115} + } + _, 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, 127, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = formError().Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if suspended != "" { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 130, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 132, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 136, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + var _ = templruntime.GeneratedTemplate diff --git a/internal/web/statuspages.templ b/internal/web/statuspages.templ index 12f399e..7d7332a 100644 --- a/internal/web/statuspages.templ +++ b/internal/web/statuspages.templ @@ -14,6 +14,7 @@ type PageRow struct { Published bool URL string Domain string + Suspended bool } // PagesView is the data of the status page list. @@ -29,7 +30,9 @@ templ StatusPagesPage(p Page, me Me, v PagesView) { ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, " ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if v.CanWrite { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -220,7 +244,7 @@ func StatusPagesPage(p Page, me Me, v PagesView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -240,7 +264,7 @@ func StatusPagesPage(p Page, me Me, v PagesView) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -277,23 +301,25 @@ type PageMonitorOption struct { // PageEditor is the data of the status page editor. type PageEditor struct { - ID string - Title string - Slug string - Description string - Published bool - ShowDetails bool - Accent string - LogoURL string - CSS string - URL string - Domain string - DomainVerified bool - RecordName string - RecordValue string - Groups []PageGroupRow - HasOrgGroups bool - Monitors []PageMonitorOption + ID string + Title string + Slug string + Description string + Published bool + ShowDetails bool + Accent string + LogoURL string + CSS string + URL string + Domain string + DomainVerified bool + RecordName string + RecordValue string + Suspended bool + SuspendedReason string + Groups []PageGroupRow + HasOrgGroups bool + Monitors []PageMonitorOption } func StatusPageEditor(p Page, me Me, e PageEditor) templ.Component { @@ -313,7 +339,7 @@ func StatusPageEditor(p Page, me Me, e PageEditor) templ.Component { } ctx = templ.InitializeContext(ctx) ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var11 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var12 := 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 { @@ -325,95 +351,133 @@ func StatusPageEditor(p Page, me Me, e PageEditor) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "

← ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var12 string - templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.title")) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 108, Col: 115} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "

← ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var13 string - templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(e.Title) + templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.title")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 110, Col: 46} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 115, Col: 115} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - if e.Published { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var14 string - templ_7745c5c3_Var14, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.SafeURL(e.URL)).ResolveURL(ctx) + templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.suspended_notice")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 113, Col: 35} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 118, Col: 43} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var14) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "\" target=\"_blank\" rel=\"noopener\" class=\"text-muted hover:text-ink\">") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, " ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var15 string - templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.open")) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 113, Col: 130} + if e.SuspendedReason != "" { + var templ_7745c5c3_Var15 string + templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(" " + i18n.T(ctx, "console.suspended_reason", "Reason", e.SuspendedReason)) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 120, Col: 81} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, " ↗ ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var16 string - templ_7745c5c3_Var16, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.SafeURL("/api/v1/org/statuspages/" + e.ID + "/export")).ResolveURL(ctx) + templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(e.Title) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 115, Col: 74} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 125, Col: 46} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var16) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "\" class=\"text-muted hover:text-ink\">") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var17 string - templ_7745c5c3_Var17, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.export")) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 115, Col: 140} + if e.Published { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var18 string + templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.open")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 128, Col: 130} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, " ↗ ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "
") + var templ_7745c5c3_Var19 string + templ_7745c5c3_Var19, templ_7745c5c3_Err = templruntime.NewAttributeExpression(templ.SafeURL("/api/v1/org/statuspages/" + e.ID + "/export")).ResolveURL(ctx) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 130, Col: 74} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var19) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "\" class=\"text-muted hover:text-ink\">") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var20 string + templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.export")) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 130, Col: 140} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -421,33 +485,33 @@ func StatusPageEditor(p Page, me Me, e PageEditor) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -463,20 +527,20 @@ func StatusPageEditor(p Page, me Me, e PageEditor) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var20 string - templ_7745c5c3_Var20, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.description")) + var templ_7745c5c3_Var23 string + templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.description")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 126, Col: 121} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 141, Col: 121} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var20)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -484,7 +548,7 @@ func StatusPageEditor(p Page, me Me, e PageEditor) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -496,33 +560,33 @@ func StatusPageEditor(p Page, me Me, e PageEditor) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var21 string - templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.show_details_hint")) + var templ_7745c5c3_Var24 string + templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.show_details_hint")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 131, Col: 86} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 146, Col: 86} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var22 string - templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.theme")) + var templ_7745c5c3_Var25 string + templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.theme")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 132, Col: 111} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 147, Col: 111} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -534,33 +598,33 @@ func StatusPageEditor(p Page, me Me, e PageEditor) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -568,46 +632,46 @@ func StatusPageEditor(p Page, me Me, e PageEditor) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -616,152 +680,152 @@ func StatusPageEditor(p Page, me Me, e PageEditor) templ.Component { return templ_7745c5c3_Err } if e.HasOrgGroups { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 45, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 56, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var32 string - templ_7745c5c3_Var32, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.groups_intro")) + var templ_7745c5c3_Var35 string + templ_7745c5c3_Var35, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.groups_intro")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 164, Col: 75} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 179, Col: 75} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var32)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var35)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 51, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 57, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if len(e.Groups) > 0 { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 52, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 81, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 87, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 82, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 90, "\" class=\"border border-rule p-3\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1057,20 +1121,20 @@ func StatusPageEditor(p Page, me Me, e PageEditor) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 85, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1307,33 +1371,33 @@ func StatusPageEditor(p Page, me Me, e PageEditor) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 106, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 114, "\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1342,205 +1406,205 @@ func StatusPageEditor(p Page, me Me, e PageEditor) templ.Component { return templ_7745c5c3_Err } if len(e.Monitors) == 0 { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 109, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 115, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var70 string - templ_7745c5c3_Var70, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.monitors.empty")) + var templ_7745c5c3_Var73 string + templ_7745c5c3_Var73, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "console.monitors.empty")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 239, Col: 81} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 254, Col: 81} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var70)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var73)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 110, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 116, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 111, "
    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 117, "
      ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } for _, m := range e.Monitors { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 112, "
    • ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var72 string - templ_7745c5c3_Var72, templ_7745c5c3_Err = templ.JoinStringErrs(m.Name) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 246, Col: 24} - } - _, 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, 116, " ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - if m.MonitorGroupPath != "" { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 117, "") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var73 string - templ_7745c5c3_Var73, templ_7745c5c3_Err = templ.JoinStringErrs(m.MonitorGroupPath) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 248, Col: 74} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var73)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 118, "") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 119, " ") + var templ_7745c5c3_Var77 string + templ_7745c5c3_Var77, templ_7745c5c3_Err = templruntime.NewAttributeExpression(m.ID).Resolve(ctx) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 266, Col: 66} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var77) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - for _, opt := range e.Groups { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 123, "") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 126, "\"> ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var80 string - templ_7745c5c3_Var80, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "pages.label")).Resolve(ctx) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 260, Col: 94} + for _, opt := range e.Groups { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 129, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var80) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 134, "
    • ") + var templ_7745c5c3_Var82 string + templ_7745c5c3_Var82, templ_7745c5c3_Err = templruntime.NewAttributeExpression(m.Label).Resolve(ctx) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 275, Col: 51} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var82) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 135, "\" placeholder=\"") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var83 string + templ_7745c5c3_Var83, templ_7745c5c3_Err = templruntime.NewAttributeExpression(i18n.T(ctx, "pages.label")).Resolve(ctx) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 275, Col: 94} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var83) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 136, "\" class=\"w-1/2 border border-rule bg-transparent px-2 py-1 text-xs outline-none focus:border-ink\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 131, "
    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 137, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1548,7 +1612,7 @@ func StatusPageEditor(p Page, me Me, e PageEditor) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 132, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 138, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1556,33 +1620,33 @@ func StatusPageEditor(p Page, me Me, e PageEditor) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 133, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 141, "\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1598,155 +1662,155 @@ func StatusPageEditor(p Page, me Me, e PageEditor) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 136, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 142, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if e.Domain != "" { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 137, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 143, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if e.DomainVerified { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 138, "

● ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var83 string - templ_7745c5c3_Var83, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.domain_verified")) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 278, Col: 82} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var83)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 139, "

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var84 string - templ_7745c5c3_Var84, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.domain_cname")) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 279, Col: 78} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var84)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 140, "

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } else { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 141, "

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var85 string - templ_7745c5c3_Var85, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.domain_instructions")) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 281, Col: 66} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var85)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 142, "

TXT
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 144, "

● ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var86 string - templ_7745c5c3_Var86, templ_7745c5c3_Err = templ.JoinStringErrs(e.RecordName) + templ_7745c5c3_Var86, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.domain_verified")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 284, Col: 45} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 293, Col: 82} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var86)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 143, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 145, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var87 string - templ_7745c5c3_Var87, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.value")) + templ_7745c5c3_Var87, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.domain_cname")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 285, Col: 60} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 294, Col: 78} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var87)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 144, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 146, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 147, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var88 string - templ_7745c5c3_Var88, templ_7745c5c3_Err = templ.JoinStringErrs(e.RecordValue) + templ_7745c5c3_Var88, templ_7745c5c3_Err = templ.JoinStringErrs(i18n.T(ctx, "pages.domain_instructions")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 286, Col: 46} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/web/statuspages.templ`, Line: 296, Col: 66} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var88)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 145, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 151, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 149, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 155, "
") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 150, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 156, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) - templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var11), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = consoleShell(p, me).Render(templ.WithChildren(ctx, templ_7745c5c3_Var12), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err }