-
Notifications
You must be signed in to change notification settings - Fork 3
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
feat(upload): add upload button functionality #176
Conversation
Azure Static Web Apps: Your stage site is ready! Visit it here: https://black-sand-0b0e2a903-176.westeurope.3.azurestaticapps.net |
Coverage Report
|
794a3eb
to
37b73a3
Compare
Azure Static Web Apps: Your stage site is ready! Visit it here: https://black-sand-0b0e2a903-176.westeurope.3.azurestaticapps.net |
Azure Static Web Apps: Your stage site is ready! Visit it here: https://black-sand-0b0e2a903-176.westeurope.3.azurestaticapps.net |
Azure Static Web Apps: Your stage site is ready! Visit it here: https://black-sand-0b0e2a903-176.westeurope.3.azurestaticapps.net |
Azure Static Web Apps: Your stage site is ready! Visit it here: https://black-sand-0b0e2a903-176.westeurope.3.azurestaticapps.net |
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 cannot comment more =)
if (item.kind === "file") { | ||
const file = item.getAsFile(); | ||
if (file) { | ||
handleExperimentFileUpload(file) | ||
} | ||
} | ||
}); | ||
} else { | ||
[...ev.dataTransfer.files].forEach((file) => { | ||
handleExperimentFileUpload(file) |
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.
What this means is "I drop something, if some of these are files, I upload each of them separately", else "if I dropped a collection of files, upload them separately". How may this happen that dropped objects are in one of the collections?
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.
It's based to cover older APIs for older chrome versoins or IE, also seemsdataTransfer.files
is deprecated.
So I can just not include it.
const { handleExperimentFileUpload } = useFileUpload(experimentUuid) | ||
function handleChangeFile(e: ChangeEvent<HTMLInputElement>) { | ||
if (e.target.files) { | ||
[...e.target.files].forEach(file => { |
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.
Looks like a code duplication
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.
It's actually not.
This is when using onChange
function in <input />
and the one above is for onDrop
function when doing Drag and Drop.
Why it's not? Because the Event
in these two is different, we need to get the file and then use handleUpload
function to upload them.
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 @safeamiiir, looks good, waiting to see it in action
Azure Static Web Apps: Your stage site is ready! Visit it here: https://black-sand-0b0e2a903-176.westeurope.3.azurestaticapps.net |
Azure Static Web Apps: Your stage site is ready! Visit it here: https://black-sand-0b0e2a903-176.westeurope.3.azurestaticapps.net |
Uncomment upload button and let users upload files for experiments