Skip to content
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

In amazon s3 #55

Merged
merged 10 commits into from
Jun 16, 2021
Merged

In amazon s3 #55

merged 10 commits into from
Jun 16, 2021

Conversation

g4rry420
Copy link
Collaborator

@g4rry420 g4rry420 commented Jun 10, 2021

What this PR does (required):

Screenshots / Videos (required):

file_upload

Any information needed to test this feature (required):

  • Go to /settings url and navigate to Profile Photo tab to test this feature.

Any issues with the current functionality (optional):

No

g4rry420 added 5 commits June 8, 2021 03:02
Signed-off-by: gurkiran_singh <gurkiransinghk@gmail.com>
Signed-off-by: gurkiran_singh <gurkiransinghk@gmail.com>
Signed-off-by: gurkiran_singh <gurkiransinghk@gmail.com>
Signed-off-by: gurkiran_singh <gurkiransinghk@gmail.com>
Signed-off-by: gurkiran_singh <gurkiransinghk@gmail.com>
@g4rry420 g4rry420 linked an issue Jun 10, 2021 that may be closed by this pull request
g4rry420 added 2 commits June 10, 2021 15:22
Signed-off-by: gurkiran_singh <gurkiransinghk@gmail.com>
Signed-off-by: gurkiran_singh <gurkiransinghk@gmail.com>
@g4rry420 g4rry420 mentioned this pull request Jun 14, 2021
Copy link

@bonnieli bonnieli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, just some readability and rewriting some repeated code comments.

in addition looks like you're disabling a lot of eslint warnings - what is currently the warning?

setImgSrc(src);
const { updateSnackBarMessage } = useSnackBar();
const handleImageUpload = (event: ChangeEvent<HTMLInputElement>): void => {
if (userState.background === '' && event.target.files?.length) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe store event.target.files in a variable - you're accessing it multiple times in this block

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will do that.

if (userState.background === '' && event.target.files?.length) {
const background = URL.createObjectURL(event.target.files[0]);
dispatchUserContext({ type: 'UPLOAD_BACKGROUND', background });
// eslint-disable-next-line

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is currently the eslint issue here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forbidden non-null assertion @typescript-eslint/no-non-null-assertion

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is resolved when I store event.target.files in a variable.

Signed-off-by: gurkiran_singh <gurkiransinghk@gmail.com>
Comment on lines 45 to 46
// eslint-disable-next-line
const handleTabIndexChange = (event: any, newValue: number): void => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to assume you are disabling the 'no-implicit-any' warning here. I would suggest to add a type to that event and remove the eslint warning that way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I didn't specify type of this is because this is backlog issue with material-ui. However, I guess I can specify this type ChangeEvent<{}> but then this type gives me these errors:

  Line 46:52:  Don't use `{}` as a type. `{}` actually means "any non-nullish value".
- If you want a type meaning "any object", you probably want `Record<string, unknown>` instead.
- If you want a type meaning "any value", you probably want `unknown` instead.
- If you want a type meaning "empty object", you probably want `Record<string, never>` instead  @typescript-eslint/ban-types

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would take a look at where you are firing the event and it generally gives you an idea of what the type should look like. Event types are tricky in React, I tend to just start at the source of where I am firing this event and then copy what I see in my editor.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you seen the MUI contributors comment here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I have tried the SyntheticEvent but it doesn't work. But following your advise, I looked at the console.log of event and found out that the event type is BaseSyntheticEvent. Thank you for your help.

Comment on lines +34 to +41
// store locationUrl in Database;
const locationUrl = data.Location;
locationUrls.push({ locationUrl, key: data.key })
if (locationUrls.length === fieldNames.length) {
return res.status(201).json({
locationUrls,
success: "File are saved successfully."
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see a comment about adding it to the database but there is no persisting the location urls to the profile model. Also, what if a user wants to just upload a profile photo? Right now on the front-end it requires them to upload a background image then a profile image. For a UX perspective this is not ideal.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I have handle the usecase for location urls in #57 pr.
Also, I understand that this is not a very good UX experience. Initially, I wanted to do something like this. But material ui doesn't support this right now. What I can do is provide a radio button to user to choose which image they want to upload. It's not very good UX, but it will decent one. What are your thoughts on this ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's something that can be addressed later, I would do some further research into potential solution here. I will say, Material UI is not blocking this feature from happening. But, feel free to visit this later.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, okay.

Copy link
Contributor

@moffatethan moffatethan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's looking good, I left some comments on your PR to address.

Signed-off-by: gurkiran_singh <gurkiransinghk@gmail.com>
@g4rry420
Copy link
Collaborator Author

@moffatethan I have made the changes. Please let me know about them.

@g4rry420 g4rry420 requested a review from moffatethan June 16, 2021 20:12
@@ -30,6 +30,7 @@ export default function Dashboard(): JSX.Element {
return (
<Grid container component="main" className={`${classes.root} ${classes.dashboard}`}>
<CssBaseline />
<Link to="/settings">Profile</Link>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't this be in the AuthNavbar?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will do

Copy link
Contributor

@moffatethan moffatethan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me, before merging if you could take a look into the placement of the settings link and move it to a more suitable file such as AuthNavbar. Thank you!

Signed-off-by: gurkiran_singh <gurkiransinghk@gmail.com>
@g4rry420 g4rry420 merged commit f56f6a6 into main Jun 16, 2021
@g4rry420 g4rry420 deleted the IN_amazon_s3 branch June 16, 2021 21:40
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.

IN: Amazon S3
3 participants