feat(dot-browser-selector): add Upload New File button to File Picker in New Edit Content#35221
Conversation
…ser selector component - Enhanced to handle file uploads via a new method. - Updated the HTML template to include a file input and an upload button, triggering the file selection dialog. - Introduced output in to emit the selected file. - Implemented unit tests for the new upload functionality in . This feature allows users to upload files directly from the browser, improving the content management experience.
…amic accept attribute
- Updated the file upload logic to preserve existing content when an upload fails, displaying appropriate error messages based on the error type (generic or permissions-related). - Added new internationalization keys for error messages related to file uploads. - Improved unit tests to cover new error handling scenarios. This change improves the user experience by providing clearer feedback during file upload operations.
…event handling - Removed unused references and signals in the DotBrowserSelectorComponent and DotSideBarComponent. - Updated event handling for node expansion to directly call the store's loadChildren method. - Cleaned up the HTML template by removing redundant attributes and improving readability. These changes streamline the component's functionality and enhance maintainability.
…folder selection - Introduced a computed property to determine if the upload button should be disabled when no site or folder is selected. - Updated the HTML templates in both and components to bind the upload button's disabled state to the new property. These changes enhance user experience by preventing uploads until a valid destination is selected.
|
Claude finished @adrianjm-dotCMS's task in 3m 35s —— View job Claude finished @adrianjm-dotCMS's task in 34s —— View job Rollback Safety Analysis (re-run on sync)
Result: ✅ Safe To Rollback All 12 changed files are frontend-only (Angular/TypeScript components and i18n property files). Checked against every rollback-unsafe category:
Language property files ( Label applied: |
Rollback Safety Analysis
Result: ✅ Safe To Rollback All 12 changed files are frontend-only (Angular/TypeScript components and i18n property files). Checked against every rollback-unsafe category:
Language property files ( Label applied: |
There was a problem hiding this comment.
Pull request overview
Adds in-place asset uploading to the dot-browser-selector file picker used by New Edit Content, aligning it more closely with Content Drive behavior so users can upload without leaving the editor.
Changes:
- Adds an Upload button + hidden file input to
dot-dataviewand wires it up throughdot-browser-selector. - Introduces a new store method to upload via
DotUploadFileService.uploadDotAssetand refresh the content list while preserving existing results on failure. - Extends i18n keys and adds unit tests for the new upload/accept/disabled behaviors.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| dotCMS/src/main/webapp/WEB-INF/messages/Language.properties | Adds new upload error message keys. |
| dotCMS/src/main/webapp/WEB-INF/messages/Language_es.properties | Adds Spanish translation for the Upload action label. |
| core-web/libs/ui/src/lib/components/dot-browser-selector/store/browser.store.ts | Removes nodeExpaned, updates folder expansion behavior, adds uploadFile method using DotUploadFileService. |
| core-web/libs/ui/src/lib/components/dot-browser-selector/store/browser.store.test.ts | Adds upload tests and mocks DotUploadFileService. |
| core-web/libs/ui/src/lib/components/dot-browser-selector/dot-browser-selector.component.ts | Adds computed uploadDisabled + accept derivation and upload handler, simplifies node expand handling. |
| core-web/libs/ui/src/lib/components/dot-browser-selector/dot-browser-selector.component.spec.ts | New component unit tests for accept/disabled/node selection/upload delegation. |
| core-web/libs/ui/src/lib/components/dot-browser-selector/dot-browser-selector.component.html | Wires new inputs/outputs between selector and dataview. |
| core-web/libs/ui/src/lib/components/dot-browser-selector/components/dot-sidebar/dot-sidebar.component.ts | Updates System Host matching logic to use data.id; removes manual change detection method. |
| core-web/libs/ui/src/lib/components/dot-browser-selector/components/dot-sidebar/dot-sidebar.component.html | Removes duplicate attribute. |
| core-web/libs/ui/src/lib/components/dot-browser-selector/components/dot-dataview/dot-dataview.component.ts | Adds accept/uploadDisabled inputs and onUploadFile output; imports PrimeNG Message module. |
| core-web/libs/ui/src/lib/components/dot-browser-selector/components/dot-dataview/dot-dataview.component.html | Adds Upload button, hidden file input, and inline error message area. |
| core-web/libs/ui/src/lib/components/dot-browser-selector/components/dot-dataview/dot-dataview.component.spec.ts | New unit tests covering the upload UI and file selection behavior. |
- Replace switchMap with exhaustMap in uploadFile to prevent cancelling in-flight POST requests when multiple uploads are triggered quickly - Replace throw with early return in onNodeSelect to avoid surfacing uncaught errors from an Angular event handler - Remove stale nodeExpaned assertions from store tests — the field does not exist in BrowserSelectorState; tests were asserting on undefined - Add missing Spanish translations for upload error keys: dot.file.field.dialog.upload.file.error and dot.file.field.dialog.upload.file.error.permissions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Rollback Safety Analysis (re-run on sync)All 12 changed files remain frontend-only. Result unchanged: ✅ Safe To Rollback Label |
… in New Edit Content (#35221) ## Summary Closes #33103 Adds an **Upload New File** button to the File Picker (`dot-browser-selector`) used in New Edit Content. Users can now upload files directly to the selected site/folder without leaving the content editor. - **Upload button** is visible in both Image Picker (`accept=image/*`) and File Picker (`accept=*/*`) - **Button disabled** only when no site/folder is selected (`hostFolderId === ''`); System Host and real sites enable it - **Permission handling**: button is always enabled — clicking without upload permissions shows an **inline error message** instead of disabling the button - **Upload uses the same endpoint/service as Content Drive** (`DotUploadFileService.uploadDotAsset`) - After a successful upload, the file list refreshes and the new file is visible but **not auto-selected** - Upload failures (403 permissions, generic server errors) show contextual inline error messages without clearing the existing file list https://github.com/user-attachments/assets/467d30ea-218c-40fd-b482-8066dd584dc0 ## Changes - `dot-dataview.component.ts/html` — added `$uploadDisabled` input and `[disabled]` binding on upload button - `dot-browser-selector.component.ts/html` — added `$uploadDisabled` computed signal (`hostFolderId === ''`) and passes it to `dot-dataview` - `dot-browser-selector.component.spec.ts` — **new spec file** covering `$uploadDisabled`, `$acceptAttr`, `onNodeSelect`, and `onFileUpload` (13 tests) ## Out of scope - Feature 2 — Global Search across all sites/folders will be handled in a separate ticket - - ## Test plan - [ ] Upload button visible in Image Picker and File Picker dialogs - [ ] Button enabled when System Host or any site/folder is selected - [ ] Button disabled only in the edge case where `hostFolderId` is empty - [ ] Clicking Upload without permissions shows inline error; file list remains intact - [ ] Happy path: select a site/folder → upload image/file → file appears in list, not auto-selected - [ ] Generic server error shows generic inline error message - [ ] Image Picker restricts file input to `image/*`; File Picker accepts all files --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
…button (#35301) ## Summary Follow-up UX improvement to #35221. After a successful upload, the newly uploaded file is now **automatically selected** in the file list and the **Add button is immediately enabled** — eliminating the extra click that was previously required. ### Changes - **`browser.store.ts`** — `uploadFile`: captures the `DotCMSContentlet` returned by `uploadDotAsset` and calls `setSelectedContent(uploadedContentlet)` before reloading the content list, so `selectedContent` is populated as soon as the upload succeeds. - **`dot-dataview.component.ts`** — Renamed `$selectedProduct` → `$selectedContent` and added `alias: 'selectedContent'` so the parent can drive the table's visual selection from outside the component. - **`dot-browser-selector.component.html`** — Added `[selectedContent]="store.selectedContent()"` binding on `dot-dataview`. This feeds the store's selection state into the PrimeNG table's `[(selection)]` binding, highlighting the uploaded row automatically after the content list refreshes. ### Before / After | | Before | After | |---|---|---| | Upload file | File appears in list, nothing selected, Add disabled | File appears in list, **row highlighted**, Add enabled | ## Video https://github.com/user-attachments/assets/8c5d4fd0-2dfa-40f4-8031-d5f0b9e34c3e ## Test plan - [ ] Upload a file → it appears in the list highlighted and Add button is enabled - [ ] Clicking a different row still selects it and keeps Add enabled - [ ] Upload error (403 / generic) shows the inline error message and does not auto-select anything - [ ] Cancelling the dialog after upload works normally This PR fixes: #33103
Summary
Closes #33103
Adds an Upload New File button to the File Picker (
dot-browser-selector) used in New Edit Content. Users can now upload files directly to the selected site/folder without leaving the content editor.accept=image/*) and File Picker (accept=*/*)hostFolderId === ''); System Host and real sites enable itDotUploadFileService.uploadDotAsset)Screen.Recording.2026-04-06.at.4.10.12.PM.mov
Changes
dot-dataview.component.ts/html— added$uploadDisabledinput and[disabled]binding on upload buttondot-browser-selector.component.ts/html— added$uploadDisabledcomputed signal (hostFolderId === '') and passes it todot-dataviewdot-browser-selector.component.spec.ts— new spec file covering$uploadDisabled,$acceptAttr,onNodeSelect, andonFileUpload(13 tests)Out of scope
Test plan
hostFolderIdis emptyimage/*; File Picker accepts all filesThis PR fixes: #33103