Skip to content

fix(browser): pass folderPath when creating file asset from Site Browser#35507

Open
adrianjm-dotCMS wants to merge 3 commits intomainfrom
issue-34588-fix-file-asset-folder-prefill-site-browser
Open

fix(browser): pass folderPath when creating file asset from Site Browser#35507
adrianjm-dotCMS wants to merge 3 commits intomainfrom
issue-34588-fix-file-asset-folder-prefill-site-browser

Conversation

@adrianjm-dotCMS
Copy link
Copy Markdown
Member

@adrianjm-dotCMS adrianjm-dotCMS commented Apr 29, 2026

Summary

  • Fixes TC-004 QA failure from PR feat(dot-custom-event-handler): enhance contentlet creation with folder #35322: when a user navigated into a nested folder in Site Browser and opened Add Asset → File, the folderPath was not passed to createContentlet(), so the new Angular edit-content form always defaulted the Host/Folder field to site root instead of the current folder
  • Stores the active folderMap in currentFileAssetFolderMap inside showFileAssetPopUp — mirroring the existing currentPageAssetFolderMap pattern already in place for HTML pages
  • Passes the resolved folderPath to createContentlet() in the single-file branch of getSelectedfileAsset
  • Adds E2E coverage for FileAssetContentType folderPath pre-fill (field variable hostFolder), complementing the SimpleContentType specs added in PR feat(dot-custom-event-handler): enhance contentlet creation with folder #35322

VIDEO

Screen.Recording.2026-04-30.at.9.57.36.AM.mov

Related

Closes #34588

Test plan

  • Navigate into a nested folder in Site Browser (e.g. folder-1/folder-2)
  • Click +Add AssetFile, select a file-asset content type with the new editor enabled
  • Verify the Angular form opens with ?folderPath=<site>/folder-1/folder-2/ in the URL and Host/Folder field pre-filled correctly
  • Upload a file, save, return to Site Browser → confirm file is inside folder-2, not at site root
  • Verify HTML page creation (TC-003) still works as before — no regression

🤖 Generated with Claude Code

When opening the Add File Asset dialog from a nested folder in Site
Browser, folderPath was not passed to createContentlet(), causing the
new Angular edit-content form to always default Host/Folder to site root.

Stores the active folderMap in currentFileAssetFolderMap (mirroring the
existing currentPageAssetFolderMap pattern used for HTML pages) and
passes the resolved folderPath to createContentlet() in the single-file
branch of getSelectedfileAsset.

Adds E2E coverage for FileAsset content type folderPath pre-fill,
complementing the SimpleContentType specs added in PR #35322.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Apr 29, 2026

Claude finished @adrianjm-dotCMS's task in 3m 4s —— View job


PR Review

  • Read changed files
  • Analyze the fix logic
  • Review E2E test coverage
  • Post findings

Clean fix. A few things worth noting:

JSP fix (view_browser_js_inc.jsp)

The core change is correct and consistent. currentFileAssetFolderMap is stored at the top of showFileAssetPopUp before the dialog is rendered, and consumed in getSelectedfileAsset using exactly the same path-construction logic as currentPageAssetFolderMap (lines 1638–1647 → copied verbatim to lines 1661–1667). The null-guard (currentFileAssetFolderMap && currentFileAssetFolderMap.fullPath) and the hoisted var declaration are fine for legacy JSP JS. No issues.

Page object (newEditContentForm.page.ts)

goToNewFileAssetWithFolderPath (lines 126–132) and goToNewWithFolderPath (lines 115–119) are identical except for their waitFor target (field-hostFolder vs title). Copilot's suggestion to unify them with a configurable readiness selector is valid:

async goToNewWithFolderPath(contentType: string, folderPath: string, readyTestId = 'title') {
    await this.page.goto(`/dotAdmin/#/content/new/${contentType}?folderPath=${folderPath}`);
    await this.page.waitForLoadState('domcontentloaded');
    await this.page.getByTestId(readyTestId).waitFor({ state: 'visible', timeout: 15000 });
}

Not a bug, but the duplication will drift if the navigation logic changes. Fix this →

E2E spec (host-folder-field-file-asset.spec.ts)

  • CONTENT_EDITOR2_ENABLED: true is applied by default in createFakeContentType (via contentType.ts:55), so the Angular form loads correctly even without explicit metadata in the spec. ✅
  • Created folders are not deleted in afterEach — but this matches the existing pattern in host-folder-field-nested.spec.ts and host-folder-field-prefill.spec.ts, which also leave folders behind. The unique testSuffix prevents cross-run collisions.
  • mode: 'serial' is used, but the three tests are independent (each beforeEach creates its own content type). They could run in parallel. However, given that this matches the existing sibling spec pattern, it's not a regression.
  • The three scenarios (deep path, shallow path, empty fallback) cover the meaningful branches. Adequate coverage.

No functional bugs, security issues, or missing edge cases found.

@github-actions github-actions Bot added Area : Backend PR changes Java/Maven backend code Area : Frontend PR changes Angular/TypeScript frontend code labels Apr 29, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes Site Browser “Add Asset → File” creation so the Angular edit-content form receives the correct folderPath for nested folders (regression noted in TC-004 / issue #34588), and adds E2E coverage to prevent recurrence.

Changes:

  • Persist the active folder context for file assets (currentFileAssetFolderMap) when opening the “Add File Asset” popup.
  • Pass the resolved folderPath into createContentlet() for the single-file asset creation path (mirrors existing HTML page behavior).
  • Add Playwright E2E specs validating folderPath pre-fill for File Asset content types (hostFolder field variable).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
dotCMS/src/main/webapp/html/portlet/ext/browser/view_browser_js_inc.jsp Captures the current folder context for file assets and forwards folderPath into the Angular create-contentlet event payload.
core-web/apps/dotcms-ui-e2e/src/tests/edit-content/fields/host-folder-field/host-folder-field-file-asset.spec.ts Adds E2E coverage ensuring folderPath query param pre-fills Host/Folder for File Asset types (nested, shallow, empty fallback).

adrianjm-dotCMS and others added 2 commits April 30, 2026 09:32
- Move goToNewFileAssetWithFolderPath() to NewEditContentFormPage so the
  URL pattern lives in one place (waits for field-hostFolder instead of
  title, which file asset types do not expose)
- Add afterEach to delete the test content type and avoid data accumulation
- Remove the local navigateToNewFileAsset helper replaced by the page object

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI: Safe To Rollback Area : Backend PR changes Java/Maven backend code Area : Frontend PR changes Angular/TypeScript frontend code

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[DEFECT] Host or Folder field not picking up current location in Site Browser

3 participants