GRI-2074: playlist add-from-library in two steps (file, then pages) with a page range #222

Merged
vivy merged 2 commits from feature/GRI-2074-playlist-add-from-library-pages into dev 2026-11-15 16:28:18 +00:00
Member

Summary

Implemented the two-step picker in frontend-web: AddFromLibraryDialog (pick a file — searchable, filtered by type Image/Video/PDF/PowerPoint/Web page, with a thumbnail — then, only for a multi-page file, pick pages), backed by a pure parsePageRange/formatPageRange in src/pageRange.ts (unit-tested for every case in the issue: 1-5,8-9, */empty, 10-, spaces ignored, 0, 7-3, beyond the end, letters). Pages are still added one PlaylistItem per page in document order, so the existing per-page duration field and the cogwheel page-overrides on an already-added document item are unaffected.

One scope note: the server never tags a row literally pptx (crates/server/src/media/handlers.rs's classify) — a PowerPoint upload becomes document (slide-image fallback) or video (converted), same as PDF/video. So the "PDF" vs "PowerPoint" filter is a frontend-only heuristic on the filename extension, not an API field. Flagging this in case the type filter matters enough to want a real field later; not blocking.

Test plan

  • frontend-web: prettier, oxlint --deny-warnings, tsc -b, vitest all green (94/94, including new pageRange.test.ts and AddFromLibraryDialog.test.tsx, plus two PlaylistsScreen.test.tsx cases updated for the new two-step flow)
  • ./scripts/local-gates.sh (full suite, including cargo workspace and cargo-deny) green
## Summary Implemented the two-step picker in `frontend-web`: `AddFromLibraryDialog` (pick a file — searchable, filtered by type Image/Video/PDF/PowerPoint/Web page, with a thumbnail — then, only for a multi-page file, pick pages), backed by a pure `parsePageRange`/`formatPageRange` in `src/pageRange.ts` (unit-tested for every case in the issue: `1-5,8-9`, `*`/empty, `10-`, spaces ignored, `0`, `7-3`, beyond the end, letters). Pages are still added one `PlaylistItem` per page in document order, so the existing per-page duration field and the cogwheel page-overrides on an already-added `document` item are unaffected. One scope note: the server never tags a row literally `pptx` (`crates/server/src/media/handlers.rs`'s `classify`) — a PowerPoint upload becomes `document` (slide-image fallback) or `video` (converted), same as PDF/video. So the "PDF" vs "PowerPoint" filter is a frontend-only heuristic on the filename extension, not an API field. Flagging this in case the type filter matters enough to want a real field later; not blocking. ## Test plan - [x] `frontend-web`: prettier, `oxlint --deny-warnings`, `tsc -b`, vitest all green (94/94, including new `pageRange.test.ts` and `AddFromLibraryDialog.test.tsx`, plus two `PlaylistsScreen.test.tsx` cases updated for the new two-step flow) - [x] `./scripts/local-gates.sh` (full suite, including `cargo` workspace and `cargo-deny`) green
GRI-2074: split add-from-library into pick-file then pick-pages, with a page range
All checks were successful
CI / the pre-push hook (pull_request) Successful in 3s
CI / cargo fmt (pull_request) Successful in 4s
CI / install.sh client upgrade (pull_request) Successful in 7s
CI / cargo deny advisories (pull_request) Successful in 22s
CI / cargo deny (pull_request) Successful in 24s
CI / repository boundary (pull_request) Successful in 5s
CI / cargo clippy (pull_request) Successful in 1m22s
CI / frontend-web (pull_request) Successful in 1m4s
CI / cargo test (pull_request) Successful in 2m22s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 2s
b8f4b14c55
vivy requested changes 2026-11-15 16:16:34 +00:00
Dismissed
vivy left a comment

Changes requested — one regression, three small items. CI is green and the branch is up to date with dev; the parser and the two-step flow are good.

1. Blocking: a document can no longer be added whole.
Before this PR the picker offered handbook.pdf (all pages) — one document item. That is the only kind of item that has the cogwheel (PlaylistMediaTab.tsx:129, isDocument) and so the only way to reach per-page time and Skip this page (PageOverridesPanel). Now every multi-page file goes to the page step and always adds N document_page items, so a new playlist can never get a cogwheel item. The cogwheel test still passes only because it seeds the item through sessionStorage; the assertion that the "all pages" option exists was deleted from PlaylistsScreen.test.tsx.
Part of this is my fault: the #208 text says "one item per page … so Skip this page keeps working", and those two do not go together.
Fix: in the page step, add a button Add whole document (one document item, page settings via the cogwheel) next to Add N pages. Keep a test that adds the whole document from the picker and then opens its cogwheel.

2. Add is enabled while the range is invalid. With an error shown (e.g. 7-3) the selection keeps the last valid range and Add N pages still adds it. Disable the button while rangeError is set.

3. Page step loads every page at full size. 50 <img src=/api/v1/media/{id}/file> at once for one file. Add loading="lazy" (and the same on the file-step thumbnails).

4. Minor: parsePageRange(text, file.pages.length) assumes pages are numbered 1..N without gaps, while the selection is keyed by pageNumber. Fine today; a one-line comment saying so is enough.

The PDF/PowerPoint filter by file extension is fine for now.

Changes requested — one regression, three small items. CI is green and the branch is up to date with `dev`; the parser and the two-step flow are good. **1. Blocking: a document can no longer be added whole.** Before this PR the picker offered `handbook.pdf (all pages)` — one `document` item. That is the only kind of item that has the cogwheel (`PlaylistMediaTab.tsx:129`, `isDocument`) and so the only way to reach per-page time and **Skip this page** (`PageOverridesPanel`). Now every multi-page file goes to the page step and always adds N `document_page` items, so a new playlist can never get a cogwheel item. The cogwheel test still passes only because it seeds the item through `sessionStorage`; the assertion that the "all pages" option exists was deleted from `PlaylistsScreen.test.tsx`. Part of this is my fault: the #208 text says "one item per page … so Skip this page keeps working", and those two do not go together. Fix: in the page step, add a button **Add whole document** (one `document` item, page settings via the cogwheel) next to **Add N pages**. Keep a test that adds the whole document from the picker and then opens its cogwheel. **2. Add is enabled while the range is invalid.** With an error shown (e.g. `7-3`) the selection keeps the last valid range and **Add N pages** still adds it. Disable the button while `rangeError` is set. **3. Page step loads every page at full size.** 50 `<img src=/api/v1/media/{id}/file>` at once for one file. Add `loading="lazy"` (and the same on the file-step thumbnails). **4. Minor:** `parsePageRange(text, file.pages.length)` assumes pages are numbered 1..N without gaps, while the selection is keyed by `pageNumber`. Fine today; a one-line comment saying so is enough. The PDF/PowerPoint filter by file extension is fine for now.
GRI-2074: add whole-document option, lazy page images, disable Add on invalid range
All checks were successful
CI / the pre-push hook (pull_request) Successful in 4s
CI / cargo fmt (pull_request) Successful in 3s
CI / install.sh client upgrade (pull_request) Successful in 6s
CI / cargo deny (pull_request) Successful in 19s
CI / cargo deny advisories (pull_request) Successful in 21s
CI / repository boundary (pull_request) Successful in 7s
CI / cargo clippy (pull_request) Successful in 1m28s
CI / frontend-web (pull_request) Successful in 1m11s
CI / cargo test (pull_request) Successful in 2m50s
CI / Notify gate failed (pull_request) Has been skipped
CI / CI (pull_request) Successful in 1s
78a4e8ffa9
Review feedback on PR #222: the two-step picker could no longer add a
multi-page document as itself, so new items never got the page-overrides
cogwheel or Skip this page. Add an explicit 'Add whole document' button
in the pages step. Also disable Add while the typed range is invalid,
and lazy-load page thumbnail images.
vivy approved these changes 2026-11-15 16:28:15 +00:00
vivy left a comment

All three points fixed at 78a4e8f: Add whole document adds the single document item (cogwheel path kept), Add disabled on an invalid range, page images lazy. Tests cover the first two. CI green, up to date with dev.

All three points fixed at 78a4e8f: Add whole document adds the single document item (cogwheel path kept), Add disabled on an invalid range, page images lazy. Tests cover the first two. CI green, up to date with dev.
vivy merged commit 8ed0ea17fb into dev 2026-11-15 16:28:18 +00:00
vivy deleted branch feature/GRI-2074-playlist-add-from-library-pages 2026-11-15 16:28:18 +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!222
No description provided.