Repository navigation
Draft and published scenes (#458, #459) - #512
Subomiadekunle wants to merge 5 commits into
Conversation
fetchBoneDataResult() returns ok, missing (404), or error (network/5xx). The viewer shows 'no images yet' only for missing content; failures show an error with a Try again button. Added regression tests and updated the dropdowns test mock.
…ss-slu#459) New scenes and duplicates start as drafts. PATCH /api/scenes/:id/status publishes or unpublishes without changing content, and GET /api/scenes?status=published lists published scenes for the bone viewer. The editor shows a Draft/Published badge, a visibility note, and a Publish/Unpublish button that requires saving first. Part of oss-slu#457.
mudabs
left a comment
There was a problem hiding this comment.
Request changes
Thank you Subomi for the substantial work on this feature. The draft/published lifecycle is clearly represented in the API and editor, the viewer correctly filters out drafts, publishing does not change scene content or updatedAt, and the tests cover the main publish/unpublish flows well.
I found one state-synchronization issue that should be fixed before approval.
[P2] Save-as-new recovery must adopt the replacement scene’s draft status
File:
- templates/js/scenes.js - saveAsNewScene(), around line 1032
When a scene is deleted externally and the user saves their working copy as a new scene, the API creates the replacement scene as a draft. However, saveAsNewScene() only copies the new id, name, createdAt, and updatedAt onto the existing working copy:
Object.assign(scene, {
id: created.id,
name: created.name,
createdAt: created.createdAt,
updatedAt: created.updatedAt
});
The existing scene.status and publishedAt values are left unchanged. If the deleted scene was published, the new server-side scene is correctly created as a draft, but the editor still displays it as Published and shows the Unpublish button. This leaves the UI inconsistent with the saved scene and can prevent the user from publishing the replacement normally.
Please update the working copy’s status metadata from the response without overwriting edits made while the save request was in flight. For example, copy created.status and either copy or remove publishedAt according to the response.
Please add a regression test in templates/tests/scenePublish.test.js that:
- Opens and publishes a scene.
- Makes an unsaved edit.
- Simulates the original scene being deleted before save.
- Saves the working copy as a new scene.
- Verifies that the new active scene and UI show Draft and that the available action is Publish.
There are also two cleanup items needed for the repository checks:
- Remove the trailing whitespace in templates/js/scenes.js around line 349.
- Remove the extra blank line at the end of templates/tests/viewerTransition.test.js.
The database/storage changes remain out of scope for this PR.
Thank you again for the thoughtful implementation and the strong test coverage.
Closes #458, closes #459 (part of #457)
What's new
draftorpublished. New scenes and duplicates start as drafts, and scenes saved before this change count as drafts, so nothing unfinished is shown as final content.API
PATCH /api/scenes/:id/statuswith{ "status": "draft" | "published" }changes only the status. Content and the save version (updatedAt) are untouched, per [Small Rock] Publish and Unpublish Scenes #459's note that publishing shouldn't change the scene.GET /api/scenes?status=published(ordraft) filters the list. Without it, the editor still sees every scene.Out of scope
Testing
boneset-api/sceneStatus.test.js: 14 API tests (defaults, filtering, publish/unpublish, content unchanged, saving after publish, duplicates, validation)templates/tests/scenePublish.test.js: 11 editor/viewer tests (badges, button states, save-before-publish, error + retry, viewer filter)viewerTransition.test.jsfor the published-only filternpm test: all suites pass;npm run lint: cleanManual check
Created a scene → Draft, and no link in the viewer → published → link appears → unpublished → link gone.