Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | 172x 179x 179x 179x 179x | import React from "react";
import { Link } from "react-router";
import { Navbar, Nav, NavDropdown, Container, Button } from "react-bootstrap";
import { useSystemInfo } from "main/utils/systemInfo";
import { hasRole } from "main/utils/useCurrentUser";
function AppNavbarLocalhost() {
return (
<Navbar.Text data-testid="AppNavbarLocalhost" className="me-3">
<span data-testid="AppNavbarLocalhost-message1">
Running on http://localhost:3000/ with no backend.
</span>
<br />
<span data-testid="AppNavbarLocalhost-message2">
You probably want http://localhost:8080 instead.
</span>
</Navbar.Text>
);
}
export default function AppNavbar({
currentUser,
systemInfo,
doLogout,
oauthLogin = "/oauth2/authorization/google",
}) {
const systemInfoFromHook = useSystemInfo();
const systemInfoData = systemInfo || systemInfoFromHook;
const isLocalhost =
(window.location.hostname === "localhost" ||
window.location.hostname === "127.0.0.1") &&
window.location.port === "3000";
return (
<Navbar bg="dark" variant="dark" expand="lg" data-testid="AppNavbar">
<Container>
<Navbar.Brand as={Link} to="/">
Team02
</Navbar.Brand>
<Navbar.Toggle aria-controls="basic-navbar-nav" />
<Navbar.Collapse id="basic-navbar-nav">
<Nav className="me-auto">
{currentUser && currentUser.loggedIn && (
<>
<Nav.Link as={Link} to="/ucsbdates">
UCSB Dates
</Nav.Link>
<Nav.Link as={Link} to="/restaurants">
Restaurants
</Nav.Link>
<Nav.Link as={Link} to="/diningcommonsmenuitem">
UCSBDiningCommonsMenuItem
</Nav.Link>
<Nav.Link as={Link} to="/ucsborganizations">
UCSB Organizations
</Nav.Link>
<Nav.Link as={Link} to="/menuItemReviews">
Menu Item Reviews
</Nav.Link>
<Nav.Link as={Link} to="/articles">
Articles
</Nav.Link>
<Nav.Link as={Link} to="/recommendationrequest">
Recommendation Request
</Nav.Link>
<Nav.Link as={Link} to="/placeholder">
Placeholder
</Nav.Link>
<Nav.Link as={Link} to="/helprequest">
HelpRequest
</Nav.Link>
{hasRole(currentUser, "ROLE_ADMIN") && (
<NavDropdown
title="Admin"
id="appnavbar-admin-dropdown"
data-testid="appnavbar-admin-dropdown"
>
<NavDropdown.Item as={Link} to="/admin/users">
Users
</NavDropdown.Item>
</NavDropdown>
)}
{systemInfoData?.springH2ConsoleEnabled && (
<Nav.Link href="/h2-console">H2Console</Nav.Link>
)}
{systemInfoData?.showSwaggerUILink && (
<Nav.Link href="/swagger-ui/index.html">Swagger</Nav.Link>
)}
</>
)}
</Nav>
<Nav className="ml-auto">
{isLocalhost && <AppNavbarLocalhost />}
{currentUser && currentUser.loggedIn ? (
<>
<Navbar.Text className="me-3" as={Link} to="/profile">
Welcome, {currentUser.root.user.email}
</Navbar.Text>
<Button onClick={doLogout}>Log Out</Button>
</>
) : (
<Button href={oauthLogin}>Log In</Button>
)}
</Nav>
</Navbar.Collapse>
</Container>
</Navbar>
);
}
|