import React from 'react'; import { Divider, List, ListItemButton, ListItemIcon, ListItemText, } from '@mui/material'; import SettingsIcon from '@mui/icons-material/Settings'; import CreateIcon from '@mui/icons-material/Create'; import NotificationsIcon from '@mui/icons-material/Notifications'; import FolderIcon from '@mui/icons-material/Folder'; import PersonIcon from '@mui/icons-material/Person'; import StorageIcon from '@mui/icons-material/Storage'; import BuildIcon from '@mui/icons-material/Build'; import PeopleIcon from '@mui/icons-material/People'; import TodayIcon from '@mui/icons-material/Today'; import PublishIcon from '@mui/icons-material/Publish'; import SmartphoneIcon from '@mui/icons-material/Smartphone'; import HelpIcon from '@mui/icons-material/Help'; import { Link, useLocation } from 'react-router-dom'; import { useSelector } from 'react-redux'; import { useTranslation } from '../../common/components/LocalizationProvider'; import { useAdministrator, useManager, useRestriction, } from '../../common/util/permissions'; import useFeatures from '../../common/util/useFeatures'; const MenuItem = ({ title, link, icon, selected, }) => ( {icon} ); const SettingsMenu = () => { const t = useTranslation(); const location = useLocation(); const readonly = useRestriction('readonly'); const admin = useAdministrator(); const manager = useManager(); const userId = useSelector((state) => state.session.user.id); const supportLink = useSelector((state) => state.session.server.attributes.support); const features = useFeatures(); return ( <> } selected={location.pathname === '/settings/preferences'} /> {!readonly && ( <> } selected={location.pathname.startsWith('/settings/notification')} /> } selected={location.pathname === `/settings/user/${userId}`} /> } selected={location.pathname.startsWith('/settings/device')} /> } selected={location.pathname.startsWith('/settings/geofence')} /> {!features.disableGroups && ( } selected={location.pathname.startsWith('/settings/group')} /> )} {!features.disableDrivers && ( } selected={location.pathname.startsWith('/settings/driver')} /> )} {!features.disableCalendars && ( } selected={location.pathname.startsWith('/settings/calendar')} /> )} {!features.disableComputedAttributes && ( } selected={location.pathname.startsWith('/settings/attribute')} /> )} {!features.disableMaintenance && ( } selected={location.pathname.startsWith('/settings/maintenance')} /> )} } selected={location.pathname.startsWith('/settings/command')} /> {supportLink && ( } /> )} )} {manager && ( <> {admin && ( } selected={location.pathname === '/settings/server'} /> )} } selected={location.pathname.startsWith('/settings/user') && location.pathname !== `/settings/user/${userId}`} /> )} ); }; export default SettingsMenu;