feat(notify): name regions and link the console in alerts; consent to subscribe
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 11m8s
ci / test (pull_request) Successful in 13m45s
ci / build (pull_request) Successful in 19m0s
ci / image (pull_request) Successful in 6m5s
ci / lint (push) Skipped
ci / test (push) Skipped
ci / build (push) Skipped
ci / image (push) Skipped
ci / lint (pull_request) Successful in 11m8s
ci / test (pull_request) Successful in 13m45s
ci / build (pull_request) Successful in 19m0s
ci / image (pull_request) Successful in 6m5s
Alert mails and chat messages named regions by id. They now show the region's name and mails link the monitor in the console. Visitors of a status page accept the platform's terms and the page's privacy policy, where set, before they can subscribe to it; the status page server and the API both check it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
This commit is contained in:
1 parent
cca4e80e54
commit
2d4bd10c9b
16 files changed
+660
-479
No files matched your search
+26
-2
@@ -2,6 +2,7 @@ package web
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"slices"
|
||||
|
||||
"github.com/yuin/goldmark"
|
||||
"github.com/yuin/goldmark/ast"
|
||||
@@ -80,7 +81,30 @@ func LegalLinks(docs []agentapi.LegalDoc, base string) []LegalLink {
|
||||
return out
|
||||
}
|
||||
|
||||
// PageLegalLinks returns the legal links of a status page.
|
||||
// PageLegalLinks returns the legal links of a status page's footer. The
|
||||
// terms are not among them: visitors accept them only when subscribing.
|
||||
func PageLegalLinks(s agentapi.PageSnapshot, base string) []LegalLink {
|
||||
return LegalLinks(s.Legal, base)
|
||||
return slices.DeleteFunc(LegalLinks(s.Legal, base), func(l LegalLink) bool { return l.Kind == "terms" })
|
||||
}
|
||||
|
||||
// SubscribeConsent returns the documents a visitor of a status page
|
||||
// accepts by subscribing: the terms and the privacy policy, where set.
|
||||
func SubscribeConsent(s agentapi.PageSnapshot, base string) []LegalLink {
|
||||
return slices.DeleteFunc(LegalLinks(s.Legal, base), func(l LegalLink) bool { return l.Kind == "imprint" })
|
||||
}
|
||||
|
||||
// ConsentLabelID names the message of the subscription checkbox for links.
|
||||
func ConsentLabelID(links []LegalLink) string {
|
||||
var terms, privacy bool
|
||||
for _, l := range links {
|
||||
terms = terms || l.Kind == "terms"
|
||||
privacy = privacy || l.Kind == "privacy"
|
||||
}
|
||||
switch {
|
||||
case terms && privacy:
|
||||
return "page.subscribe.accept_both"
|
||||
case terms:
|
||||
return "page.subscribe.accept_terms"
|
||||
}
|
||||
return "page.subscribe.accept_privacy"
|
||||
}
|
||||
@@ -114,10 +114,26 @@ templ publicSubscribe(s agentapi.PageSnapshot, a PublicAssets) {
|
||||
<section id="subscribe" class="mb-12 border-t border-rule pt-6">
|
||||
<h2 class="mb-1 text-xs font-medium uppercase tracking-wider text-muted">{ i18n.T(ctx, "page.subscribe.title") }</h2>
|
||||
<p class="mb-3 text-sm">{ i18n.T(ctx, "page.subscribe.intro") }</p>
|
||||
<form method="post" action={ templ.SafeURL(a.ComponentBase + "subscribe") } class="flex max-w-md flex-wrap gap-2">
|
||||
<label class="sr-only" for="subscribe-email">{ i18n.T(ctx, "page.subscribe.email") }</label>
|
||||
<input id="subscribe-email" type="email" name="email" required maxlength="254" autocomplete="email" placeholder={ i18n.T(ctx, "page.subscribe.email") } class="min-w-0 flex-1 border border-rule bg-transparent px-2 py-1.5 text-sm"/>
|
||||
<button type="submit" class="border border-ink px-3 py-1.5 text-sm hover:bg-ink hover:text-paper">{ i18n.T(ctx, "page.subscribe.submit") }</button>
|
||||
<form method="post" action={ templ.SafeURL(a.ComponentBase + "subscribe") } class="max-w-md">
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<label class="sr-only" for="subscribe-email">{ i18n.T(ctx, "page.subscribe.email") }</label>
|
||||
<input id="subscribe-email" type="email" name="email" required maxlength="254" autocomplete="email" placeholder={ i18n.T(ctx, "page.subscribe.email") } class="min-w-0 flex-1 border border-rule bg-transparent px-2 py-1.5 text-sm"/>
|
||||
<button type="submit" class="border border-ink px-3 py-1.5 text-sm hover:bg-ink hover:text-paper">{ i18n.T(ctx, "page.subscribe.submit") }</button>
|
||||
</div>
|
||||
if consent := SubscribeConsent(s, a.LegalBase); len(consent) > 0 {
|
||||
<label class="mt-3 flex items-start gap-2 text-sm">
|
||||
<input type="checkbox" name="accept" value="1" required class="mt-1"/>
|
||||
<span>
|
||||
{ i18n.T(ctx, ConsentLabelID(consent)) }
|
||||
for i, l := range consent {
|
||||
if i > 0 {
|
||||
<span aria-hidden="true">·</span>
|
||||
}
|
||||
<a href={ templ.SafeURL(l.Href) } target="_blank" rel="noopener" class="underline underline-offset-2">{ i18n.T(ctx, LegalTitleID(l.Kind)) }</a>
|
||||
}
|
||||
</span>
|
||||
</label>
|
||||
}
|
||||
</form>
|
||||
<p class="mt-2 text-xs text-muted">{ i18n.T(ctx, "page.subscribe.privacy") }</p>
|
||||
</section>
|
||||
|
||||
+511
-446
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user