Breaking: Use content tree API for editor data loading (fixes #458)#459
Conversation
Replace full content fetch with lightweight tree endpoint. Editor now loads projected fields via GET /api/content/tree/:courseId and fetches full documents on demand when editing individual items. Staleness check uses If-Modified-Since conditional requests for zero-cost polling.
Origin.editor.data.content is a plain Backbone.Collection with no url property (created via native fetch in loadTree), so calling .fetch() on it throws, causing an errorfetchingdata popup on every menu delete despite the DELETE request succeeding. Instead of re-fetching, remove the deleted item and its descendants from the local collection directly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the editor’s data-loading strategy to use a lightweight content tree endpoint for initial load and conditional requests for staleness checks, while lazily fetching full documents only when a user opens an item for editing.
Changes:
- Replace the initial full content fetch with
GET /api/content/tree/:courseIdand store projected items inOrigin.editor.data.content. - Update staleness detection to use
If-Modified-Sinceconditional requests (304 when unchanged). - Ensure full models are fetched on-demand (
await model.fetch()) before building scaffold forms in individual editor routes.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| app/modules/editor/global/editorDataLoader.js | Implements tree loading + conditional staleness check; replaces previous full collection fetch logic. |
| app/modules/editor/article/index.js | Fetch full article document before building the edit form. |
| app/modules/editor/block/index.js | Fetch full block document before building the edit form. |
| app/modules/editor/component/index.js | Fetch full component document before building the edit form (existing items only). |
| app/modules/editor/contentObject/index.js | Fetch full page/menu document before building the edit form. |
| app/modules/editor/config/index.js | Fetch full config document before building the edit form. |
| app/modules/editor/course/index.js | Fetch full course document before building the settings form. |
| app/modules/editor/themeEditor/index.js | Fetch full course + config before opening the theme editor UI. |
| app/modules/editor/contentObject/views/editorMenuView.js | Updates client-side deletion handling to remove items from the in-memory tree/collections. |
| app/modules/editor/menuSettings/index.js | Minor whitespace-only change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ader isOutdated() now returns the fetched tree data on 200 so loadTree() can reuse it instead of hitting the same endpoint a second time. The await on isOutdated() is moved inside the existing try/catch so network errors are handled gracefully. Also removes redundant Backbone method reassignments in favour of the idiomatic model collection option. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@copilot Thanks for the review — addressed the following in 0f08de3: Double request on stale content (comment #2): Unhandled rejection (comment #1): Moved the Redundant method assignments (comment #4): Removed the manual |
Agent-Logs-Url: https://github.com/adapt-security/adapt-authoring-ui/sessions/04f3b6dd-f18f-44ff-8432-cff7d8d77871 Co-authored-by: taylortom <1059083+taylortom@users.noreply.github.com>
Addressed the two remaining reviewer comments in e277615:
|
The canImport check used `=== undefined` which returned false even when the array was empty, blocking every import once the importer started initialising the array up-front.
…estamp Editor data loading now requires: - adapt-authoring-content with the GET /api/content/tree/:courseId endpoint (^3.0.0) - adapt-authoring-authored with course timestamp on update (^1.4.0)
# [3.0.0](v2.0.7...v3.0.0) (2026-05-08) ### Breaking * Use content tree API for editor data loading (fixes #458) (#459) ([8f3b7a7](8f3b7a7)), closes [#458](#458) [#459](#459) ### Chore * Add packages:write permission to release workflow ([9c39a25](9c39a25)) * Use shared semantic-release config ([7bb4ff4](7bb4ff4))
|
🎉 This PR is included in version 3.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Fixes #458
Breaking
GET /api/content/tree/:courseIdinstead of the full-contentPOST /api/content/query— payload reduced from ~300-500KB to ~10-20KBIf-Modified-Sinceconditional requests, returning 304 when content hasn't changed (zero body transfer vs previous POST query)editorDataLoaderinternal API changed:loadTree()replacesContentCollectionfetch;isOutdated()uses conditional GETawait model.fetch()before scaffold form buildingpeerDependenciesupdated to declare runtime requirements explicitly:adapt-authoring-content: ^3.0.0— for the new tree endpointadapt-authoring-authored: ^1.4.0— for course timestamp on updateUpdate
editorDataLoader.js—$.ajaxused throughout instead of nativefetchfor consistency with the rest of the codebase; semicolons and spacing restored to match surrounding editor module stylemenuSettings/index.js— no full fetch needed since_menu,_theme,_enabledPluginsare now in tree projectionDependencies
Testing
/api/content/tree/:idinstead of/api/content/query