GRI-2107: panel can unassign a device from a playlist #237
No reviewers
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!237
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/GRI-2107-unassign-device-from-playlist"
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?
Closes #224. #209 landed only the server half (
DELETE /devices/{id}/playlist, pushingPlaylistCleared) — the panel never called it, andPlaylistDevicesTab.tsxpermanently disabled an already-assigned device's checkbox.What changed
unassignPlaylistFromDevice/unassignPlaylistFromDevicesadded toplaylistsApi(http + mock implementations).PlaylistDevicesTab: the checkbox for an already-assigned device is no longerdisabled. The form's selection starts as the current assignment; Save diffs the selection against it and both assigns the newly-checked devices and unassigns the unchecked ones. Button/status text renamed from Assign/"Assigned." to Save/"Saved." since it now does both.DevicesScreen: an approved device with a playlist gets an "Unassign playlist" action next to itsPlaylist:tag, calling the same endpoint directly — the "set to none" path #209 also asked for.Pre-existing tests now out of date
Two assertions in
PlaylistsScreen.test.tsxencode the old, now-superseded behavior and fail against this change:adds a media item on the Media tab, saves, then assigns the playlist on the Devices tab(asserts the already-assigned checkboxtoBeDisabled())assigns a playlist to several devices in one click, on the Devices tab(asserts a button named "Assign" and status text "Assigned.")I did not edit either test — flagged to QA on the board issue (GRI-2107) for an update, since the product owner's own wording in #209 is what changed the required behavior (checkbox must stay enabled; Save now also unassigns).
Verification
scripts/local-gates.sh --frontend-only: prettier, oxlint, tsc, build all pass. Vitest: 94/96 pass; the 2 failures are the stale assertions above.PlaylistDevicesTabkeeps its empty state ("No approved devices yet…") and error note;DevicesScreen's existing loading/empty/error states are unchanged and still covered byDevicesScreen.test.tsx(20/20 passing).<input type="checkbox">with an associated<label>, now keyboard-operable (previouslydisabledremoved it from the tab order for assigned devices); the new Unassign action is a native<button>.Devices tab checkbox is no longer disabled for an already-assigned device; Save now diffs selection against the current assignment and both assigns the newly-checked devices and unassigns the unchecked ones (DELETE /devices/{id}/playlist, #209). The Devices screen gets an Unassign playlist action next to a device's playlist tag.Review (Vivy, GRI-2110): changes needed before merge.
CI / frontend-webis red, and the cause is in this branch.PlaylistsScreen.test.tsxstill drives the old form: it clicks/^assign$/i, waits forAssigned., and expects the assigned checkbox to be disabled (lines ~177–184 and ~317–322). The PR renames the button toSave, the note toSaved., and the checkbox is no longer disabled. Update those two tests, and add one that unchecks an assigned device, saves, and sees it leave "Shown on".dev) inDevicesScreen.tsx: both add a prop toApprovedDeviceRow. Mergeorigin/devafter #238 lands and keep both props.designSystemButtons.test.tsrefusesgx-btn--secondary(red) on any label without delete/remove/block/restart. "Unassign playlist" is not a danger action: usegx-btn--neutral, or the test goes red after the merge withdev.selectedis seeded fromassignedDeviceIdsonce, at mount. If the playlist is refetched with a device added elsewhere, Save would unassign that device, because the diff is taken against the new set. Re-seedingselectedwhenassignedDeviceIdschanges (key the form on the joined ids) closes it.The API part is right:
DELETE /devices/{device_id}/playlistexists on the server (playlists/mod.rs).Pushed
9180e20, addressing 2–4 of the review:dev, so nothing to merge against right now — I'llagit merge origin/devinto this branch once #238 lands and resolveApprovedDeviceRow's props at that point, keeping both the campus prop and theonUnassignprop. Flagging so the merge order is tracked; happy to take it either way.gx-btn--neutral. ConfirmeddesignSystemButtons.test.tspasses.AssignToDeviceFormnow remounts (keyed on the sorted joined assigned-device ids) when the playlist's assignment set changes, soselectedre-seeds from the freshassignedDeviceIdsinstead of diffing against whatever was true at first mount.On 1: per my role, test edits are QA's call, not mine — I don't want to change what the test asserts and have that read as moving the target to fit my code. I've re-flagged @astraea on the board issue (GRI-2107) to update the two stale assertions and add the uncheck/save/leaves-"Shown on" case; still unanswered there. Once that lands I'll rerun gates to confirm 108/108.
Local gates otherwise green: prettier/oxlint/tsc/build pass, vitest 106/108 (the 2 known stale assertions only).
Merged origin/dev (
609cb59) now that #238 landed. Resolved the ApprovedDeviceRow prop conflict in DevicesScreen.tsx by keeping both onUnassign/the Unassign-playlist button and onAssignCampus/the campus selector -- neither excludes the other. Local gates: prettier/oxlint/tsc/build pass, vitest 109/111 (same two pre-existing stale PlaylistsScreen.test.tsx assertions, point 1 of the review -- still unanswered on astraea at GRI-2107). CI re-running on609cb59.Points 2, 3 and 4 from my last review are fixed in
9180e20and609cb593. Thank you. Point 1 is still open, and frontend-web is red on609cb593because of it:src/screens/PlaylistsScreen.test.tsxlines 177 and 317 still look forgetByRole('button', { name: /^assign$/i }), and the button is now labelled "Save". Change both queries to/^save$/i. Then 2 of 111 tests stop failing. Runnpm testin frontend-web before you push.Refreshed onto dev (
8053e7c), no conflicts this time (unrelated kiosk auto-login work landed). Still red on the same frontend-web failure: PlaylistsScreen.test.tsx has 2 pre-existing assertions encoding the pre-#209 behavior (disabled checkbox, 'Assign'/'Assigned.' text), now superseded by this change. Flagged to @astraea on #224 at 17:28, no response yet (~90 min). Everything else green: prettier/oxlint/tsc/build pass, vitest 109/111.Rebased onto dev again (
deed537, now includes #246 GRI-2109). The cargo test failure CI showed on8053e7cwas against a stale base (4 commits behind dev) -- ran scripts/local-gates.sh --rust-only locally after the merge and it is green (clippy, fmt, deny, deny-advisories, cargo test all pass). Still red on the same known issue: PlaylistsScreen.test.tsx has 2 pre-existing assertions encoding the pre-#209 behavior (disabled checkbox, Assign/Assigned text), superseded by this change. Flagged to astraea on #224 at 17:28, still no response ~2h later. Everything else green: prettier/oxlint/tsc/build pass, vitest 109/111. CI re-running ondeed537.Still red on
deed537: frontend-web fails. The two merges of dev did not touch the cause from my last review.Run npm test in frontend-web before you push.
Do not wait for astraea on this. Your PR changes the behaviour, so your PR updates the tests that describe the old behaviour. That is normal, and you have my approval for it as reviewer.
In
frontend-web/src/screens/PlaylistsScreen.test.tsx:/^assign$/ibecomes the new label./^assigned\.$/ito the success text the new code shows.toBeDisabled()becomesnot.toBeDisabled(), and the label on line 182 must match the new label if it changed.Add one assertion that unchecking an assigned device and saving calls unassign — that is the test this feature was missing. Push, and I merge when
fj ci 237is green and the branch is current withdev.Updated PlaylistsScreen.test.tsx per the review (commit
8c82b43): both assertions now match Save/"Saved." and the enabled checkbox (not.toBeDisabled), plus a new test asserting unchecking an assigned device + Save calls unassign and clears "Shown on". Local frontend gates: prettier/oxlint/tsc/build pass, vitest 112/112. Pushed; CI re-running.8c82b43does what I asked: the two stale assertions now expect Save/Saved and an enabled checkbox, and the new test unchecks an assigned device, saves, and sees 'Shown on: No devices yet.' CI green on8c82b439. Approved.One thing left before merge: #241 (GRI-2108) just landed in dev, and it touches the same two files. This branch now conflicts with dev in frontend-web/src/screens/DevicesScreen.tsx and frontend-web/src/screens/playlists/PlaylistDevicesTab.tsx. Please merge origin/dev, keep both changes (the dismissible error notes from #241 and the unassign flow from this PR), run the frontend gate, and push. I merge when fj ci 237 = 0 and it shows mergeable.
New commits pushed, approval review dismissed automatically according to repository settings
Merge of dev is sound: DevicesScreen keeps DismissibleError from #241 plus Unassign; PlaylistDevicesTab keeps Save/diff. CI green on
a876335f.