Skip to content

[Document Editor] Inline upload for relation editable - #4000

Merged
ValeriaMaltseva merged 7 commits into
2026.xfrom
1620-inline-upload-for-relation-editable
Sep 1, 2026
Merged

ValeriaMaltseva merged 7 commits into
2026.xfrom
1620-inline-upload-for-relation-editable

Conversation

@ValeriaMaltseva

@ValeriaMaltseva ValeriaMaltseva commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Closes #1620

Adds inline upload to the document relation editable, mirroring what the sibling relations (many-to-many) editable already offered.

Note

This PR was reworked after #4039 was merged. #4039 already added the upload button to ManyToOneRelation (shown whenever assets are allowed and the field is enabled), the assetUploadPath prop, the post-upload subtype guard and its asset-upload-type-not-allowed message. This PR keeps that merged behavior unchanged and only adds what is still missing for #1620.

What changed

ManyToOneRelation gained a disableInlineUpload opt-out prop that hides the upload button #4039 introduced. This mirrors the existing disableInlineUpload prop on the sibling ManyToManyRelation component, so both relation components are now configured the same way.

The document relation editable wires up the template config — same option names as the relations and image editables, so all of them behave alike:

{{ pimcore_relation('myRelation', {
    'uploadPath': '/content',
    'disableInlineUpload': false
}) }}

uploadPath was already declared in the editable's config type but unused; it is passed to the component as assetUploadPath now. disableInlineUpload also covers the request in #1966 for the many-to-one case. The upload button itself appears on the editable via #4039's default (assets allowed + enabled) — no opt-in needed.

No new upload machinery: it reuses the shared upload modal, so duplicate-name conflict handling, size limits, the upload queue and the iframe forwarding (element.openUploadModal) all apply unchanged.

Also fixed: subtype was not enforced on upload in many-to-many

#4039 fixed this for ManyToOneRelation; the same gap existed in the many-to-many toolbar. allowedAssetTypes was enforced for the element selector (createElementSelectorConfig) and for drag & drop (dndIsValidDataisAllowedSubType), but not for uploads. A relation restricted to image therefore accepted an uploaded PDF — a value neither of the other two paths could have produced.

The toolbar now filters uploaded assets through isAllowedSubType before assigning, and warns when some were dropped. The check runs after upload rather than as an accept filter on the file dialog, because the server decides the asset type from the MIME type, while accept is only a dialog hint. The assets are already created at that point, so the message says so instead of pretending they were rejected.

