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

feat(React): Avatar dropdown menu and logout function #2115

Merged
merged 3 commits into from
Feb 18, 2021
Merged

feat(React): Avatar dropdown menu and logout function #2115

merged 3 commits into from
Feb 18, 2021

Conversation

brendansun93
Copy link
Contributor

@brendansun93 brendansun93 commented Feb 17, 2021

Scope
This PR changes all page that includes the header bar.

Changes
This PR adds new feature which pops up a menu when hovering on profile on top right corner of the page. Currently, there is only 1 option, that is to log out. After this option is clicked, user session is cleared and users are redirected to the login page.

This PR also contains a overwritten changes in #2095 where multiple clicking on the profile will redirect users to url like "user/user/user/user/..."
Screenshot from 2021-02-17 16-39-54

Checklist

  • The PR conforms to DataHub's Contributing Guideline (particularly Commit Message Format)
  • Links to related issues (if applicable)
  • Tests for the changes have been added/updated (if applicable)
  • Docs related to the changes have been added/updated (if applicable)

@brendansun93
Copy link
Contributor Author

@gabe-lyons @jjoyce0510 @shirshanka
Please review

Comment on lines 41 to 43
if (!isLoggedIn) {
return <Redirect to="/login" />;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

do you need this redirect? Each page is wrapped in a ProtectedRoute component which should be doing this redirect for you

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, this is removed now.

/>
</Link>
<Dropdown overlay={menu}>
<Link to={`/${entityRegistry.getPathName(EntityType.CorpUser)}/${_urn}`}>
Copy link
Contributor

Choose a reason for hiding this comment

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

nice re-fix 👍

Copy link
Contributor

@gabe-lyons gabe-lyons left a comment

Choose a reason for hiding this comment

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

looks great, thanks @brendansun. I do think you may be able to remove the redirect logic though.

const isLoggedIn = checkAuthStatus();

const handleLogout = () => {
Cookies.remove('PLAY_SESSION');
Copy link
Contributor

Choose a reason for hiding this comment

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

technically, this line isn't doing anything. the play cookie is http only, so js isn't able to read or write it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line is removed now.

@brendansun93
Copy link
Contributor Author

@gabe-lyons Comments resolved, please review again. Thanks!

Copy link
Contributor

@gabe-lyons gabe-lyons left a comment

Choose a reason for hiding this comment

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

perfect 🚀

Copy link
Contributor

@shirshanka shirshanka left a comment

Choose a reason for hiding this comment

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

LGTM!
Although we never want people to log out of DataHub :)

@shirshanka shirshanka merged commit 65b231c into datahub-project:master Feb 18, 2021
@brendansun93 brendansun93 deleted the avatar-dropdown-logout branch February 18, 2021 19:57
@jjoyce0510
Copy link
Collaborator

Thanks Brendan!

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.

5 participants