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

Combine edit profile and edit home in one page with tabs #1200

Merged
merged 30 commits into from May 27, 2021

Conversation

thdk
Copy link
Member

@thdk thdk commented May 9, 2021

It closes #949 at least partially and is the start of some changes to the profile pages to better match the design from figma.

There now is a single page with two tabs. One tab for 'about' and another one for 'home'. I've added routes so you can directly navigate to a specific tab. Also after saving the form, you'll be redirected to the related view with the updated information.

BREAKING CHANGE: the username is now REQUIRED in profile urls.

Example routes:
user/aapeli
user/aapeli/about (same as user/aapeli)
user/aapeli/home
user/edit/aapeli
user/edit/aapeli/home
user/edit/aapeli/about (same as user/edit/aapeli)

When current route is user/aapeli/home and user clicks the 'edit' button,
then user the route is changed to user/edit/aapeli/home.
Next when the user clicks 'save', the route is changed again to user/aapeli/home.

So you stay on the profile section you were editing/viewing.

Let me know if this is not what we want, I have little experience with best practices for routes.
My argument for having the user id in the url is:

  • you won't have issues if there is a user that uses 'edit', 'home' or 'about' as username
  • users can copy paste their url from their profile page and send it to other people.

Regarding the Account Settings button. There is an option to add the account settings as another tab on the edit profile page. However, @ItsiW said it actually belongs in the hamburger menu so I left it as is for now. On the top right of the edit profile page.

Frontend checklist

  • Formatted my code with yarn format && yarn lint --fix
  • There are no warnings from yarn lint
  • There are no console warnings when running the app
  • Added any new components to storybook
  • Added tests where relevant
    => I can probably still write (or copy) the existing test that we now have for edit hosting preferences for edit profile tab.
  • All tests pass
  • Clicked around my changes running locally and it works
  • Checked Desktop, Mobile and Tablet screen sizes

thdk added 3 commits May 9, 2021 19:13
BREAKING CHANGE: the username is now REQUIRED in profile urls.

Example routes:
user/aapeli
user/aapeli/about (same as user/aapeli)
user/aapeli/home
user/edit/aapeli
user/edit/aapeli/home
user/edit/aapeli/about (same as user/edit/aapeli)

When current route is user/aapeli/home and user clicks the 'edit' button,
then user the route is changed to user/edit/aapeli/home.
Next when the user clicks 'save', the route is changed again to user/aapeli/home.

So you stay on the profile section you were editing/viewing."
@thdk thdk requested a review from a team May 9, 2021 18:27
Copy link
Member

@lucaslcode lucaslcode left a comment

Choose a reason for hiding this comment

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

This is much better, thanks!

app/frontend/src/routes.ts Outdated Show resolved Hide resolved
app/frontend/src/routes.ts Outdated Show resolved Hide resolved
app/frontend/src/components/Navigation/Navigation.tsx Outdated Show resolved Hide resolved
app/frontend/src/components/Navigation/Navigation.tsx Outdated Show resolved Hide resolved
app/frontend/src/features/profile/edit/EditProfilePage.tsx Outdated Show resolved Hide resolved
app/frontend/src/features/profile/edit/EditProfilePage.tsx Outdated Show resolved Hide resolved
app/frontend/src/features/profile/edit/EditProfilePage.tsx Outdated Show resolved Hide resolved
app/frontend/src/features/profile/view/Overview.tsx Outdated Show resolved Hide resolved
ItsiW
ItsiW previously requested changes May 10, 2021
Copy link
Member

@ItsiW ItsiW 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, waaay cleaner now. But we need username to not be required in URLs.

For your first point, we can prevent specific usernames in the backend. Good point on wanting to share profile, we can satisfy this and the requirement with:

  • /user/ redirects to /user/aapeli
  • /user/about redirects to /user/aapeli/about
  • /user/home redirects to /user/aapeli/home

The reason for this is that we link to profile and editing pages in a number of places so that needs to be generic.

I don't think either point applies to edit now. The only use case for sharing is people showing others how to edit their own profile, so it would be better not to have the username in that URL at all. It's sufficient to just have

  • /user/edit
  • /user/edit/about
  • /user/edit/home

Also, and might just be a me thing, I couldn't see the About/Home tabs immediately. Could be a question for UX because I understand we want to be consistent.

@darrenvong
Copy link
Member

Agreed with what's said here already. In particular, we shouldn't have user/edit/<username> as that creates a lot of impossible URLs a normal user won't have access to (since the URL implies they can edit another user when they can't) so I think the best thing is to not have them altogether.

@thdk
Copy link
Member Author

thdk commented May 11, 2021

Wow, you are all very fast with reviewing! 👍

