GRI-2111: panel Campus selector for moving media between campuses (#242) #254

Merged
vivy merged 7 commits from feature/GRI-2111-media-campus-selector into dev 2026-11-16 00:49:24 +00:00
Member

Summary

Panel half of #242: a global admin can move a media item (or a whole document, all pages at once) between campuses from the media library, using the PATCH /api/v1/media/{id} contract pinned on #244.

  • A Campus selector appears on each top-level media row (image, URL, video, document), visible only when user.campusId === null (global admin) — the same convention NewPlaylistDialog already uses.
  • Selecting a campus calls the new moveMediaCampus(mediaId, campusId). A document's selector moves every page with it (noted next to the selector).
  • A 409 media_in_use_by_other_campus response shows the playlists that would lose the item and asks to confirm removing it from them and moving, mirroring the existing media_in_use/delete conflict flow (GRI-1962).
  • MediaItem.campusId and the wire's campus_id were added — the server already returns this field (crates/server/src/media/handlers.rs), the frontend type just hadn't picked it up yet.

Backend route: #244 (aetherforge). Acceptance tests for the backend/server contract: #245 (test/GRI-2115, already in dev). This PR's own tests are the frontend's: a global admin sees the selector and a campus admin does not, a move succeeds, a document move notes every page moves, the 409 conflict names the playlists and offers remove-and-move, cancelling leaves the item alone, and a generic error falls back to a generic message.

Merge waits for #244 to land, per the chief of staff's routing on GRI-72 (board comment, GRI-2111).

Test plan

  • npm run check in frontend-web (prettier, oxlint, tsc, vitest) — all green.
  • npm run build in frontend-web — builds.
  • Full scripts/local-gates.sh --frontend-only run locally — every gate passed.
  • Manually reasoned through loading/empty/error states: unaffected by this change (existing states untouched); the selector itself has no separate loading/error state since listCampuses() fills in once latency resolves and the "All campuses" option is always present first.
  • Light/dark theme and responsive layout: no new design tokens or literals introduced — selector uses the existing gx-input/gx-field classes shared with every other form control on this screen.
  • Keyboard/focus: the selector is a native <select> with its own <label>, keyed per item by its own id (not a shared label), so it is independently reachable and announced; the conflict dialog reuses the existing alertdialog/alert pattern with visible focusable buttons.
## Summary Panel half of #242: a global admin can move a media item (or a whole document, all pages at once) between campuses from the media library, using the `PATCH /api/v1/media/{id}` contract pinned on #244. - A **Campus** selector appears on each top-level media row (image, URL, video, document), visible only when `user.campusId === null` (global admin) — the same convention `NewPlaylistDialog` already uses. - Selecting a campus calls the new `moveMediaCampus(mediaId, campusId)`. A document's selector moves every page with it (noted next to the selector). - A `409 media_in_use_by_other_campus` response shows the playlists that would lose the item and asks to confirm removing it from them and moving, mirroring the existing `media_in_use`/delete conflict flow (GRI-1962). - `MediaItem.campusId` and the wire's `campus_id` were added — the server already returns this field (`crates/server/src/media/handlers.rs`), the frontend type just hadn't picked it up yet. Backend route: #244 (aetherforge). Acceptance tests for the backend/server contract: #245 (test/GRI-2115, already in `dev`). This PR's own tests are the frontend's: a global admin sees the selector and a campus admin does not, a move succeeds, a document move notes every page moves, the 409 conflict names the playlists and offers remove-and-move, cancelling leaves the item alone, and a generic error falls back to a generic message. Merge waits for #244 to land, per the chief of staff's routing on GRI-72 (board comment, GRI-2111). ## Test plan - [x] `npm run check` in `frontend-web` (prettier, oxlint, tsc, vitest) — all green. - [x] `npm run build` in `frontend-web` — builds. - [x] Full `scripts/local-gates.sh --frontend-only` run locally — every gate passed. - [x] Manually reasoned through loading/empty/error states: unaffected by this change (existing states untouched); the selector itself has no separate loading/error state since `listCampuses()` fills in once latency resolves and the "All campuses" option is always present first. - [x] Light/dark theme and responsive layout: no new design tokens or literals introduced — selector uses the existing `gx-input`/`gx-field` classes shared with every other form control on this screen. - [x] Keyboard/focus: the selector is a native `<select>` with its own `<label>`, keyed per item by its own id (not a shared label), so it is independently reachable and announced; the conflict dialog reuses the existing `alertdialog`/`alert` pattern with visible focusable buttons.
GRI-2111: fix formatting (prettier)
All checks were successful
CI / the pre-push hook (pull_request) Successful in 3s
CI / cargo fmt (pull_request) Successful in 6s
CI / install.sh client upgrade (pull_request) Successful in 10s
CI / cargo deny (pull_request) Successful in 24s
CI / cargo deny advisories (pull_request) Successful in 32s
CI / repository boundary (pull_request) Successful in 6s
CI / cargo clippy (pull_request) Successful in 1m46s
CI / frontend-web (pull_request) Successful in 1m30s
CI / cargo test (pull_request) Successful in 4m54s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 2s
b5bb361b37
Author
Member

Panel built against the contract in #244 (not waiting for it to land, per the chief of staff's GRI-72 routing tonight). Frontend-only change: Campus selector on each media item, visible to a global admin only, with the 409 conflict/remove-and-move flow mirroring the existing delete conflict. Own acceptance tests added in a separate commit before the implementation commit. npm run check + npm run build + full scripts/local-gates.sh --frontend-only all green locally; forge CI running now. Merge waits for #244.

Panel built against the contract in #244 (not waiting for it to land, per the chief of staff's GRI-72 routing tonight). Frontend-only change: Campus selector on each media item, visible to a global admin only, with the 409 conflict/remove-and-move flow mirroring the existing delete conflict. Own acceptance tests added in a separate commit before the implementation commit. `npm run check` + `npm run build` + full `scripts/local-gates.sh --frontend-only` all green locally; forge CI running now. Merge waits for #244.
vivy requested changes 2026-11-15 21:25:19 +00:00
Dismissed
vivy left a comment

Close, two fixes:

  1. canMoveCampus = user.campusId === null does not match the server. PATCH /media/{id} (#253) checks current.is_admin. A non-admin user can have campusId null (EditUserForm sends null when the campus field is empty), so that user sees the selector and every move fails with 403 and 'Could not move that item'. Use user.isAdmin, which SessionUser already has. Please add a test: non-admin with campusId null sees no selector.
  2. listCampuses().then(setCampuses) has no catch. A failed request is an unhandled rejection and the selector shows only 'All campuses' with no message. Show an error, as refresh() does.

This merges after #253 (the server endpoint), not before.

Close, two fixes: 1. canMoveCampus = user.campusId === null does not match the server. PATCH /media/{id} (#253) checks current.is_admin. A non-admin user can have campusId null (EditUserForm sends null when the campus field is empty), so that user sees the selector and every move fails with 403 and 'Could not move that item'. Use user.isAdmin, which SessionUser already has. Please add a test: non-admin with campusId null sees no selector. 2. listCampuses().then(setCampuses) has no catch. A failed request is an unhandled rejection and the selector shows only 'All campuses' with no message. Show an error, as refresh() does. This merges after #253 (the server endpoint), not before.
GRI-2111: gate campus move on isAdmin, not a null campusId; surface campus-list load errors
All checks were successful
CI / the pre-push hook (pull_request) Successful in 4s
CI / cargo fmt (pull_request) Successful in 6s
CI / install.sh client upgrade (pull_request) Successful in 12s
CI / cargo deny (pull_request) Successful in 24s
CI / cargo deny advisories (pull_request) Successful in 26s
CI / cargo clippy (pull_request) Successful in 2m16s
CI / repository boundary (pull_request) Successful in 7s
CI / frontend-web (pull_request) Successful in 1m36s
CI / cargo test (pull_request) Successful in 5m24s
CI / CI (pull_request) Successful in 3s
CI / Notify gate failed (pull_request) Has been skipped
6fcf85c7f9
Author
Member

Addressed both review points (commit 6fcf85c):

  1. canMoveCampus now reads user.isAdmin instead of user.campusId === null — a non-admin with no campus assigned no longer sees the selector. Added a test (hides the Campus selector from a non-admin even when their campusId is null).
  2. listCampuses().then(setCampuses) now has a .catch that sets the load error state, same message pattern as refresh(). Added a test covering the failure path.

npm run check (127 tests) and npm run build green; full scripts/local-gates.sh --frontend-only green. CI running on the pull request.

Addressed both review points (commit 6fcf85c): 1. `canMoveCampus` now reads `user.isAdmin` instead of `user.campusId === null` — a non-admin with no campus assigned no longer sees the selector. Added a test (`hides the Campus selector from a non-admin even when their campusId is null`). 2. `listCampuses().then(setCampuses)` now has a `.catch` that sets the load error state, same message pattern as `refresh()`. Added a test covering the failure path. `npm run check` (127 tests) and `npm run build` green; full `scripts/local-gates.sh --frontend-only` green. CI running on the pull request.
vivy approved these changes 2026-11-15 22:39:36 +00:00
Dismissed
vivy left a comment

Re-reviewed 6fcf85c7. canMoveCampus now uses user.isAdmin, the same check the server makes, and a failed campus list now shows an error instead of failing silently. The panel sends campus_id: null explicitly, which matches the new required field in #253. CI is green.

One small thing, not a blocker: a failed campus list replaces the whole Media screen with the error, so an admin cannot see their media until the reload works. A notice next to the Campus selector would hurt less. Fix it in a follow-up if you agree.

Approved. Merges after #253.

Re-reviewed 6fcf85c7. `canMoveCampus` now uses `user.isAdmin`, the same check the server makes, and a failed campus list now shows an error instead of failing silently. The panel sends `campus_id: null` explicitly, which matches the new required field in #253. CI is green. One small thing, not a blocker: a failed campus list replaces the whole Media screen with the error, so an admin cannot see their media until the reload works. A notice next to the Campus selector would hurt less. Fix it in a follow-up if you agree. Approved. Merges after #253.
Merge branch 'dev' into feature/GRI-2111-media-campus-selector
Some checks failed
CI / the pre-push hook (pull_request) Successful in 5s
CI / install.sh client upgrade (pull_request) Successful in 11s
CI / cargo fmt (pull_request) Successful in 5s
CI / cargo deny (pull_request) Successful in 20s
CI / cargo deny advisories (pull_request) Successful in 21s
CI / cargo clippy (pull_request) Successful in 1m26s
CI / repository boundary (pull_request) Successful in 4s
CI / frontend-web (pull_request) Failing after 33s
CI / cargo test (pull_request) Successful in 2m58s
CI / CI (pull_request) Failing after 2s
CI / Notify gate failed (pull_request) Successful in 2s
21e59a5c7e
vivy dismissed vivy's review 2026-11-15 23:59:26 +00:00
Reason:

New commits pushed, approval review dismissed automatically according to repository settings

GRI-2111: fix GRI-2121 upload tests broken by making MediaScreen's user prop required
All checks were successful
CI / the pre-push hook (pull_request) Successful in 4s
CI / cargo fmt (pull_request) Successful in 5s
CI / install.sh client upgrade (pull_request) Successful in 8s
CI / cargo deny (pull_request) Successful in 15s
CI / cargo deny advisories (pull_request) Successful in 19s
CI / repository boundary (pull_request) Successful in 5s
CI / cargo clippy (pull_request) Successful in 1m16s
CI / frontend-web (pull_request) Successful in 1m8s
CI / cargo test (pull_request) Successful in 3m18s
CI / CI (pull_request) Successful in 2s
CI / Notify gate failed (pull_request) Has been skipped
8034696c3d
Merge branch 'dev' into feature/GRI-2111-media-campus-selector
All checks were successful
CI / the pre-push hook (pull_request) Successful in 6s
CI / install.sh client upgrade (pull_request) Successful in 11s
CI / cargo fmt (pull_request) Successful in 6s
CI / cargo clippy (pull_request) Successful in 1m52s
CI / cargo deny (pull_request) Successful in 20s
CI / cargo deny advisories (pull_request) Successful in 19s
CI / repository boundary (pull_request) Successful in 7s
CI / frontend-web (pull_request) Successful in 1m26s
CI / cargo test (pull_request) Successful in 5m10s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 1s
8dbe66f9b2
vivy merged commit 2e59f39067 into dev 2026-11-16 00:49:24 +00:00
vivy deleted branch feature/GRI-2111-media-campus-selector 2026-11-16 00:49:24 +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!254
No description provided.