GRI-2106: let a global or campus admin assign a device to a campus #238

Merged
vivy merged 2 commits from feature/GRI-2106-device-campus-assignment into dev 2026-11-15 18:27:00 +00:00
Member

Closes #225

What changed

The Devices screen (approved devices list) now has a Campus control:

  • A global admin (user.campusId === null) sees a dropdown of every campus.
  • A campus admin sees a dropdown with only their own campus, matching the
    server's may_access scoping on PATCH /devices/{id} — they could never
    reach another campus's option even if it were offered.
  • A user without devices_manage sees the device's campus as read-only text
    instead of a control.

PATCH /devices/{id} requires name, so the client resends the device's
current name alongside the chosen campus_id.

Files

  • frontend-web/src/api/types.ts — Device.campusId
  • frontend-web/src/api/httpDevicesApi.ts — wire mapping, assignDeviceCampus
  • frontend-web/src/api/mockDevicesApi.ts — mock counterpart
  • frontend-web/src/api/devicesApi.ts — export the new function
  • frontend-web/src/screens/DevicesScreen.tsx — the control, campus list, permission/role gating
  • frontend-web/src/screens/DashboardScreen.tsx — pass user down to DevicesScreen
  • frontend-web/src/screens/DevicesScreen.test.tsx — tests for both roles and the read-only case

Test plan

  • scripts/local-gates.sh --frontend-only: prettier, oxlint, tsc -b, vitest run (99 passed), vite build — all green.
  • New tests: global admin sees all 4 campuses and can assign one; a campus
    admin sees only their own campus as an option; a user without
    devices_manage sees read-only campus text instead of a control.
  • Visual check: reused existing .gx-field/.gx-input/.gx-tag design-system
    classes already used elsewhere on this screen and on UsersScreen for the
    same campus-picker pattern — no new colours, sizes or CSS, so existing
    light/dark theming, focus rings and AA contrast carry over unchanged.
    The control sits in the same gx-card gx-list-item flex row as the
    existing Name/Host/Token/Playlist fields, so it wraps the same way at
    narrow widths.
Closes https://git.grimoirix.org/Grimoirix/grimoire-of-digital-signage/issues/225 ## What changed The Devices screen (approved devices list) now has a Campus control: - A global admin (`user.campusId === null`) sees a dropdown of every campus. - A campus admin sees a dropdown with only their own campus, matching the server's `may_access` scoping on `PATCH /devices/{id}` — they could never reach another campus's option even if it were offered. - A user without `devices_manage` sees the device's campus as read-only text instead of a control. `PATCH /devices/{id}` requires `name`, so the client resends the device's current name alongside the chosen `campus_id`. ## Files - `frontend-web/src/api/types.ts` — `Device.campusId` - `frontend-web/src/api/httpDevicesApi.ts` — wire mapping, `assignDeviceCampus` - `frontend-web/src/api/mockDevicesApi.ts` — mock counterpart - `frontend-web/src/api/devicesApi.ts` — export the new function - `frontend-web/src/screens/DevicesScreen.tsx` — the control, campus list, permission/role gating - `frontend-web/src/screens/DashboardScreen.tsx` — pass `user` down to `DevicesScreen` - `frontend-web/src/screens/DevicesScreen.test.tsx` — tests for both roles and the read-only case ## Test plan - `scripts/local-gates.sh --frontend-only`: prettier, oxlint, `tsc -b`, `vitest run` (99 passed), `vite build` — all green. - New tests: global admin sees all 4 campuses and can assign one; a campus admin sees only their own campus as an option; a user without `devices_manage` sees read-only campus text instead of a control. - Visual check: reused existing `.gx-field`/`.gx-input`/`.gx-tag` design-system classes already used elsewhere on this screen and on `UsersScreen` for the same campus-picker pattern — no new colours, sizes or CSS, so existing light/dark theming, focus rings and AA contrast carry over unchanged. The control sits in the same `gx-card gx-list-item` flex row as the existing Name/Host/Token/Playlist fields, so it wraps the same way at narrow widths.
GRI-2106: let a global or campus admin assign a device to a campus
All checks were successful
CI / the pre-push hook (pull_request) Successful in 3s
CI / cargo fmt (pull_request) Successful in 3s
CI / install.sh client upgrade (pull_request) Successful in 7s
CI / cargo deny advisories (pull_request) Successful in 21s
CI / cargo deny (pull_request) Successful in 22s
CI / repository boundary (pull_request) Successful in 6s
CI / cargo clippy (pull_request) Successful in 1m24s
CI / frontend-web (pull_request) Successful in 1m6s
CI / cargo test (pull_request) Successful in 2m26s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 2s
ce03388d76
Merge branch 'dev' into feature/GRI-2106-device-campus-assignment
All checks were successful
CI / the pre-push hook (pull_request) Successful in 6s
CI / install.sh client upgrade (pull_request) Successful in 10s
CI / cargo fmt (pull_request) Successful in 7s
CI / cargo deny (pull_request) Successful in 21s
CI / cargo deny advisories (pull_request) Successful in 23s
CI / cargo clippy (pull_request) Successful in 1m30s
CI / repository boundary (pull_request) Successful in 4s
CI / frontend-web (pull_request) Successful in 1m5s
CI / cargo test (pull_request) Successful in 3m21s
CI / CI (pull_request) Successful in 2s
CI / Notify gate failed (pull_request) Has been skipped
e98e703c40
Owner

Review (Vivy, GRI-2110): approved. The server side is already in dev: PATCH /devices/{id} takes campus_id, checks may_access on the target campus, and GET /campuses is open to any signed-in user, so a campus admin can load the screen. Tests cover global admin, campus admin and read-only. Branch updated from dev (it was 2 behind after #235); merging when CI is green.

Known limit, not for this PR: a campus cannot be cleared back to "every campus" (server, forge #159).

Review (Vivy, GRI-2110): **approved.** The server side is already in `dev`: `PATCH /devices/{id}` takes `campus_id`, checks `may_access` on the target campus, and `GET /campuses` is open to any signed-in user, so a campus admin can load the screen. Tests cover global admin, campus admin and read-only. Branch updated from `dev` (it was 2 behind after #235); merging when CI is green. Known limit, not for this PR: a campus cannot be cleared back to "every campus" (server, forge #159).
vivy merged commit 30d507fd3e into dev 2026-11-15 18:27:00 +00:00
vivy deleted branch feature/GRI-2106-device-campus-assignment 2026-11-15 18:27:01 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
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!238
No description provided.