summaryrefslogtreecommitdiff
path: root/src/components/navigation
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/navigation')
-rw-r--r--src/components/navigation/Navbar.js46
1 files changed, 29 insertions, 17 deletions
diff --git a/src/components/navigation/Navbar.js b/src/components/navigation/Navbar.js
index c0c8c006..e621b1e4 100644
--- a/src/components/navigation/Navbar.js
+++ b/src/components/navigation/Navbar.js
@@ -8,6 +8,7 @@ import ProfileName from "../../containers/auth/ProfileName";
import "./Navbar.css";
export const NavItem = withRouter(props => <NavItemWithoutRoute {...props}/>);
+export const LoggedInSection = withRouter(props => <LoggedInSectionWithoutRoute {...props}/>);
const NavItemWithoutRoute = ({route, location, children}) => (
<li className={classNames("nav-item", location.pathname === route ? "active" : undefined)}>
@@ -15,6 +16,33 @@ const NavItemWithoutRoute = ({route, location, children}) => (
</li>
);
+const LoggedInSectionWithoutRoute = ({location}) => (
+ <ul className="navbar-nav auth-links">
+ {userIsLoggedIn() ?
+ [
+ location.pathname === "/" ?
+ <NavItem route="/simulations" key="simulations">
+ <Link className="nav-link" title="My Simulations" to="/simulations">
+ My Simulations
+ </Link>
+ </NavItem> :
+ <NavItem route="/profile" key="profile">
+ <Link className="nav-link" title="My Profile" to="/profile">
+ <ProfileName/>
+ </Link>
+ </NavItem>,
+ <NavItem route="logout" key="logout">
+ <Logout/>
+ </NavItem>
+ ] :
+ <NavItem route="login">
+ <Login visible={true}/>
+ </NavItem>
+ }
+ </ul>
+ )
+;
+
const Navbar = ({children}) => (
<nav className="navbar fixed-top navbar-expand-lg navbar-light bg-faded" id="navbar">
<div className="container">
@@ -31,23 +59,7 @@ const Navbar = ({children}) => (
<ul className="navbar-nav mr-auto">
{children}
</ul>
- <ul className="navbar-nav">
- {userIsLoggedIn() ?
- [
- <NavItem route="/profile">
- <Link className="username nav-link" title="My Profile" to="/profile">
- <ProfileName/>
- </Link>
- </NavItem>,
- <NavItem route="logout">
- <Logout/>
- </NavItem>
- ] :
- <NavItem route="login">
- <Login visible={true}/>
- </NavItem>
- }
- </ul>
+ <LoggedInSection/>
</div>
</div>
</nav>