Skip to content

[dtq-dev-93] Check the upload size in the browser and refresh sponsor and author subfields after a pick - #1762

Open
milanmajchrak wants to merge 2 commits into
dtq-dev-93from
93/fe-submission-fork-fixes
Open

milanmajchrak wants to merge 2 commits into
dtq-dev-93from
93/fe-submission-fork-fixes

Conversation

@milanmajchrak

@milanmajchrak milanmajchrak commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

References

Ports these dtq-dev changes:

Upstream DSpace has no merged size check. An open upstream PR "Reject files above the upload size limit before sending any data" reads the limit from the upload section config instead.

Description

The uploader refuses a file over the server's upload limit before sending it. After a picked funding or author suggestion, the form is rebuilt from the saved value, so every subfield shows its own part.

Instructions for Reviewers

List of changes in this PR:

  • UploaderComponent reads spring.servlet.multipart.max-file-size and sets it as the ng2-file-upload maxFileSize. A bigger file is not queued, and onUploadError gets the existing size-limit message, which SubmissionUploadFilesComponent already shows.
  • Auto upload waits until the limit is known. Files added before that are checked when it arrives.
  • The limit is read with its unit (4GB, 512MB, a bare number is bytes, -1 is no limit). The dtq-dev code read every value as GB.
  • A sponsor or author suggestion puts the whole value into one subfield. The autocomplete marks the change of a pick with suggestionPicked. SubmissionSectionFormComponent remembers the pick and its row, and rebuilds the form when the server returns that row saved. Typed text never rebuilds the form. Contact and size have no suggestions, so there is nothing to fill in from the server. dtq-dev also rebuilds only for sponsor and author.
  • dtq-dev did the same by polling the item over REST every 250 ms. Here the save response in the store triggers it.
  • New specs in uploader.component.spec.ts, section-form.component.spec.ts and ds-dynamic-autocomplete.component.spec.ts. Each one that covers a fix fails without it.

How to test:

  1. Set spring.servlet.multipart.max-file-size = 1MB in the backend local.cfg and restart it.
  2. In a submission, drop a 2 MB file. It is refused at once with "File size exceeds the maximum upload size", and DevTools shows no upload request. A smaller file uploads as before.
  3. In the Funding field choose EU and search a project, then pick one. After the save, type, code, organisation, name and EU identifier each show their own part.
  4. In the author last-name field pick a suggestion like "Surname, Name". After the save, both inputs are filled.
  5. Type Smith, Jr. as the last name and John as the first name. The form is not rebuilt and nothing you type is lost.
  6. Add a second author row and pick the same suggestion as in row 1. After the save, both rows show last and first name in their own inputs.
  • npm run test -- --include=src/app/shared/upload/uploader/uploader.component.spec.ts --include=src/app/submission/sections/form/section-form.component.spec.ts --include=src/app/shared/form/builder/ds-dynamic-form-ui/models/autocomplete/ds-dynamic-autocomplete.component.spec.ts

Codex review (gpt-6.2-sol, high), 3 rounds: 4 findings fixed (a typed comma looked like a pick, the same value in another row confirmed a pick, two ways a file was sent before the limit was known). The last round found 4, not changed in this PR:

  • After a pick, the whole form is rebuilt, so text typed in another field before the save returns is lost. dtq-dev rebuilds the same way after every sponsor or author change.
  • In MyDSpace, a file dropped while the limit is still loading can go out through the manual upload there. The server still rejects it.
  • Leaving the page while the limit is still loading can still start the queued upload.
  • A limit of 0 is not applied in the browser.

Checklist

  • My PR is created against the main branch of code (unless it is a backport or is fixing an issue specific to an older branch).
  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR passes ESLint validation using npm run lint
  • My PR doesn't introduce circular dependencies (verified via npm run check-circ-deps)
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • My PR aligns with Accessibility guidelines if it makes changes to the user interface.
  • My PR uses i18n (internationalization) keys instead of hardcoded English text, to allow for translations.
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
  • If my PR includes new libraries/dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR includes new features or configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

🤖 Generated with Claude Code

milanmajchrak and others added 2 commits November 26, 2026 15:31
The uploader reads spring.servlet.multipart.max-file-size and refuses a bigger file before it is sent.
Auto upload waits for the limit. Ported from dtq-dev; units like MB are now read correctly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The autocomplete marks a picked suggestion, which fills one subfield with the whole value.
Once the server returns that row saved, the form is rebuilt so each subfield shows its own part, as on dtq-dev.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant