// This file is part of Moonfire NVR, a security camera network video recorder. // Copyright (C) 2021 The Moonfire NVR Authors; see AUTHORS and LICENSE.txt. // SPDX-License-Identifier: GPL-v3.0-or-later WITH GPL-3.0-linking-exception import Button from "@mui/material/Button"; import IconButton from "@mui/material/IconButton"; import Menu from "@mui/material/Menu"; import MenuItem from "@mui/material/MenuItem"; import { Theme } from "@mui/material/styles"; import { createStyles, makeStyles } from "@mui/styles"; import Toolbar from "@mui/material/Toolbar"; import Typography from "@mui/material/Typography"; import AccountCircle from "@mui/icons-material/AccountCircle"; import MenuIcon from "@mui/icons-material/Menu"; import React from "react"; import { LoginState } from "./App"; import { Session } from "./types"; const useStyles = makeStyles((theme: Theme) => createStyles({ title: { flexGrow: 1, }, activity: { marginRight: theme.spacing(2), }, }) ); interface Props { loginState: LoginState; setSession: (session: Session | null) => void; requestLogin: () => void; logout: () => void; menuClick?: () => void; activityMenuPart: JSX.Element | null; } // https://material-ui.com/components/app-bar/ function MoonfireMenu(props: Props) { const classes = useStyles(); const [accountMenuAnchor, setAccountMenuAnchor] = React.useState(null); const handleMenu = (event: React.MouseEvent) => { setAccountMenuAnchor(event.currentTarget); }; const handleClose = () => { setAccountMenuAnchor(null); }; const handleLogout = () => { // Note this close should happen before `auth` toggles, or material-ui will // be unhappy about the anchor element not being part of the layout. handleClose(); props.logout(); }; return ( <> Moonfire NVR {props.activityMenuPart !== null && (
{props.activityMenuPart}
)} {props.loginState !== "unknown" && props.loginState !== "logged-in" && ( )} {props.loginState === "logged-in" && (
Logout
)}
); } export default MoonfireMenu;