-
Notifications
You must be signed in to change notification settings - Fork 73
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: add file upload component and refactor fetch to work with formData (#2274) #4742
Conversation
throw new Error('Failed to fetch public files ' + (err?.message || '')); | ||
}, | ||
}); | ||
const [uploadError, setUploadError] = useState(null); |
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.
@apburnes i know it looks like a lot, but this handles dismissing the alerts (both error and success) after a set duration. I havent added a dismiss click yet.
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.
That's ok for this PR. Once we pickup the alert mgmt issue, we will pull this into a separate hook.
setFolderName(''); | ||
setShowFolderNameField(false); | ||
} catch (error) { | ||
setErrorMessage(error.message || 'Failed to create folder.'); |
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.
ffee6ae
to
84018e0
Compare
🤖 This is an automated code coverage reportTotal coverage (lines): 27.1% |
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 good. In subsequent PR's we will refactor the alerting and I had a question about the request content type after we delete the headers for upload.
throw new Error('Failed to fetch public files ' + (err?.message || '')); | ||
}, | ||
}); | ||
const [uploadError, setUploadError] = useState(null); |
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.
That's ok for this PR. Once we pickup the alert mgmt issue, we will pull this into a separate hook.
if (baseConfigs.headers['content-type'] === 'multipart/form-data') { | ||
requestBody = configs.body; | ||
// browser must set this for FormData | ||
delete baseConfigs.headers['content-type']; |
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.
After an upload, do the following requests have the content-type
set to application/json
?
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.
they'd get defaultHeaders
again which includes 'content-type': 'application/json'
, unless they have been explicitly given 'content-type'='something-else'
FWIW i think these are supposed to be capitalized "Content-Type"
but assumed yall had a reason for the lowercase
84018e0
to
d55aae1
Compare
d55aae1
to
86c18e4
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.
💯 We went over next steps and outlined future issues to build on this upload functionality.
Changes proposed in this pull request:
@shared
, with onUpload, onCancel, and triggerOnMount props for use elsewheresecurity considerations