-
Notifications
You must be signed in to change notification settings - Fork 480
feat(dot-browsing): Fix error in HostEdit Folder #34457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(dot-browsing): Fix error in HostEdit Folder #34457
Conversation
…update tests ## Summary This commit introduces a parent reference in the tree structure for better data management and updates related tests to ensure functionality. ## Changes Made ### Models - Added `parent` property to `CustomTreeNode` in `dot-browser-selector.model.ts`. ### Store - Updated `HostFolderFiledStore` to utilize the new `CustomTreeNode` structure in `host-folder-field.store.ts`. ### Service - Modified `DotBrowsingService` to include the parent reference in the tree response in `dot-browsing.service.ts`. ### Tests - Expanded test cases in `dot-browsing.service.spec.ts` to validate the presence of the parent reference in tree structures for both single and multi-level paths. ## Technical Details The addition of the parent reference allows consumers of the tree structure to access the parent folder's hostname directly, improving the usability of the data model. ## Testing - [x] Unit tests added/updated to cover new functionality. - [x] Manual testing performed to verify tree structure integrity and parent reference accessibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug where the "Host or Folder" field value was not displaying in the new Edit Mode for HTML pages. The root cause was that the parent property was missing from the tree structure returned by DotBrowsingService, causing the store code that accessed tree.parent.hostName to fail with a null reference error.
Changes:
- Added
parentproperty to theCustomTreeNodetype definition to include parent folder information - Modified
DotBrowsingService.buildTreeByPaths()to populate the parent reference in the tree response - Added explicit type annotation in
HostFolderFiledStorefor better type safety - Added comprehensive unit tests to verify the parent reference is always present in both single-level and multi-level folder paths
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
core-web/libs/dotcms-models/src/lib/dot-browser-selector.model.ts |
Added optional parent?: DotFolder property to CustomTreeNode type and imported DotFolder model |
core-web/libs/ui/src/lib/services/dot-browsing/dot-browsing.service.ts |
Updated buildTreeByPaths() to include parent: node.parent in the tree structure; alphabetized imports |
core-web/libs/edit-content/src/lib/fields/dot-edit-content-host-folder-field/store/host-folder-field.store.ts |
Added CustomTreeNode type annotation and import; alphabetized imports |
core-web/libs/ui/src/lib/services/dot-browsing/dot-browsing.service.spec.ts |
Added two comprehensive test cases verifying parent reference exists for single and multi-level paths; alphabetized imports |
...t-content/src/lib/fields/dot-edit-content-host-folder-field/store/host-folder-field.store.ts
Outdated
Show resolved
Hide resolved
…is-not-showing-up-in-new-edit-mode
…tailed documentation ### Changes Made - Added comprehensive JSDoc comments to `TreeNodeData`, `TreeNodeItem`, `TreeNodeSelectItem`, and `CustomTreeNode` types in `dot-browser-selector.model.ts` for better clarity on their structure and usage. - Updated `HostFolderFiledStore` to utilize the new `CustomTreeNode` type in `host-folder-field.store.ts`, ensuring type safety and improved readability. ### Motivation These enhancements improve the maintainability of the codebase by providing clear documentation for developers working with tree structures in the browser selector. ### Testing - Manual testing performed to verify that the tree structure functions correctly with the updated types.
Summary
This commit introduces a parent reference in the tree structure for better data management and updates related tests to ensure functionality.
Changes Made
Models
parentproperty toCustomTreeNodeindot-browser-selector.model.ts.Store
HostFolderFiledStoreto utilize the newCustomTreeNodestructure inhost-folder-field.store.ts.Service
DotBrowsingServiceto include the parent reference in the tree response indot-browsing.service.ts.Tests
dot-browsing.service.spec.tsto validate the presence of the parent reference in tree structures for both single and multi-level paths.Technical Details
The addition of the parent reference allows consumers of the tree structure to access the parent folder's hostname directly, improving the usability of the data model.
Testing
#34275
This PR fixes: #34275