Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

hide profile menu item #42

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/components/NavBar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ const NavBar = ({ hideSwitchTools }) => {
auth.profile && (
<Fragment>
{hideSwitchTools ? null : <NotificationsMenu />}
<UserMenu profile={auth.profile} />
<UserMenu
profile={auth.profile}
hideSwitchTools={hideSwitchTools}
/>
</Fragment>
)
) : (
Expand All @@ -110,7 +113,10 @@ const NavBar = ({ hideSwitchTools }) => {
auth.profile && (
<Fragment>
{hideSwitchTools ? null : <NotificationsMenu />}
<UserMenu profile={auth.profile} />
<UserMenu
profile={auth.profile}
hideSwitchTools={hideSwitchTools}
/>
</Fragment>
)
) : (
Expand Down
26 changes: 20 additions & 6 deletions src/components/UserMenu/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
*/
import React, { useState, useCallback, Fragment } from "react";
import { Link } from "@reach/router";
import PropTypes from "prop-types";
import Avatar from "../Avatar";
import cn from "classnames";
import OutsideClickHandler from "react-outside-click-handler";
import { logout, getLogoutUrl } from "../../utils";
import "./styles.css";
import { useMediaQuery } from "react-responsive";

const UserMenu = ({ profile }) => {
const UserMenu = ({ profile, hideSwitchTools }) => {
const [isOpenMenu, setIsOpenMenu] = useState(false);

const closeMenu = useCallback(() => {
Expand Down Expand Up @@ -63,11 +64,16 @@ const UserMenu = ({ profile }) => {
<div className="user-menu-popover-arrow" />
<div className="user-menu-popover-content">
<ul className="user-menu-list">
<li>
<Link to={`/profile/${profile.handle}`} onClick={closeMenu}>
Profile
</Link>
</li>
{hideSwitchTools ? null : (
<li>
<Link
to={`/profile/${profile.handle}`}
onClick={closeMenu}
>
Profile
</Link>
</li>
)}
<li>
<a href={getLogoutUrl()} onClick={onLogoutClick}>
Log Out
Expand All @@ -83,4 +89,12 @@ const UserMenu = ({ profile }) => {
);
};

UserMenu.defaultProps = {
hideSwitchTools: false,
};

UserMenu.propTypes = {
hideSwitchTools: PropTypes.boolean,
};

export default UserMenu;