import ArrowDropDown from '@mui/icons-material/ArrowDropDown'
import Dns from '@mui/icons-material/Dns'
import Hub from '@mui/icons-material/Hub'
import MenuIcon from '@mui/icons-material/Menu'
import People from '@mui/icons-material/People'
import Public from '@mui/icons-material/Public'
import ViewInAr from '@mui/icons-material/ViewInAr'
import Router from '@mui/icons-material/Router'
import VerifiedUser from '@mui/icons-material/VerifiedUser'
import VpnKey from '@mui/icons-material/VpnKey'
import { Button, ListItemIcon, ListItemText, Menu, MenuItem } from '@mui/material'
import { useState, type ReactNode } from 'react'
/** The path of the signed-in user's own account page. */
export const USER_PATH = '/user'
/** The path of the Remote Access page: IKEv2, OpenVPN and WireGuard. */
export const REMOTE_ACCESS_PATH = '/remote-access-manager'
/** The path of the Certificates page. */
export const CA_PATH = '/ca-manager'
/** The path of the Identities page: the users, the groups and the service accounts. */
export const USERS_PATH = '/user-manager'
/** The path of the Connectivity page: the site-to-site connections and their state. */
export const SITE_TO_SITE_PATH = '/site-to-site-manager'
/** The path of the Docker page: the state of Docker and of its rules. */
export const DOCKER_PATH = '/docker-manager'
/** The path of the Web Sites page: the sites Caddy serves and their files. */
export const SITES_PATH = '/sites-manager'
/** The path of the DNS page: the name server's settings, domains and records. */
export const DNS_PATH = '/dns-manager'
/** The path of the shell page: a login shell on the server, opened with the shell button of the header, not the menu. */
export const SHELL_PATH = '/shell'
/** The pages of an administrator in the menu: path, label and icon. */
const PAGES: { path: string; label: string; icon: ReactNode }[] = [
{ path: '/', label: 'Server', icon: },
{ path: USERS_PATH, label: 'Identities', icon: },
{ path: SITE_TO_SITE_PATH, label: 'Connectivity', icon: },
{ path: REMOTE_ACCESS_PATH, label: 'Remote Access', icon: },
{ path: CA_PATH, label: 'Certificates', icon: },
{ path: SITES_PATH, label: 'Web Sites', icon: },
{ path: DNS_PATH, label: 'DNS', icon: },
{ path: DOCKER_PATH, label: 'Docker', icon: },
]
/**
* A button naming the page shown, or Pages on the account and the shell page, whose menu opens the pages of an
* administrator but those of hidden, the pages of a component switched off or of software the server does not have.
*/
export default function PageMenu(props: { path: string; hidden: string[] }) {
const [anchor, setAnchor] = useState(null)
const current = PAGES.find((page) => page.path === props.path) ?? { path: props.path, label: 'Pages', icon: }
return (
<>
}
aria-haspopup="menu"
aria-expanded={anchor !== null}
onClick={(event) => setAnchor(event.currentTarget)}
>
{current.label}
>
)
}