-
Notifications
You must be signed in to change notification settings - Fork 31
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
Add support for new attachment API and improve UX for error messages #2754
Conversation
|
@bjosttveit Some questions before I go into reviewing the actual code:
Will it handle failures, then? What about timeouts, i.e. you internet speed drops to zero (or you upload a gigantic attachment). Will you risk losing out on that state update for previously uploaded attachments if you (for example) navigate to another page in the meantime?
Will you still be able to see the full filename on hover?
Nice! Should this be a button instead of a link, maybe? 🤔 |
The upload itself should not throw any uncaught exceptions. The promise for uploading each file has a
What do you mean by navigate to another page? Navigating within the app should not affect things. The FileUpload component simply calls the (async) function without awaiting it or expecting a return value. All of the state updates are handled by the attachmentplugin (store) and propagate back to the component through hooks (as it was before). Navigating away (like refreshing) will maybe cancel pending requests? But you would also get the updated form data for what has already completed when loading I guess.
Yes
It is a button 😄 (variant tertiary) |
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.
Good stuff! 💪
Description
Will now use the new attachment API if the backend version is up to date. Since the new API can make changes to form data, validations, and instance data we have to upload attachments in series instead of in parallel (if multiple are selected at the same time) to prevent race conditions. However, it will gather all of the changes and update the state only once at the end. This could really use some cypress tests to verify that form data etc. is updated correctly, but its a lot of set up, and I cannot spend that much more time on this right now.
Errors with uploading a file is no longer showed in a toster (only if you drag more files than allowed, you still get a toaster saying you selected too many files), but is shown below the fileupload component, the user needs to close the alert for it to disappear. Attachments which fail to upload are stored in the node-state instead of the react-component's state so that they don't disappear when switching pages. It will however disappear on refresh since nothing gets stored in the backend.
This, together with Altinn/app-lib-dotnet#850 deals with some of the issues in #2706. Specifically, enabling updating the form data / validations and the app frontend getting these changes as well as improved UX for error messages that caused the upload to be rejected.
This is what it looks like now. Long filenames are truncated in the middle.
If there are multiple issues with an attachment, it will be shown as a list. If there are more than 3 issues you have to expand to show them all so that it does not immediately take up a lot of space if the list is very long.
Related Issue(s)
Verification/QA
kind/*
label to this PR for proper release notes grouping