Translations

  • relations.upload.subtype-not-allowed (new) — phrased count-independently, since the many-to-many upload can partially fail; added to all seven locales at the English position.
  • asset-upload-type-not-allowed (from Restore inline asset upload on the many-to-one relation field #4039, used by ManyToOneRelation) — was English-only; the six missing locale translations are synced now (partly by the automated translation-sync workflow on this branch).

Asset is left untranslated per the glossary.

Verification

  • tsc --noEmit — clean
  • eslint on all touched files — clean
  • Full jest suite — 602 tests passing, including Restore inline asset upload on the many-to-one relation field #4039's existing ManyToOneRelation upload tests (unchanged and still green), a new test for disableInlineUpload, and 3 tests for the many-to-many partial-rejection behaviour
  • Storybook story added under Components/Data Entry/Relation/ManyToOneRelationConfigurationsWith Inline Upload

Not verified in a browser. My workspace has a 2026.2 backend against this 2026.x frontend, and POST /assets/exists/{id} (the batched upload exists-check from #3986) only exists on backend 2026.x — so every upload 405s locally, independent of this change. The iframe → parent openUploadModal hop and the button's visual placement are therefore verified as code paths only, not empirically. CI plus a review on an aligned environment should cover the rest.

Note for the reviewer

The many-to-many fix is a pre-existing bug in a sibling component, not part of #1620. It is here because it is the same defect #4039 fixed for many-to-one, and the same guard. Say the word if you would rather have it as its own PR.

🤖 Generated with Claude Code

Adds an upload button to the many-to-one relation, so a document `relation`
editable can create a new asset and assign it without leaving the editor —
the capability the sibling `relations` editable already had.

The button is opt-in on the component (`assetInlineUploadAllowed`), because
ManyToOneRelation is also used as a plain element picker in ~25 places that
should not grow an upload button. The document editable enables it when the
editable allows assets, and honours the template config:

    {{ pimcore_relation('myRelation', {
        'uploadPath': '/content',
        'disableInlineUpload': false
    }) }}

Uploading reuses the shared upload modal, so conflict handling, size limits,
the upload queue and the iframe forwarding apply unchanged.

Also closes the same gap in the many-to-many toolbar: uploaded assets were
assigned without checking `allowedAssetTypes`, so a relation restricted to
images accepted an uploaded PDF — a value neither the element selector nor
drag and drop would have produced. Both components now validate the
server-assigned asset type before assigning it.

Refs #1620

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings August 20, 2026 07:46
@ValeriaMaltseva ValeriaMaltseva added this to the 2026.3.0 milestone Aug 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Verdict: Needs changes. Adds inline asset upload to document relation editables and subtype validation to both relation components.

Changes:

  • Adds opt-in upload support, upload-path configuration, and assignment handling.
  • Rejects uploaded assets with disallowed subtypes.
  • Adds tests, Storybook coverage, and translations.

Assessment:

  • Fixes the missing upload integration at the owning components.
  • Optional props preserve backward compatibility and existing call sites.
  • Regression tests cover upload gating, assignment, and subtype rejection.
  • Blocker: asynchronous path resolution can upload files to the asset root before the configured path resolves.

Reviewed changes

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

Show a summary per file
File Description
translations/studio.sv.yaml Adds Swedish rejection messages.
translations/studio.no.yaml Adds Norwegian rejection messages.
translations/studio.it.yaml Adds Italian rejection messages.
translations/studio.fr.yaml Adds French rejection messages.
translations/studio.es.yaml Adds Spanish rejection messages.
translations/studio.en.yaml Adds English rejection messages.
translations/studio.de.yaml Adds German rejection messages.
dynamic-type-document-editable-relation.tsx Wires editable upload configuration.
many-to-one-relation.tsx Implements inline upload and subtype validation.
many-to-one-relation.test.tsx Tests upload behavior.
many-to-one-relation.stories.tsx Documents the upload configuration.
many-to-many-relation/components/toolbar/toolbar.tsx Validates uploaded asset subtypes.
many-to-many-relation/components/toolbar/toolbar.test.tsx Tests partial and complete rejection.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@pimcore-deployments

Copy link
Copy Markdown
Collaborator

🌐 Translations synced automatically

The key changes below were generated for all target languages, passed the
mechanical validation gate (key parity, order, placeholders, types, plurals),
and are being committed to this branch by the workflow (check the run status
if the commit is not visible).
Please review the generated translations.

Added (2):

  • relations.upload.subtype-not-allowed
  • many-to-one-relation.upload.subtype-not-allowed

🧹 Pre-existing translation errors (backlog partly cleared)

18 validation error(s) predating this PR were present at the merge base. This run also fixed 6 of them; 12 still remain. The remainder is not blocking — later runs keep chipping at it.

ValeriaMaltseva and others added 4 commits September 1, 2026 09:44
allowed), the assetUploadPath prop and the subtype guard on
ManyToOneRelation. Keep that merged behavior and reduce this PR to its
actual delta: a disableInlineUpload opt-out prop (mirroring
ManyToManyRelation), the document relation editable wiring for the
uploadPath and disableInlineUpload template options, and translations
for the asset-upload-type-not-allowed key that #4039 added in English
only.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Sep 1, 2026

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Note

This error may be related to your runner configuration. You can now configure runners for Copilot code review separately from Copilot cloud agent by creating a copilot-code-review.yml file with your setup steps. Read the docs for details.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated no new comments.

@ValeriaMaltseva
ValeriaMaltseva merged commit d221aa4 into 2026.x Sep 1, 2026
22 of 23 checks passed
@ValeriaMaltseva
ValeriaMaltseva deleted the 1620-inline-upload-for-relation-editable branch September 1, 2026 11:58
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Document Editor] Inline upload for relation editable

3 participants