diff --git a/internal/api/dashboard_filter_test.go b/internal/api/dashboard_filter_test.go index d30ec1f..a367188 100644 --- a/internal/api/dashboard_filter_test.go +++ b/internal/api/dashboard_filter_test.go @@ -55,3 +55,31 @@ func TestDashboardFiltersByStatus(t *testing.T) { t.Error("an unknown status filter hides monitors") } } + +func TestSignupSendsSignedInUsersToTheMonitors(t *testing.T) { + e := newEnv(t) + visitor := e.browser(t) + if st, path, _ := visitor.page("/signup"); st != http.StatusOK || path != "/signup" { + t.Fatalf("signup for a visitor = %d at %s", st, path) + } + owner := e.browser(t) + owner.signup("o@"+uniq("su")+".test", uniq("su-")) + if st, path, html := owner.page("/signup"); st != http.StatusOK || path != "/" || !strings.Contains(html, "Monitors") { + t.Errorf("signup when signed in ended at %s (%d), want the monitor list", path, st) + } +} + +func TestPageEditorOffersAddAndRemoveAll(t *testing.T) { + e := newEnv(t) + _, region := e.platformChecker(t, uniq("eu-")) + owner := e.browser(t) + owner.signup("o@"+uniq("pa")+".test", uniq("pa-")) + owner.do("POST", "/api/v1/org/monitors", map[string]any{"name": "Shop", "type": "http", "target": "https://shop.test", "interval_seconds": 60, "regions": []string{region}}) + _, p := owner.do("POST", "/api/v1/org/statuspages", map[string]any{"slug": uniq("pa-"), "title": "Status"}) + _, _, html := owner.page("/statuspages/" + p["id"].(string)) + for _, want := range []string{`data-check-all="on"`, `data-check-all="off"`, "Add all", "Remove all"} { + if !strings.Contains(html, want) { + t.Errorf("the page editor lacks %q", want) + } + } +} diff --git a/internal/api/pages.go b/internal/api/pages.go index 21e4cb8..0079d96 100644 --- a/internal/api/pages.go +++ b/internal/api/pages.go @@ -122,6 +122,11 @@ func (s *Server) signupOptions(ctx context.Context) (bool, []web.IDPButton, erro } func (s *Server) signupPage(c *gin.Context) { + // Signed in already: straight to the monitors. + if auth.Current(c) != nil { + c.Redirect(http.StatusSeeOther, "/") + return + } email, providers, err := s.signupOptions(c.Request.Context()) if err != nil { internalError(c, err) diff --git a/internal/i18n/locales/de.json b/internal/i18n/locales/de.json index 0528950..8a3f293 100644 --- a/internal/i18n/locales/de.json +++ b/internal/i18n/locales/de.json @@ -1290,6 +1290,8 @@ "pages.intro": "Öffentliche Seiten mit dem Zustand ausgewählter Monitore. Jede Seite kann eine eigene Domain nutzen oder als einzelne HTML-Datei exportiert werden.", "pages.label": "Öffentlicher Name", "pages.logo": "Logo-URL (https)", + "pages.monitors_all": "Alle hinzufügen", + "pages.monitors_none": "Alle entfernen", "pages.no_group": "Ohne Gruppe", "pages.open": "Öffnen", "pages.own_servers": "Die Statusseiten dieser Organisation liefern nur ihre eigenen Statusseiten-Server aus, nicht die der Plattform. Ruf sie über die Adresse deiner Server auf oder verbinde eine eigene Domain, die auf sie zeigt.", diff --git a/internal/i18n/locales/en.json b/internal/i18n/locales/en.json index 4b0d5f8..e39a590 100644 --- a/internal/i18n/locales/en.json +++ b/internal/i18n/locales/en.json @@ -1290,6 +1290,8 @@ "pages.intro": "Public pages showing the state of selected monitors. Each page can use its own domain or be exported as a single HTML file.", "pages.label": "Public name", "pages.logo": "Logo URL (https)", + "pages.monitors_all": "Add all", + "pages.monitors_none": "Remove all", "pages.no_group": "No group", "pages.open": "Open", "pages.own_servers": "Your organization's own status page servers serve its pages; the platform's do not. Open them at the address of your servers or connect a custom domain pointing at them.", diff --git a/internal/web/assets/app.js b/internal/web/assets/app.js index 347894d..5bec5f5 100644 --- a/internal/web/assets/app.js +++ b/internal/web/assets/app.js @@ -186,6 +186,15 @@ navToggle.setAttribute("aria-expanded", String(open)); return; } + // Ticks or clears every checkbox named by data-check-all in its form. + const checkAll = ev.target.closest("[data-check-all]"); + if (checkAll) { + const on = checkAll.dataset.checkAll === "on"; + checkAll.closest("form")?.querySelectorAll(checkAll.dataset.checkTarget).forEach((box) => { + box.checked = on; + }); + return; + } const locale = ev.target.closest("[data-locale]"); if (locale) { await api.post("/locale", { locale: locale.dataset.locale }).catch(() => {}); diff --git a/internal/web/statuspages.templ b/internal/web/statuspages.templ index d2d787a..8b6784c 100644 --- a/internal/web/statuspages.templ +++ b/internal/web/statuspages.templ @@ -272,6 +272,11 @@ templ StatusPageEditor(p Page, me Me, e PageEditor) { @formError() if len(e.Monitors) == 0 {

{ i18n.T(ctx, "console.monitors.empty") }

+ } else { +

+ + +

}