Issue 36459 add has children field to folder search api to support accurate UI tree rendering - #36497
Merged
Conversation
5 tasks
Contributor
|
Claude finished @freddyDOTCMS's task in 7m 44s —— View job Review: PR #36497 —
|
freddyDOTCMS
enabled auto-merge
July 9, 2026 21:35
…search_API_to_support_accurate_UI_tree_rendering
jcastro-dotcms
approved these changes
Jul 9, 2026
jcastro-dotcms
approved these changes
Jul 9, 2026
|
Tick the box to add this pull request to the merge queue (same as
|
freddyDOTCMS
deleted the
issue_36459_Add_hasChildren_field_to_folder_search_API_to_support_accurate_UI_tree_rendering
branch
July 9, 2026 23:40
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes: #36459
Summary
Adds a
hasChildrenboolean field to every folder entry returned byGET /api/v1/folder/search, so UI tree components can accurately decide whether to render an expand arrow — without issuing a second request per folder.Problem: The endpoint returned folder data but gave no signal about sub-folders. Tree UIs were forced to choose between an N+1 query per folder or rendering expand arrows on all folders (including leaves). Clicking a leaf's arrow loaded nothing, breaking the UX.
Solution:
hasChildrenis computed in batch per page — two SQL round-trips total: one to fetch all direct children of the page's folders in a singleIN (...)query, one batch permission check viapermissionAPI.filterCollection. No per-folder queries.hasChildren: trueonly when at least one child is visible to the requesting user.What changed
FolderSearchView— addedhasChildrenboolean field to the response record.FolderAPIImpl#searchFolders— calls newfindParentPathsWithVisibleChildrenafter the existing page query; uses batchpermissionAPI.filterCollection(not per-itemdoesUserHavePermission).FolderFactory/FolderFactoryImpl— newfindDirectChildFolders(hostInode, parentPaths)fetches all direct children for the page in one SQL query.FolderResourceSearchTestandFolderAPIImplFilterTest/FolderFactoryImplTestcovering: child exists →true, leaf folder →false, permission-hidden child →false, user with read permission → visible child counted, empty page guard.FolderResourcecollection withhasChildrenassertions.API contract
The change is fully backwards-compatible. No existing fields are removed or modified.
{ "id": "...", "inode": "...", "name": "blog", "path": "/content/blog/", "addChildrenAllowed": true, "hasChildren": true }Checklist
permissionAPI.filterCollectionpath — no new permission surface)Closes #36459