Repository navigation
Admin portal Phase 5: notices + site-wide banners - #179
Merged
Merged
Conversation
Deploying nemar-website with
|
| Latest commit: |
e977f95
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://b8396551.nemar-website.pages.dev |
| Branch Preview URL: | https://feature-issue-178-phase5-not.nemar-website.pages.dev |
This was referenced Jul 25, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #178. Phase 5 of epic #158 — the last phase, so this completes the epic.
Adds
/admin/notices(list / create / delete) and renders active notices as stacking site-wide banners on every page.What's here
src/lib/notices-api.ts— public banner feed + admin CRUD, every fetch deadline-boundedsrc/pages/api/notices.ts— same-originno-storeJSON feed for the bannersrc/components/SiteNotices.astro— stacking banners inBase.astro, one tone per level, per-notice dismissalsrc/pages/admin/notices.astro— create form (level / audience / expiry, with live consequence hints and a 1000-char counter) and a list that marks lapsed noticesADMIN_TABSis now liveDecisions worth reviewing
The banner is client-fetched, never server-rendered.
index.astro,discover.astro, anddataset/[id].astroall set real edge-cache headers with long stale-while-revalidate windows — 12 h on the landing page, 24 h on dataset detail. An SSR'd banner would be frozen into that cached HTML: a new outage notice invisible untils-maxageelapsed, a resolved one lingering for the whole SWR window. Fetching from ano-storesame-origin route keeps page HTML cacheable and the banner current.Expiry is computed client-side. Per nemar-cli#1024 (filed from this work), the backend compares an ISO-8601
expires_atagainst SQLite'sdatetime('now')as strings;Tsorts after a space, so a notice expiring later today is still served as active until the next UTC day. Verified withsqlite3. Both the banner and the admin list therefore compute expiry themselves — the nemar-cli CLI already does the same, so this matches existing behaviour rather than inventing a workaround.Dismissal is per-notice and level-dependent. Keyed by notice id, so dismissing a standing announcement never suppresses a maintenance banner posted later.
info/warningdismissals persist inlocalStorage— a months-long "the site has moved" banner that returned on every visit would be an irritation.criticalusessessionStorage, so an active outage can be pushed aside but re-asserts on the next visit.Levels are
info | warning | critical, fixed upstream by both a zod enum and migration 0016'sCHECK. Each gets a distinct tone (info reads as a tip, warning amber, critical as an outage). A separatemaintenancelevel would need an upstream migration and is not attempted here.Messages render via
textContent, neverinnerHTML. Admin-authored is not the same as trusted markup, and a banner on every page is the last place to allow injection.Bug caught by running it
/api/noticesinitially returned nothing for anonymous visitors.dashboardApiBase()infers "SSR" from the presence of a cookie header, but an anonymous request has none, so it resolved to the relative/api/v1— unfetchable server-side. Because the banner fails soft, the symptom was not an error but a banner that silently never appeared for signed-out visitors, i.e. most of the marketing surface. Fixed with an explicitbaseUrlpassed by the route; the cookie heuristic stays correct for the authenticated admin clients that rely on it.Testing
bun run test— 837 passing (32 new).bun run typecheck0 errors,bun run lintclean,bun run buildclean.PUBLIC_API_BASE_URL), not just unit tests:role="alert"on critical only,role="status"on the restlevel: criticalwith18:30local correctly stored as01:30Zthe next day; delete → row removed via the typed-confirmation dialog/admin/notices302s to/login?next=…, admin gets 200.Still worth a real admin pass on the preview deploy against live data, same as Phases 3 and 4.