UoE/Bitstream name in upload notifications - #1411
Conversation
Upload success and failure toasts in the submission form now name the file
they refer to ("File "report.pdf" uploaded successfully") instead of the
anonymous "Upload successful" / "Upload failed", so a submitter dropping
several files can tell which one each toast is about.
The uploader gains an additive `onCompleteItemWithFile` output carrying the
parsed response plus the client-side file name; the legacy `onCompleteItem`
is retained and still emits the bare parsed body first, byte-identically, so
the five other uploader consumers are untouched. `onUploadError` is retyped
from `any` to the existing `UploaderError`. A single `getNotificationContent`
helper is the only place an upload notification key literal appears.
The CLARIN client-side size-limit rejection is preserved exactly: its
discriminator still compares against a one-argument `translate.instant(key)`
and still runs first, and its message is emitted un-interpolated and without
a file name. The error handler resolves the name from both emitted item
shapes (FileItem from onErrorItem, FileLikeObject from onWhenAddingFileFailed).
Locales that have not translated the two new keys render the generic message
via the `default` interpolate param that MissingTranslationHelper already
honours, rather than a raw dotted key. cs.json5 carries human translations.
Ported from dataquest-dev#24.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR enhances upload-related user feedback by including the client-side file name in submission upload toast notifications, so multi-file uploads can be distinguished and failures are easier to spot. It does so by adding an additive uploader completion output that includes the uploaded file name (when available) while preserving the existing completion output unchanged.
Changes:
- Introduces
onCompleteItemWithFileas an additive uploader output emitting{ response, fileName? }alongside the existingonCompleteItem. - Updates the submission upload UI flow to use file-name-aware i18n keys (with a safe fallback via the
defaultinterpolate param) and preserves the existing size-limit discriminator behavior. - Adds/updates unit tests and i18n keys (English + Czech) to cover new notification behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/app/shared/upload/uploader/uploader-complete-event.model.ts | New completion-event model carrying parsed response + optional client-side file name. |
| src/app/shared/upload/uploader/uploader.component.ts | Emits the new onCompleteItemWithFile event while keeping onCompleteItem unchanged; types onUploadError. |
| src/app/shared/upload/uploader/uploader.component.spec.ts | Adds unit tests for the new completion output and size-limit/error emission invariants. |
| src/app/submission/form/submission-upload-files/submission-upload-files.component.html | Switches the binding to consume onCompleteItemWithFile. |
| src/app/submission/form/submission-upload-files/submission-upload-files.component.ts | Uses file-name-aware notification content (with i18n fallback) and retains size-limit discrimination logic. |
| src/app/submission/form/submission-upload-files/submission-upload-files.component.spec.ts | Adds coverage for file-name notifications, fallbacks, malformed payloads, and escaped rendering path. |
| src/assets/i18n/en.json5 | Adds upload-successful-file / upload-failed-file keys with {{fileName}}. |
| src/assets/i18n/cs.json5 | Adds Czech translations (plus commented English reference lines) for the new -file keys. |
Suppressed comments (1)
src/app/shared/upload/uploader/uploader-complete-event.model.ts:18
- The new model file ends with an extra whitespace-only line (trailing spaces). This adds avoidable diff noise and can trip whitespace-sensitive checks/editors.
}
|
Thanks @copilot — reviewed the one suppressed comment and I'm skipping it, because it doesn't reproduce.
The file ends with a single No trailing spaces, no whitespace-only final line. That is also exactly how the three sibling models in the same folder end ( No other comments were generated, so there is nothing else to action from this review. |
Description
Drop three files into a submission and you get three identical "Upload successful" toasts. If one of them fails, there's no way to tell which. This makes each notification name its file. When we don't have a name to show, you get the old generic message, same as before.
Instructions for Reviewers
What changed:
ds-uploadergets a second output,onCompleteItemWithFile, carrying{ response, fileName? }. The oldonCompleteItemstill fires first and still emits the bare response, so the three other places using the uploader don't notice anything.onUploadErroris typed asUploaderErrornow instead ofany, and the upload notification keys all moved into one smallgetNotificationContent()helper.en.json5plus Czech translations. Locales that don't have them yet fall back to the generic message instead of printing a rawsubmission.sections.upload.*key — that's what thedefaultinterpolate param is doing.To try it: drop two or three files into the Upload section and check each toast names the right one. Worth doing once in Czech too. For the size-limit path you need
dspace.upload.maxconfigured, otherwise the feature is simply off and the test tells you nothing.Before, both files give you the same message:
After:
Checklist
main— no, this one is a backport ontodtq-dev.role="alert"region and the same escaped rendering path, only the text differs. I haven't put a screen reader on it.Written with some help from Claude Code.