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

Commit ac22d0e

Browse files
authored
Merge pull request #42 from nursoltan-s/hide-profile-menu-item
hide profile menu item
2 parents b8eead5 + f310b4c commit ac22d0e

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

src/components/NavBar/index.jsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ const NavBar = ({ hideSwitchTools }) => {
9292
auth.profile && (
9393
<Fragment>
9494
{hideSwitchTools ? null : <NotificationsMenu />}
95-
<UserMenu profile={auth.profile} />
95+
<UserMenu
96+
profile={auth.profile}
97+
hideSwitchTools={hideSwitchTools}
98+
/>
9699
</Fragment>
97100
)
98101
) : (
@@ -110,7 +113,10 @@ const NavBar = ({ hideSwitchTools }) => {
110113
auth.profile && (
111114
<Fragment>
112115
{hideSwitchTools ? null : <NotificationsMenu />}
113-
<UserMenu profile={auth.profile} />
116+
<UserMenu
117+
profile={auth.profile}
118+
hideSwitchTools={hideSwitchTools}
119+
/>
114120
</Fragment>
115121
)
116122
) : (

src/components/UserMenu/index.jsx

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
*/
66
import React, { useState, useCallback, Fragment } from "react";
77
import { Link } from "@reach/router";
8+
import PropTypes from "prop-types";
89
import Avatar from "../Avatar";
910
import cn from "classnames";
1011
import OutsideClickHandler from "react-outside-click-handler";
1112
import { logout, getLogoutUrl } from "../../utils";
1213
import "./styles.css";
1314
import { useMediaQuery } from "react-responsive";
1415

15-
const UserMenu = ({ profile }) => {
16+
const UserMenu = ({ profile, hideSwitchTools }) => {
1617
const [isOpenMenu, setIsOpenMenu] = useState(false);
1718

1819
const closeMenu = useCallback(() => {
@@ -63,11 +64,16 @@ const UserMenu = ({ profile }) => {
6364
<div className="user-menu-popover-arrow" />
6465
<div className="user-menu-popover-content">
6566
<ul className="user-menu-list">
66-
<li>
67-
<Link to={`/profile/${profile.handle}`} onClick={closeMenu}>
68-
Profile
69-
</Link>
70-
</li>
67+
{hideSwitchTools ? null : (
68+
<li>
69+
<Link
70+
to={`/profile/${profile.handle}`}
71+
onClick={closeMenu}
72+
>
73+
Profile
74+
</Link>
75+
</li>
76+
)}
7177
<li>
7278
<a href={getLogoutUrl()} onClick={onLogoutClick}>
7379
Log Out
@@ -83,4 +89,12 @@ const UserMenu = ({ profile }) => {
8389
);
8490
};
8591

92+
UserMenu.defaultProps = {
93+
hideSwitchTools: false,
94+
};
95+
96+
UserMenu.propTypes = {
97+
hideSwitchTools: PropTypes.boolean,
98+
};
99+
86100
export default UserMenu;

0 commit comments

Comments
 (0)