fix(edit-content): forward contentlet languageId to file field browser selector#35297
fix(edit-content): forward contentlet languageId to file field browser selector#35297
Conversation
…r selector The new Edit Content screen file field was opening the browser selector dialog without passing the contentlet's languageId, so the backend POST /api/v1/browser request defaulted to the system default language and excluded assets that only exist in the active language (e.g. French-only images were invisible when editing French content). Add an optional languageId to ContentByFolderParams and forward the current contentlet's languageId from DotFileFieldComponent.showSelectExistingFileDialog so it flows through DotBrowserSelectorComponent's $folderParams into the browser API call. The AngularFormBridge is unaffected; it already spreads params into the dialog data. Closes #34459
|
Claude finished @oidacra's task in 2m 35s —— View job PR Review
The approach is sound. A few issues worth flagging: 1. Primary fix path has no running test coverage
2. Optional-chain guard on a required input is dead code
this.$contentlet()?.languageId
3. Silent no-op when locales haven't loaded yet
4. The interface lives in both 5.
Summary: the fix logic is correct. The blocking concern is (1) — if |
…ile field dialog $contentlet is input.required but its value can be null while a contentlet is still being hydrated (e.g. new content with no saved contentlet yet), causing "Cannot read properties of null (reading 'languageId')" when the Select Existing File dialog is opened. Restore the optional chain so the dialog still opens in that state; languageId is forwarded as undefined which the backend treats as "any language", matching prior behavior.
…tore For new contentlets the $contentlet input has no languageId yet, so the "Select Existing File" dialog was falling back to the session language and hiding assets the user actually wanted to pick when editing in a non-default locale (e.g. fr-FR). Read the active locale from DotEditContentStore.currentLocale() first (injected as optional so the component can still render outside the edit-content layout / in unit tests) and fall back to the contentlet's languageId when the store isn't available. Verified in the UI: switching to fr-FR on a new contentlet and opening the Select Existing Image dialog now sends the fr-FR languageId in the /api/v1/browser POST and shows French-only assets.
Summary
Fixes a defect where image (and other file) fields in the new Edit Content screen did not show assets that exist only in the active editing language. The browser selector was opening without the contentlet's
languageId, so thePOST /api/v1/browserrequest defaulted to the system default language and hid language-specific assets.The fix carries
languageIdend-to-end through the dialog → store → HTTP chain:ContentByFolderParamsnow accepts an optionallanguageId?: number(both copies kept in sync).DotFileFieldComponent.showSelectExistingFileDialog()forwardsthis.$contentlet().languageIdin the dialog data.DotBrowserSelectorComponent.ngOnInit()already spreadsDynamicDialogConfig.datainto$folderParams, so the value propagates to the store and HTTP call without further code changes.AngularFormBridge.openBrowserModalalso already passes params through via a shallow spread, so VTL custom fields that setlanguageIdinoptions.paramsare automatically forwarded now that the interface supports it.Closes #34459
Acceptance Criteria
ContentByFolderParamsincludes an optionallanguageIdlanguageIdto the browser selector dialog dataAngularFormBridge.openBrowserModalforwardslanguageId(no bridge code change needed beyond the interface)dot-browser-selector.component.spec.ts,dot-edit-content-file-field.component.spec.ts)Test Plan
Automated
yarn nx test ui --testPathPattern=dot-browser-selector— 3 new tests assertlanguageIdpropagation fromDynamicDialogConfig.datathrough$folderParamsand intostore.uploadFileyarn nx test edit-content --testPathPattern=dot-edit-content-file-field— passes (new assertion added inside the existingxdescribe'd suite will run when that suite is un-skipped)yarn nx build dotcms-ui— compiles cleanlyyarn nx lint data-access edit-content— clean (pre-existing lint errors indotcms-modelsare unrelated to this change and exist onmain)Manual
Changed Files
core-web/libs/dotcms-models/src/lib/dot-site.model.tscore-web/libs/data-access/src/lib/dot-site/dot-site.service.tscore-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/components/dot-file-field/dot-file-field.component.tscore-web/libs/edit-content/src/lib/fields/dot-edit-content-file-field/dot-edit-content-file-field.component.spec.tscore-web/libs/ui/src/lib/components/dot-browser-selector/dot-browser-selector.component.spec.tsVisual Changes
UI-visible change: the "Select Existing File" dialog in the new Edit Content screen now lists images/files that match the contentlet's current language. Please attach before/after screenshots or a short clip showing a French-only image appearing in the selector when editing in French.