-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UI: Handle Empty File Uploads in FileUploader #1802
UI: Handle Empty File Uploads in FileUploader #1802
Conversation
400d2c8
to
d94136e
Compare
* Expose `RECORDS_RESOURCES_ALLOW_EMPTY_FILES` for UI control * Related to: inveniosoftware/invenio-rdm-records#1802
f50bb40
to
2bc83b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM! Just a few comments to make it a bit more readable!
...ds/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/FileUploader/FileUploader.js
Outdated
Show resolved
Hide resolved
const emptyFiles = acceptedFiles.filter((file) => file.size === 0); | ||
const nonEmptyFiles = acceptedFiles.filter((file) => file.size > 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very minor optimization... we ended up having 3 times filter
, maybe we can loop once?
const emptyFiles = acceptedFiles.filter((file) => file.size === 0); | |
const nonEmptyFiles = acceptedFiles.filter((file) => file.size > 0); | |
const filesNames = _map(filesList, "name"); | |
let hasEmptyFiles = false; | |
let hasNonEmptyFiles = false; | |
let hasDuplicatedFiles = false; | |
let nonEmptyFiles = []; | |
for (const file of acceptedFiles) { | |
if (file.size === 0) { | |
hasEmptyFiles = true; | |
} else { | |
hasNonEmptyFiles = true; | |
nonEmptyFiles.push(file); | |
} | |
if (filesNames.includes(file.name)) { | |
hasDuplicatedFiles = true; | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opted to use reduce to accumulate duplicate, empty, and non-empty files in a single pass. This allows us to track file names for warnings while maintaining efficiency and flexibility, as booleans alone can't e.g track file names.
Let me know if this works or if there's a better approach.
...ds/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/FileUploader/FileUploader.js
Outdated
Show resolved
Hide resolved
...ds/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/FileUploader/FileUploader.js
Outdated
Show resolved
Hide resolved
...m_records/assets/semantic-ui/js/invenio_rdm_records/src/deposit/fields/FileUploader/index.js
Outdated
Show resolved
Hide resolved
* Expose `RECORDS_RESOURCES_ALLOW_EMPTY_FILES` for UI control * Related to: inveniosoftware/invenio-rdm-records#1802
2b84f65
to
80bde7a
Compare
* Expose `RECORDS_RESOURCES_ALLOW_EMPTY_FILES` for UI control * Related to: inveniosoftware/invenio-rdm-records#1802
* Expose `RECORDS_RESOURCES_ALLOW_EMPTY_FILES` for UI control * Related to: inveniosoftware/invenio-rdm-records#1802
* Display a warning for empty files, indicating they won't be included and listing file names. * Feature controlled by `records-resources-allow-empty-files` config value. * Continue uploading other files while showing the warning message.
80bde7a
to
d6aab12
Compare
* Add the missing translation tags. * Refactor the logic to display multiple warning messages, while allowing other files to upload, except for case where exceeding the file size limit.
@ntarocco Since you wanted to improve readability, I've added a separate commit where I refactored the component. Now, the uploader continues uploading the rest of the files while showing warnings for duplicate files or empty files (was not possible before). I've also added other missing translations and small fixes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic improvement and very nice and readable implementation 👏🏼
* Expose `RECORDS_RESOURCES_ALLOW_EMPTY_FILES` for UI control * Related to: inveniosoftware/invenio-rdm-records#1802
* Expose `RECORDS_RESOURCES_ALLOW_EMPTY_FILES` for UI control * Related to: inveniosoftware/invenio-rdm-records#1802
📁 invenio-accounts (5.1.1 -> 5.1.2 🐛) release: v5.1.2 security: filter out current session if it's set to `None` * also, rename it to avoid controversial terminology dependencies: bump flask-security-invenio minimum 📁 invenio-app-rdm (13.0.0b1.dev3 -> 13.0.0b1.dev5 🌈) 📦 release: v13.0.0b1.dev5 deposit: Add allow-empty-files config available for deposit page * Expose `RECORDS_RESOURCES_ALLOW_EMPTY_FILES` for UI control * Related to: inveniosoftware/invenio-rdm-records#1802 deposit: provide permissions to publish button config: add group resolver for notifications admin-records: add reference to gh issue admin-records: account for system owned records migration: account for deleted communities and draft concept DOI css: added class for padding removal theme: fix accordion rotation template: mathjax remove from javascript block templates: add mathjax only to parent template landing page: support different MathJax delimeters search-result: namespace overridable id for community search results search-result: provide key to part of community array element fix: the following / prevents rspack from building release: v13.0.0b1.dev4 config: make OAI-PMH record index dynamic modal: fix record adding to a community * closes inveniosoftware/invenio-app-rdm#2821 📁 invenio-banners (3.1.0 -> 3.1.1 🐛) 📦 release: v3.1.1 admin: adjust descriptions of fields 📁 invenio-files-rest (2.2.0 -> 2.2.1 🐛) release: v2.2.1 fix: fix downloading for some weird filenames the following filenames couldn't be downloaded before: - is not `latin-1` encodable, ... - ...and contains a comma (`,`) character fix: apply invenio-accounts api changes 📁 invenio-jobs (0.5.0 -> 0.5.1 🐛) release: v0.5.1 fix: add compatibility layer to move to flask>=3 * flask-sqlalchemy moved pagination. * this change has been added to have a smooth migration to flask>=3.0.0 without creating a hard cut and major versions release. 📁 invenio-oaiserver (2.2.1 -> 2.2.2 🐛) 📦 release: v2.2.2 percolator: allow lazy strings from config 📁 invenio-oauthclient (4.0.0 -> 4.0.2 🐛) release: v4.0.2 views: fix boolean logic for checking remote app visibility release: v4.0.1 global: explicitly set and use hide attribute for config fix: add flag for auth in keycloak realm url 📁 invenio-pages (4.1.0 -> 4.1.1 🐛) release: v4.1.1 fix: add compatibility layer to move to flask>=3 * flask-sqlalchemy moved pagination. * this change has been added to have a smooth migration to flask>=3.0.0 without creating a hard cut and major versions release. 📁 invenio-rdm-records (12.1.0 -> 12.2.1 🌈) release: v12.2.1 deposit: check permission and set disable tooltip for publish button Refactor: Enhance Warnings Handling * Add the missing translation tags. * Refactor the logic to display multiple warning messages, while allowing other files to upload, except for case where exceeding the file size limit. UI: Handle empty file uploads in FileUploader * Display a warning for empty files, indicating they won't be included and listing file names. * Feature controlled by `records-resources-allow-empty-files` config value. * Continue uploading other files while showing the warning message. serializers: ensure values are not None before access release: v12.1.1 fixtures: allow to load new vocab resource: fix add record to community * Removes response_handler to avoid allowing to process the response with the schema * closes inveniosoftware/invenio-app-rdm#2821 controls: refactored isDisabled function * Refactored isDisabled function in PublishButton and SubmitReviewButton components to check if all files are finished uploading before enabling the button. * Passed filesState instead of just the number of files to the function. * Added a check for non-finished files. * Added early returns to avoid unnecessary checks on possible large objects / arrays. 📁 invenio-requests (5.0.0 -> 5.1.0 🌈) release: v5.1.0 assets: optimise detection if timeline was updated timeline feed: render mathematical content in the request comments 📁 invenio-theme (3.3.0 -> 3.4.0 🌈) release: v3.4.0 config: add MathJax support navbar: fix logo size in non-desktop devices css: updated table border style 📁 invenio-users-resources (6.0.0 -> 6.1.0 🌈) release: v6.1.0 users: services: Add can_read_all permission for admin search services: permissions: Use search_all config for admin user search CI: Switch To Centralised Workflows * Change branches type from string to array * Switch to centralised workflows 📁 invenio-vocabularies (5.0.2 -> 5.0.3 🐛) 📦 release: v5.0.3 services: skip index rebuilding
📁 invenio-accounts (5.1.1 -> 5.1.2 🐛) release: v5.1.2 security: filter out current session if it's set to `None` * also, rename it to avoid controversial terminology dependencies: bump flask-security-invenio minimum 📁 invenio-app-rdm (13.0.0b1.dev3 -> 13.0.0b1.dev5 🌈) 📦 release: v13.0.0b1.dev5 deposit: Add allow-empty-files config available for deposit page * Expose `RECORDS_RESOURCES_ALLOW_EMPTY_FILES` for UI control * Related to: inveniosoftware/invenio-rdm-records#1802 deposit: provide permissions to publish button config: add group resolver for notifications admin-records: add reference to gh issue admin-records: account for system owned records migration: account for deleted communities and draft concept DOI css: added class for padding removal theme: fix accordion rotation template: mathjax remove from javascript block templates: add mathjax only to parent template landing page: support different MathJax delimeters search-result: namespace overridable id for community search results search-result: provide key to part of community array element fix: the following / prevents rspack from building release: v13.0.0b1.dev4 config: make OAI-PMH record index dynamic modal: fix record adding to a community * closes inveniosoftware/invenio-app-rdm#2821 📁 invenio-banners (3.1.0 -> 3.1.1 🐛) 📦 release: v3.1.1 admin: adjust descriptions of fields 📁 invenio-files-rest (2.2.0 -> 2.2.1 🐛) release: v2.2.1 fix: fix downloading for some weird filenames the following filenames couldn't be downloaded before: - is not `latin-1` encodable, ... - ...and contains a comma (`,`) character fix: apply invenio-accounts api changes 📁 invenio-jobs (0.5.0 -> 0.5.1 🐛) release: v0.5.1 fix: add compatibility layer to move to flask>=3 * flask-sqlalchemy moved pagination. * this change has been added to have a smooth migration to flask>=3.0.0 without creating a hard cut and major versions release. 📁 invenio-oaiserver (2.2.1 -> 2.2.2 🐛) 📦 release: v2.2.2 percolator: allow lazy strings from config 📁 invenio-oauthclient (4.0.0 -> 4.0.2 🐛) release: v4.0.2 views: fix boolean logic for checking remote app visibility release: v4.0.1 global: explicitly set and use hide attribute for config fix: add flag for auth in keycloak realm url 📁 invenio-pages (4.1.0 -> 4.1.1 🐛) release: v4.1.1 fix: add compatibility layer to move to flask>=3 * flask-sqlalchemy moved pagination. * this change has been added to have a smooth migration to flask>=3.0.0 without creating a hard cut and major versions release. 📁 invenio-rdm-records (12.1.0 -> 12.2.1 🌈) release: v12.2.1 deposit: check permission and set disable tooltip for publish button Refactor: Enhance Warnings Handling * Add the missing translation tags. * Refactor the logic to display multiple warning messages, while allowing other files to upload, except for case where exceeding the file size limit. UI: Handle empty file uploads in FileUploader * Display a warning for empty files, indicating they won't be included and listing file names. * Feature controlled by `records-resources-allow-empty-files` config value. * Continue uploading other files while showing the warning message. serializers: ensure values are not None before access release: v12.1.1 fixtures: allow to load new vocab resource: fix add record to community * Removes response_handler to avoid allowing to process the response with the schema * closes inveniosoftware/invenio-app-rdm#2821 controls: refactored isDisabled function * Refactored isDisabled function in PublishButton and SubmitReviewButton components to check if all files are finished uploading before enabling the button. * Passed filesState instead of just the number of files to the function. * Added a check for non-finished files. * Added early returns to avoid unnecessary checks on possible large objects / arrays. 📁 invenio-requests (5.0.0 -> 5.1.0 🌈) release: v5.1.0 assets: optimise detection if timeline was updated timeline feed: render mathematical content in the request comments 📁 invenio-theme (3.3.0 -> 3.4.0 🌈) release: v3.4.0 config: add MathJax support navbar: fix logo size in non-desktop devices css: updated table border style 📁 invenio-users-resources (6.0.0 -> 6.1.0 🌈) release: v6.1.0 users: services: Add can_read_all permission for admin search services: permissions: Use search_all config for admin user search CI: Switch To Centralised Workflows * Change branches type from string to array * Switch to centralised workflows 📁 invenio-vocabularies (5.0.2 -> 5.0.3 🐛) 📦 release: v5.0.3 services: skip index rebuilding
📁 invenio-accounts (5.1.1 -> 5.1.2 🐛) release: v5.1.2 security: filter out current session if it's set to `None` * also, rename it to avoid controversial terminology dependencies: bump flask-security-invenio minimum This is for v12 as invenio-users-resources at least needs it https://github.com/inveniosoftware/invenio-users-resources/blob/master/invenio_users_resources/resources/users/resource.py#L15 and invenio-accounts is the controlling distribution package for that dependency. 📁 invenio-app-rdm (13.0.0b1.dev3 -> 13.0.0b1.dev5 🌈) 📦 release: v13.0.0b1.dev5 deposit: Add allow-empty-files config available for deposit page * Expose `RECORDS_RESOURCES_ALLOW_EMPTY_FILES` for UI control * Related to: inveniosoftware/invenio-rdm-records#1802 deposit: provide permissions to publish button config: add group resolver for notifications admin-records: add reference to gh issue admin-records: account for system owned records migration: account for deleted communities and draft concept DOI css: added class for padding removal theme: fix accordion rotation template: mathjax remove from javascript block templates: add mathjax only to parent template landing page: support different MathJax delimeters * closes CERNDocumentServer/cds-rdm#133 search-result: namespace overridable id for community search results search-result: provide key to part of community array element fix: the following / prevents rspack from building release: v13.0.0b1.dev4 config: make OAI-PMH record index dynamic modal: fix record adding to a community * closes inveniosoftware/invenio-app-rdm#2821 📁 invenio-banners (3.1.0 -> 3.1.1 🐛) 📦 release: v3.1.1 admin: adjust descriptions of fields 📁 invenio-files-rest (2.2.0 -> 2.2.1 🐛) release: v2.2.1 fix: fix downloading for some weird filenames the following filenames couldn't be downloaded before: - is not `latin-1` encodable, ... - ...and contains a comma (`,`) character fix: apply invenio-accounts api changes * This commit addresses compatibility issues caused by the recent API changes in the invenio-accounts module that is introduced in [this commit](inveniosoftware/invenio-accounts@5e1c583). It removes the usage of accounts_blueprint from invenio_files_rest and related tests, as it is no longer required and causes failures in the continuous integration (CI) tests. The change is aligned with the new release notes of invenio-accounts where this modification has been documented. * Upgrades Sphinx to >=5.0.0,<6.0.0 to address compatibility issues with Python 3.11. Removes deprecated 'formatargspec' from inspect, critical for Python 3.11 support and stability in our Invenio platform. 📁 invenio-jobs (0.5.0 -> 0.5.1 🐛) release: v0.5.1 fix: add compatibility layer to move to flask>=3 * flask-sqlalchemy moved pagination. * this change has been added to have a smooth migration to flask>=3.0.0 without creating a hard cut and major versions release. 📁 invenio-oaiserver (2.2.1 -> 2.2.2 🐛) 📦 release: v2.2.2 percolator: allow lazy strings from config 📁 invenio-oauthclient (4.0.0 -> 4.0.2 🐛) release: v4.0.2 views: fix boolean logic for checking remote app visibility release: v4.0.1 global: explicitly set and use hide attribute for config fix: add flag for auth in keycloak realm url 📁 invenio-pages (4.1.0 -> 4.1.1 🐛) release: v4.1.1 fix: add compatibility layer to move to flask>=3 * flask-sqlalchemy moved pagination. * this change has been added to have a smooth migration to flask>=3.0.0 without creating a hard cut and major versions release. 📁 invenio-rdm-records (12.1.0 -> 12.2.1 🌈) release: v12.2.1 deposit: check permission and set disable tooltip for publish button Refactor: Enhance Warnings Handling * Add the missing translation tags. * Refactor the logic to display multiple warning messages, while allowing other files to upload, except for case where exceeding the file size limit. UI: Handle empty file uploads in FileUploader * Display a warning for empty files, indicating they won't be included and listing file names. * Feature controlled by `records-resources-allow-empty-files` config value. * Continue uploading other files while showing the warning message. serializers: ensure values are not None before access release: v12.1.1 fixtures: allow to load new vocab resource: fix add record to community * Removes response_handler to avoid allowing to process the response with the schema * closes inveniosoftware/invenio-app-rdm#2821 controls: refactored isDisabled function * Refactored isDisabled function in PublishButton and SubmitReviewButton components to check if all files are finished uploading before enabling the button. * Passed filesState instead of just the number of files to the function. * Added a check for non-finished files. * Added early returns to avoid unnecessary checks on possible large objects / arrays. 📁 invenio-requests (5.0.0 -> 5.1.0 🌈) release: v5.1.0 assets: optimise detection if timeline was updated timeline feed: render mathematical content in the request comments * closes CERNDocumentServer/cds-rdm#133 📁 invenio-theme (3.3.0 -> 3.4.0 🌈) release: v3.4.0 config: add MathJax support * closes CERNDocumentServer/cds-rdm#133 navbar: fix logo size in non-desktop devices css: updated table border style 📁 invenio-users-resources (6.0.0 -> 6.1.0 🌈) release: v6.1.0 users: services: Add can_read_all permission for admin search services: permissions: Use search_all config for admin user search CI: Switch To Centralised Workflows * Change branches type from string to array * Switch to centralised workflows 📁 invenio-vocabularies (5.0.2 -> 5.1.0 🌈) 📦 release: v5.1.0 funders: tune search boost for acronyms * Add and `acronym.keyword` field to the funders mapping. * Apply to funders the same field boosting as in affiliations. 📦 release: v5.0.3 services: skip index rebuilding
❤️ Thank you for your contribution!
Description
records-resources-allow-empty-files
config value.Checklist
Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:
Frontend
Reminder
By using GitHub, you have already agreed to the GitHub’s Terms of Service including that: