Description
The GET /api/v1/folder/search endpoint returns folder data but does not indicate whether a folder has sub-folders visible to the current user. UI tree components rely on this signal to decide whether to render an expand arrow — without it, they either make a second request per folder (N+1 problem) or render expand arrows on all folders, including leaf folders. When a user clicks to expand a leaf folder, nothing loads, which is a confusing and broken experience.
The fix is to add a hasChildren boolean field to the response, computed per-page in a single batch query and filtered by the current user's permissions. No schema migration is required.
Changes required
Each folder entry in the GET /api/v1/folder/search response will include a new hasChildren boolean field:
{
"id": "...",
"name": "blog",
"path": "/content/blog/",
"addChildrenAllowed": true,
"hasChildren": true
}
No other fields are removed or modified. The endpoint contract is fully backwards-compatible — consumers that do not use hasChildren are unaffected.
Acceptance Criteria
Additional Context
- No database schema changes required
- Permission filtering should use
permissionAPI.filterCollection (batch) rather than per-item doesUserHavePermission calls
Description
The
GET /api/v1/folder/searchendpoint returns folder data but does not indicate whether a folder has sub-folders visible to the current user. UI tree components rely on this signal to decide whether to render an expand arrow — without it, they either make a second request per folder (N+1 problem) or render expand arrows on all folders, including leaf folders. When a user clicks to expand a leaf folder, nothing loads, which is a confusing and broken experience.The fix is to add a
hasChildrenboolean field to the response, computed per-page in a single batch query and filtered by the current user's permissions. No schema migration is required.Changes required
Each folder entry in the
GET /api/v1/folder/searchresponse will include a newhasChildrenboolean field:{ "id": "...", "name": "blog", "path": "/content/blog/", "addChildrenAllowed": true, "hasChildren": true }No other fields are removed or modified. The endpoint contract is fully backwards-compatible — consumers that do not use
hasChildrenare unaffected.Acceptance Criteria
GET /api/v1/folder/searchresponse includes ahasChildrenboolean on each folder entryhasChildrenistrueonly if at least one child folder exists and is visible to the current user based on their permissionshasChildrenisfalsefor leaf folders or folders where all children are hidden from the current user by permissionsAdditional Context
permissionAPI.filterCollection(batch) rather than per-itemdoesUserHavePermissioncalls