import React, {useCallback, useContext} from 'react'; import {Link, NavLink} from "react-router-dom"; import Icon from "shared/elements/icon"; import {LocaleContext} from "shared/locale"; import {styled} from "@mui/material"; import ProfilePicture from "shared/elements/profile-picture"; const ProfileLink = styled(Link)((props) => ({ "& > div": { padding: 3, width: 30, height: 30, }, marginLeft: props.theme.spacing(1), marginTop: props.theme.spacing(1), display: "grid", gridTemplateColumns: "45px auto", "& > span": { alignSelf: "center" } })); export default function Sidebar(props) { const api = props.api; const showDialog = props.showDialog; const {translate: L} = useContext(LocaleContext); const onLogout = useCallback(() => { api.logout().then(obj => { if (obj.success) { document.location = "/admin"; } else { showDialog("Error logging out: " + obj.msg, "Error logging out"); } }); }, [api, showDialog]); const menuItems = { "dashboard": { "name": "admin.dashboard", "icon": "tachometer-alt" }, "users": { "name": "admin.users", "icon": "users" }, "groups": { "name": "admin.groups", "icon": "users-cog" }, "routes": { "name": "admin.page_routes", "icon": "copy", }, "settings": { "name": "admin.settings", "icon": "tools" }, "permissions": { "name": "admin.acl", "icon": "door-open" }, "logs": { "name": "admin.logs", "icon": "file-medical-alt" }, "help": { "name": "admin.help", "icon": "question-circle" }, }; let li = []; for (let id in menuItems) { let obj = menuItems[id]; const badge = (obj.badge ? {obj.badge.value} : <>); li.push(
  • {L(obj.name)}{badge}

  • ); } li.push(
  • onLogout()} className={"nav-link"}>

    {L("general.logout")}

  • ); return <> }