All files / components/Nav GithubLogin.jsx

100% Statements 18/18
100% Branches 7/7
100% Functions 1/1
100% Lines 18/18

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 251x 1x   1x 14x 14x 14x 1x 1x 14x 8x 8x 8x 8x       8x 5x 5x 5x     5x  
import { Button, Navbar } from "react-bootstrap";
import { Link } from "react-router";
 
export default function GithubLogin({ currentUser, systemInfo }) {
  var githubOauthLogin =
    systemInfo?.githubOauthLogin || "/oauth2/authorization/github";
  if (!currentUser || !currentUser.loggedIn) {
    return <span data-testid="GithubLogin-logged-out" />;
  }
  if (currentUser.root.user.githubLogin) {
    return (
      <>
        <Navbar.Text className="me-3" as={Link} to="/profile">
          Github: {currentUser.root.user.githubLogin}
        </Navbar.Text>
      </>
    );
  }
  return (
    <>
      <Button href={githubOauthLogin}>Connect Github</Button>
    </>
  );
}