GRI-2212: allow setting a device back to All campuses #328

Merged
vivy merged 3 commits from fix/GRI-2212-device-clear-campus into dev 2026-11-18 13:38:37 +00:00
Member

Summary

Forge #323: a device that already has a campus could not be set back to All campuses — the server treated an absent campus_id and null as the same thing ("leave it unchanged"), and the panel's campus select disabled the empty option.

  • Server: UpdateDeviceRequest.campus_id is now three-state (absent = unchanged, null = clear, uuid = that campus), via Option<Option<Uuid>>. Clearing is refused with 403 unless the caller may access every campus (global admin). Clearing never runs the playlist-mismatch check (#310) — a device with no campus fits any playlist.
  • Panel: the device campus select offers an All campuses option (same wording as the media campus picker, #242) to global admins only; choosing it sends campus_id: null.
  • plan/server/rest-api.md updated for the PATCH /devices/{id} contract.

Test plan

  • cargo test -p server --test devices_integration -- --include-ignored — 29/29 passed, including the new cases: absent field leaves campus unchanged, global admin clears to null, a device on a campus playlist can still be cleared, a campus editor gets 403 clearing.
  • cargo fmt --check, cargo clippy -p server --tests clean.
  • npx tsc --noEmit, npm run lint clean.
  • npx vitest run src/screens/DevicesScreen.test.tsx — 30/30 passed, including: global admin sees All campuses and choosing it calls the API with null; a campus admin does not see it.
## Summary Forge #323: a device that already has a campus could not be set back to *All campuses* — the server treated an absent `campus_id` and `null` as the same thing ("leave it unchanged"), and the panel's campus select disabled the empty option. - Server: `UpdateDeviceRequest.campus_id` is now three-state (absent = unchanged, `null` = clear, uuid = that campus), via `Option<Option<Uuid>>`. Clearing is refused with 403 unless the caller may access every campus (global admin). Clearing never runs the playlist-mismatch check (#310) — a device with no campus fits any playlist. - Panel: the device campus select offers an *All campuses* option (same wording as the media campus picker, #242) to global admins only; choosing it sends `campus_id: null`. - `plan/server/rest-api.md` updated for the `PATCH /devices/{id}` contract. ## Test plan - [x] `cargo test -p server --test devices_integration -- --include-ignored` — 29/29 passed, including the new cases: absent field leaves campus unchanged, global admin clears to null, a device on a campus playlist can still be cleared, a campus editor gets 403 clearing. - [x] `cargo fmt --check`, `cargo clippy -p server --tests` clean. - [x] `npx tsc --noEmit`, `npm run lint` clean. - [x] `npx vitest run src/screens/DevicesScreen.test.tsx` — 30/30 passed, including: global admin sees *All campuses* and choosing it calls the API with `null`; a campus admin does not see it.
campus_id becomes three-state (absent/null/uuid) on PATCH /devices/{id}.
Clearing requires global-admin access and skips the playlist-mismatch
check, since a device with no campus fits any playlist. Panel offers
an All campuses option to global admins only.
The new campus-editor 403 test logs in via POST /session, which needs
the LoginThrottle extension the real router layers in. Missing it made
login 500 rather than exercise the test.
GRI-2212: merge dev
All checks were successful
CI / the pre-push hook (pull_request) Successful in 5s
CI / install.sh client upgrade (pull_request) Successful in 13s
CI / cargo fmt (pull_request) Successful in 4s
CI / cargo clippy (pull_request) Successful in 1m12s
CI / cargo deny (pull_request) Successful in 15s
CI / cargo deny advisories (pull_request) Successful in 21s
CI / frontend-web (pull_request) Successful in 1m14s
CI / repository boundary (pull_request) Successful in 3s
CI / cargo test (pull_request) Successful in 3m54s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 1s
7a27cf3fe4
vivy merged commit 20007bc17c into dev 2026-11-18 13:38:37 +00:00
vivy deleted branch fix/GRI-2212-device-clear-campus 2026-11-18 13:38:39 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Grimoirix/grimoire-of-digital-signage!328
No description provided.