Skip to content

Cleanup of uploader code #2244

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

Merged
merged 4 commits into from
Jun 22, 2023
Merged

Conversation

lindapaiste
Copy link
Collaborator

@lindapaiste lindapaiste commented Jun 12, 2023

Changes:

  • Convert the FileUploader to a function component.
  • Call the .destroy() method when the component unmounts. This prevents the form HTML from getting added to the page multiple times when the modal is closed and re-opened. The duplicated HTML is no longer an issue after Fix: upload modal closes when clicking inside #2245. Still seems like a good idea to cleanup.
  • Move some (but not all) styling from CSS to JS.
  • The accept and sending callbacks don't involve Redux at all so I think it's weird to dispatch them (though it does work just fine). I'm calling them as plain functions instead.
  • Turn the repeated if condition into a utility function isS3Upload.
  • Delete the localIntercept function which uses FileReader. We can use .text() method on the file object which is the newer approach.
  • Convert the accept function syntax from Promise.then to async/await.
  • Remove the complicated if condition from the error branch with the magic of the optional chaining ?.
  • Delete the hidden inputs which set the attachments[] field on the form. I can't see why we would need this and it works without it. The Dropzone already includes the binary data in the form under the file property. Pinging @catarak - maybe she knows why it's there. It's possible that it used to be necessary but isn't anymore.

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • has no test errors (npm run test)
  • is from a uniquely-named feature branch and is up to date with the develop branch.
  • is descriptively named and links to an issue number, i.e. Fixes #123

@lindapaiste lindapaiste marked this pull request as draft June 12, 2023 03:09
@lindapaiste lindapaiste marked this pull request as ready for review June 12, 2023 16:11
@raclim
Copy link
Collaborator

raclim commented Jun 22, 2023

Thanks so much for working on this! I'm not too sure what might've been happening with the hidden inputs either, but I also think it should be fine without it?

I'll merge in #2245 right after as well, and then do the next release :)

@raclim raclim merged commit 185b8b2 into processing:develop Jun 22, 2023
@lindapaiste lindapaiste deleted the refactor/uploader branch July 19, 2023 23:03
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