Skip to content

UoE/Bitstream name in upload notifications - #1411

Merged
milanmajchrak merged 1 commit into
dtq-devfrom
uoe/bitstream-name-in-upload-notifications
Aug 3, 2026
Merged

UoE/Bitstream name in upload notifications#1411
milanmajchrak merged 1 commit into
dtq-devfrom
uoe/bitstream-name-in-upload-notifications

Conversation

@milanmajchrak

@milanmajchrak milanmajchrak commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

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-uploader gets a second output, onCompleteItemWithFile, carrying { response, fileName? }. The old onCompleteItem still fires first and still emits the bare response, so the three other places using the uploader don't notice anything.
  • onUploadError is typed as UploaderError now instead of any, and the upload notification keys all moved into one small getNotificationContent() helper.
  • Two new keys in en.json5 plus Czech translations. Locales that don't have them yet fall back to the generic message instead of printing a raw submission.sections.upload.* key — that's what the default interpolate 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.max configured, otherwise the feature is simply off and the test tells you nothing.

Before, both files give you the same message:

Before

After:

After

Checklist

  • Created against main — no, this one is a backport onto dtq-dev.
  • Small — 51 lines of actual code across 4 files, the rest is specs and i18n.
  • Follows our coding conventions.
  • Passes ESLint — green in CI.
  • No circular dependencies — green in CI.
  • TypeDoc on everything new.
  • Specs — 24 new ones. CI went from 5467 to 5491 passing, nothing else moved.
  • Accessibility — the notification component isn't touched, so it's the same role="alert" region and the same escaped rendering path, only the text differs. I haven't put a screen reader on it.
  • i18n keys, no hardcoded English.
  • How to test it — above.
  • No new dependencies.
  • Nothing new to document.

Written with some help from Claude Code.

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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 onCompleteItemWithFile as an additive uploader output emitting { response, fileName? } alongside the existing onCompleteItem.
  • Updates the submission upload UI flow to use file-name-aware i18n keys (with a safe fallback via the default interpolate 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.
}

@milanmajchrak

Copy link
Copy Markdown
Collaborator Author

Thanks @copilot — reviewed the one suppressed comment and I'm skipping it, because it doesn't reproduce.

uploader-complete-event.model.ts:18 — the new model file ends with an extra whitespace-only line (trailing spaces).

The file ends with a single } followed by one newline and nothing else. Verified against the pushed blob:

$ gh api -H "Accept: application/vnd.github.raw" \
    ".../contents/src/app/shared/upload/uploader/uploader-complete-event.model.ts?ref=uoe/bitstream-name-in-upload-notifications" \
  | tail -3 | cat -A
   */$
  fileName?: string;$
}$

No trailing spaces, no whitespace-only final line. That is also exactly how the three sibling models in the same folder end (uploader-error.model.ts, uploader-options.model.ts, uploader-properties.model.ts — all }$), so the file matches the existing convention. Run lint is green in CI on both 18.x and 20.x.

No other comments were generated, so there is nothing else to action from this review.

@milanmajchrak
milanmajchrak merged commit 6487711 into dtq-dev Aug 3, 2026
7 checks passed
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.

2 participants