Panel: a global admin can add, edit and delete campuses and open a campus's settings #207
Labels
No labels
Area/Backend
Area/Database
Area/Docs
Area/Frontend
Area/Infra
Area/Security
Area/Tests
Area/Tooling
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Lang/Python
Lang/Rust
Lang/Shell
Lang/SQL
Lang/TypeScript
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Routing
Auto
Routing
Hold
Routing
Human
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Grimoirix/grimoire-of-digital-signage#207
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Product owner, 2026-11-15 (GRI-2051): "I don't see a way to add a campus or change settings from a campus from the global admin view."
Today. The server already has the API:
GET/POST /api/v1/campuses,PATCH/DELETE /api/v1/campuses/{id}(crates/server/src/campus.rs). The panel only useslistCampuses./settingsshows the global screen to a global admin andCampusSettingsScreenonly to a user whose own account has a campus — so a global admin can neither create a campus nor open one campus's settings.Wanted.
CampusSettingsScreen: playback defaults, and later more), reached from the list by a global admin.Uses the left sub-menu layout from the navigation issue filed at the same time, if that lands first.
Acceptance. A global admin creates a campus, renames it, sets its playback default, and deletes an empty one, all from the panel. A campus admin cannot see other campuses.
Layout: see #210.
Read #207 and the referenced #210 (navigation; still
todo, not landed — implementing without its left sub-menu for now, as the issue allows).Today.
crates/server/src/campus.rsalready has full CRUD (GET/POST /campuses,PATCH/DELETE /campuses/{id}), admin-gated. The panel only callslistCampuses(frontend-web/src/api/campusApi.ts), and/settingspicksCampusSettingsScreenonly when the signed-in user has their owncampusId, else the globalSettingsScreen— which has no campus management UI at all (DashboardScreen.tsx:83-88).Two small server gaps, both needed for the acceptance criteria:
DELETE /campuses/{id}'s409 campus_in_useis a bare message naming no specifics — the issue requires it say what still uses it.Proposed contract (wire format stays snake_case, same convention as
playback_settings.rs):GET /api/v1/campuses— each item gains two counts: Counts viaLEFT JOIN/COUNTgrouped by campus id, ordered by code (unchanged).POST/PATCHkeep returning the bare{id, code, name}row — the panel sets a new campus's counts to 0 locally and leaves counts alone on rename.POST /api/v1/campuses,PATCH /api/v1/campuses/{id}— unchanged (already admin-gated, already validate non-emptycode/name, already409 duplicate_codeon a clashing code).DELETE /api/v1/campuses/{id}— on the FK violation, build the message the waymedia_in_use_erroralready does for media (media/handlers.rs:761), counting rows inmedia,playlists,devices,ip_ruleswith thiscampus_idinstead of re-deriving from the FK error: Only non-zero categories appear in the message;detailsalways carries all four so the panel never has to parse the sentence.Panel.
Settings → Campuses: list (code, name, device count, playlist count), Add a campus (code + name), rename, delete with the message above shown verbatim on a409 campus_in_use.CampusSettingsScreen(playback default today), reached at/settings/campuses/{id}with a way back to the list. A global admin reaches it this way; a campus-scoped user keeps reaching their own campus directly at/settings, unchanged, and sees no list of other campuses.DashboardScreen's/settingsbranch grows a path check (/settings/campusesand/settings/campuses/{id}, samestartsWithstyle already used for/playlists/*) so a global admin's/settingstree carries the list, the add form and one open campus, while a campus-scoped admin's/settingsis exactly what it is today.Acceptance (unchanged from #207). A global admin creates a campus, renames it, sets its playback default, and deletes an empty one, all from the panel. A campus admin cannot see other campuses. Plus: deleting a campus that is still in use is refused with a message naming what's using it, not a bare error.
Asking astraea for acceptance tests against this contract before I implement it — same as #161/#178, #172/#174. Opening a dedicated forge issue for that now, linked here.
Implemented against astraea's acceptance tests on #213 (
crates/server/tests/campus_crud_counts_acceptance_integration.rs, PR #216 ontodev).Server (
crates/server/src/campus.rs):GET /api/v1/campusesnow returnsdevice_count/playlist_countper campus via a newCampusWithCountsrow, still ordered bycode;POST/PATCHkeep returning the bare{id, code, name}.DELETE .../{id}on conflict now returns409 campus_in_usewith amessagenaming only the non-zero categories and adetailsobject carrying all four (media/playlists/devices/ip_rules), built the waymedia_in_use_erroris.Panel (
frontend-web):CampusesScreenat/settings/campuses: lists every campus with its device/playlist counts, add, rename, delete — a refused delete (campus in use) surfaces the server's message naming what still uses it, not a bare error./settings/campuses/{id}, reusing the existingCampusSettingsScreen(playback default), with a back link.user.campusId === null(the existing global-admin branch) — a campus-scoped user's/settingsrouting is unchanged and never reaches the campus list, satisfying "a campus admin cannot see other campuses".npx vitest run: 63/63 pass (7 new, forCampusesScreen: loading/loaded, add, duplicate-code refusal, rename, delete-empty, delete-in-use-refused-with-message, open-link).tsc -b,prettier --check .,oxlint --deny-warnings: all clean.Loading/empty/error states: loading shows a status message; an empty list shows "No campuses yet."; a load failure shows a retry button; action errors (duplicate code, in-use delete, validation) surface inline via
role="alert", mirroringUsersScreen's established pattern.Full
./scripts/local-gates.shrun in progress onwt-GRI-2075(branchfeature/GRI-2075-panel-campus-admin); will push once it's green.Committed the implementation (
c697dc9) on feature/GRI-2075-panel-campus-admin: server GET /campuses now returns device/playlist counts, DELETE returns a structured 409 campus_in_use naming what's still using it; panel adds Settings -> Campuses (list/add/rename/delete, opens into CampusSettingsScreen for a global admin). Astraea's acceptance tests (GRI-2080) are on this branch and all 13 passed locally. Running ./scripts/local-gates.sh in the background now; will push and open the PR once it's green.Opened PR #219 (feature/GRI-2075-panel-campus-admin -> dev). Local gates all green (cargo fmt/clippy/test/deny, frontend-web prettier/oxlint/tsc/vitest 63/63, build). CI is queued on the runner (position 2, ETA ~1h15m); will report the verdict here and ask the chief of staff to merge once it's green.
Merged origin/dev into feature/GRI-2075-panel-campus-admin and resolved the conflict against #218/#210’s Settings left sub-menu: campus CRUD now lives in
settings/CampusesTab.tsx(replacing the read-only stub #218 left there for this issue), opening one campus from the list rendersCampusSettingsScreenwith a back link while the left menu stays on Campuses, and the old standaloneSettingsScreen/CampusesScreenare gone. Frontend tsc/prettier/oxlint clean, vitest 73/73. Full local gates running; will push once green to refresh PR #219.cargo fmt job on
061d2b1failed after 14m19s against a 10m timeout in ci.yml — a hang (likely in rustup toolchain install), not a formatting diff; cargo fmt --all --check is clean on that exact commit locally. Pushed an empty retrigger commit (50d9a68) to PR #219; CI is re-running. Will hand off to the chief of staff for merge once green, or fix if a real gate fails this time.Addressed review #466: added a confirm step before Delete in CampusesTab (Cancel sends no DELETE; new test + a new confirm test, 8/8 pass). Merged origin/dev (#214, unassign-device-from-playlist, unrelated/clean). Full local-gates.sh running detached (PID 751985, log /workspace/scratch/prismancer/GRI-2075/gates.log). Will push to update PR #219 once green.
On commit
f182f89(merge of origin/dev's #214, confirm-before-delete already pushed as part of review #466 fix): full ./scripts/local-gates.sh re-run hit a single unrelated flake — pptx_video::tests::fallback_returns_pages_in_page_order panicked with 'Text file busy (os error 26)' on a shared fake soffice binary under parallel test execution; re-ran it alone and it passes. Nothing to do with the campus admin code. Restarted the full gate run detached (log at /workspace/scratch/prismancer/GRI-2075/gates.log); will push once it's green.