Devices: allow setting a device back to All campuses #323

Closed
opened 2026-11-18 09:53:38 +00:00 by vivy · 2 comments
Owner

Product owner, panel test on 10.4.80.205 (dev 56dd99c), 2026-11-18 — screenshot on GRI-2051.

What he sees: on the Devices screen, a device that already has a campus cannot be set back to All campuses (no campus). The campus list offers only real campuses; "Choose a campus" is disabled. Media items can be set to All campuses (#242), devices cannot.

Cause — server and panel both:

  • PATCH /devices/{id} (crates/server/src/devices/handlers.rs) reads campus_id as Option<Uuid>, so an absent field and null are the same thing: "leave the campus as it is". There is no way to say "clear it".
  • DevicesScreen.tsx:357-371: the select's empty option is disabled, and onChange ignores an empty value. assignDeviceCampus in httpDevicesApi.ts always sends a campus id.

Wanted:

  • Server: campus_id becomes three-state: absent = unchanged, null = no campus, a uuid = that campus (serde Option<Option<Uuid>> with deserialize_with/double_option, or an explicit field).
  • Who may clear it: only a user who may access every campus (global admin). A campus admin who clears it would move the device out of their own campus; refuse that with 403 and a clear message.
  • Playlist check (#310): clearing never conflicts. A device with no campus may show any playlist (#310 table, row 1), so no mismatch check is needed for null.
  • Panel: the campus select gets an All campuses option (same wording as the media campus picker, #242), shown to global admins only. Choosing it sends campus_id: null.

Done when:

  • Server integration test: PATCH with campus_id: null clears it; absent field leaves it; campus admin gets 403 on null; a device on a campus playlist can still be cleared.
  • Vitest: global admin sees All campuses and choosing it calls the API with null; a campus admin does not see it.
Product owner, panel test on 10.4.80.205 (dev `56dd99c`), 2026-11-18 — screenshot on GRI-2051. **What he sees:** on the Devices screen, a device that already has a campus cannot be set back to **All campuses** (no campus). The campus list offers only real campuses; "Choose a campus" is disabled. Media items can be set to *All campuses* (#242), devices cannot. **Cause — server and panel both:** - `PATCH /devices/{id}` (`crates/server/src/devices/handlers.rs`) reads `campus_id` as `Option<Uuid>`, so an absent field and `null` are the same thing: "leave the campus as it is". There is no way to say "clear it". - `DevicesScreen.tsx:357-371`: the select's empty option is `disabled`, and `onChange` ignores an empty value. `assignDeviceCampus` in `httpDevicesApi.ts` always sends a campus id. **Wanted:** - **Server:** `campus_id` becomes three-state: absent = unchanged, `null` = no campus, a uuid = that campus (serde `Option<Option<Uuid>>` with `deserialize_with`/`double_option`, or an explicit field). - **Who may clear it:** only a user who may access every campus (global admin). A campus admin who clears it would move the device out of their own campus; refuse that with 403 and a clear message. - **Playlist check (#310):** clearing never conflicts. A device with no campus may show any playlist (#310 table, row 1), so no mismatch check is needed for `null`. - **Panel:** the campus select gets an **All campuses** option (same wording as the media campus picker, #242), shown to global admins only. Choosing it sends `campus_id: null`. **Done when:** - Server integration test: PATCH with `campus_id: null` clears it; absent field leaves it; campus admin gets 403 on `null`; a device on a campus playlist can still be cleared. - Vitest: global admin sees *All campuses* and choosing it calls the API with `null`; a campus admin does not see it.
Author
Owner

Merged in #328 (server: campus_id: null clears, 403 for a campus-bound caller; panel: All campuses option). CI 7/7 required green, up to date with dev.

Follow-up nit, not blocking: the panel offers All campuses when user.isAdmin, but the server refuses when the caller has a campus. An admin-group user bound to a campus sees the option and gets a 403. Should be user.isAdmin && user.campusId === null.

Merged in #328 (server: `campus_id: null` clears, 403 for a campus-bound caller; panel: *All campuses* option). CI 7/7 required green, up to date with dev. Follow-up nit, not blocking: the panel offers *All campuses* when `user.isAdmin`, but the server refuses when the caller has a campus. An admin-group user bound to a campus sees the option and gets a 403. Should be `user.isAdmin && user.campusId === null`.
vivy closed this issue 2026-11-18 13:59:22 +00:00
Author
Owner

Done: #328 (server + panel) and #329 (option hidden for campus-bound admins) are in dev bf59402. Deploy to 10.4.80.205 follows when dev CI is green.

Done: #328 (server + panel) and #329 (option hidden for campus-bound admins) are in dev bf59402. Deploy to 10.4.80.205 follows when dev CI is green.
Sign in to join this conversation.
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#323
No description provided.