I've already adjusted the routing issues and will continue the other remarks as well as merging develop branch tonight.

@aapeliv
Copy link
Member

aapeliv commented May 14, 2021

Hi, just a heads up, if you change the routes, please remember to fix up also //docs/urls.md and //app/backend/src/couchers/urls.py. There's a bunch of onboarding emails going out on Sunday, so I just want to make sure they don't lead to 404s!

@lucaslcode
Copy link
Member

I'm assuming this is ready for review now - remember to request so we know! :)

Copy link
Member

@lucaslcode lucaslcode left a comment

Choose a reason for hiding this comment

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

Nice work!

There's a variable accidental rename and just a few other nits

app/frontend/src/features/profile/edit/EditProfilePage.tsx Outdated Show resolved Hide resolved
app/frontend/src/routes.ts Outdated Show resolved Hide resolved
app/frontend/src/routes.ts Outdated Show resolved Hide resolved
app/frontend/src/routes.ts Outdated Show resolved Hide resolved
app/frontend/src/routes.ts Outdated Show resolved Hide resolved
@thdk
Copy link
Member Author

thdk commented May 15, 2021

@aapeliv @darrenvong @lucaslcode thank you all for reviewing.

I'm still busy with this PR. I had some trouble on finding the best routes with optional usernames.

/User/home (for route user/username?/tab?)

Still don't know how the frontend can now for such route whether 'home' is a user or a tab on the profile page.

Except for hardcoding something like:

const user,tab = useParams()

If user === home || user === about
tab = user
user = undefined
end if

This long weekend I was visiting my family in law in Czechia so I pushed my changes already in case I would have some spare time here :)

This week Ill have some more time again. I'll work on your feedback and add tests.

@thdk
Copy link
Member Author

thdk commented May 17, 2021

Hi, just a heads up, if you change the routes, please remember to fix up also //docs/urls.md and //app/backend/src/couchers/urls.py. There's a bunch of onboarding emails going out on Sunday, so I just want to make sure they don't lead to 404s!

Ah didn't know about these, so good that you mentioned it. I've added the new routes to both these files. But not sure if they should support the 'tab' parameter as well. Let me know if changes are required.

root and others added 4 commits May 17, 2021 21:33
The typescript overloads were a little overkill here indeed. Having two seperate functions greatly simplifies it.
@darrenvong
Copy link
Member

Screenshot 2021-05-17 at 22 44 12
Visiting other profiles is completely broken - the URL says "aapeli" but it's still showing the test user's profile and it seems to the same for all profiles

app/frontend/src/components/TabBar/TabBar.tsx Outdated Show resolved Hide resolved
app/frontend/src/components/TabBar/TabBar.tsx Outdated Show resolved Hide resolved
@aapeliv
Copy link
Member

aapeliv commented May 23, 2021

@thdk: how're you doing on this one?

@thdk
Copy link
Member Author

thdk commented May 23, 2021 via email

@thdk thdk requested a review from darrenvong May 24, 2021 17:56
Copy link
Member

@darrenvong darrenvong left a comment

Choose a reason for hiding this comment

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

The TabBar thing is minor really and I was happy to leave it if there wasn't anything else... but since your merge here is introducing a bug by replacing the user invalidation on save (by accident I hope!), thought I'll point it out as you might as well fix both together

@thdk thdk requested a review from darrenvong May 25, 2021 11:27
Copy link
Member

@darrenvong darrenvong left a comment

Choose a reason for hiding this comment

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

Sorry I didn't review this as quickly, there's also a merge conflict with develop now but hopefully this should be it once fixed 🤞

app/frontend/src/features/constants.ts Outdated Show resolved Hide resolved
@thdk thdk requested a review from darrenvong May 27, 2021 07:13
darrenvong
darrenvong previously approved these changes May 27, 2021
@darrenvong darrenvong dismissed their stale review May 27, 2021 18:37

More merge conflicts need to be fixed :(

Copy link
Member

@lucaslcode lucaslcode left a comment

Choose a reason for hiding this comment

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

There shouldn't have been prettier issues - I just updated prettier. Try running yarn && yarn format

@thdk
Copy link
Member Author

thdk commented May 27, 2021

There shouldn't have been prettier issues - I just updated prettier. Try running yarn && yarn format

Auch, now I have even more changes.. I'll commit them so you can see if that's normal.

@thdk thdk dismissed ItsiW’s stale review May 27, 2021 19:28

user id is not required anymore

@thdk thdk merged commit 8080da7 into develop May 27, 2021
@thdk thdk deleted the frontend/feature/edit-profile-1 branch May 27, 2021 19:29
@thdk thdk mentioned this pull request May 28, 2021
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Combine edit profile and edit home into one page
5 participants