From bf95e1bb48379bc1c3482d3f201017250991a832 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 8 May 2022 17:33:58 -0700 Subject: Implement new page layout --- modern/src/common/components/PageLayout.js | 110 +++++++++++++++++++++ modern/src/settings/AccumulatorsPage.js | 7 +- modern/src/settings/CalendarPage.js | 10 +- modern/src/settings/CalendarsPage.js | 7 +- modern/src/settings/CommandPage.js | 10 +- modern/src/settings/CommandSendPage.js | 7 +- modern/src/settings/CommandsPage.js | 7 +- modern/src/settings/ComputedAttributePage.js | 10 +- modern/src/settings/ComputedAttributesPage.js | 7 +- modern/src/settings/DevicePage.js | 10 +- modern/src/settings/DriverPage.js | 10 +- modern/src/settings/DriversPage.js | 7 +- modern/src/settings/GeofencePage.js | 10 +- modern/src/settings/GroupPage.js | 10 +- modern/src/settings/GroupsPage.js | 7 +- modern/src/settings/MaintenancePage.js | 10 +- modern/src/settings/MaintenancesPage.js | 7 +- modern/src/settings/NotificationPage.js | 10 +- modern/src/settings/NotificationsPage.js | 7 +- modern/src/settings/PreferencesPage.js | 7 +- modern/src/settings/ServerPage.js | 7 +- modern/src/settings/UserPage.js | 11 ++- modern/src/settings/UsersPage.js | 7 +- modern/src/settings/components/EditItemView.js | 8 +- modern/src/settings/components/SettingsMenu.js | 128 +++++++++++++++++++++++++ 25 files changed, 381 insertions(+), 50 deletions(-) create mode 100644 modern/src/common/components/PageLayout.js create mode 100644 modern/src/settings/components/SettingsMenu.js (limited to 'modern') diff --git a/modern/src/common/components/PageLayout.js b/modern/src/common/components/PageLayout.js new file mode 100644 index 00000000..e37ae4dc --- /dev/null +++ b/modern/src/common/components/PageLayout.js @@ -0,0 +1,110 @@ +import React, { useState } from 'react'; +import { + AppBar, Breadcrumbs, Divider, Drawer, Hidden, IconButton, makeStyles, Toolbar, Typography, useMediaQuery, useTheme, +} from '@material-ui/core'; +import ArrowBackIcon from '@material-ui/icons/ArrowBack'; +import MenuIcon from '@material-ui/icons/Menu'; +import { useHistory } from 'react-router-dom'; +import { useTranslation } from './LocalizationProvider'; + +const useStyles = makeStyles((theme) => ({ + desktopRoot: { + height: '100%', + display: 'flex', + }, + mobileRoot: { + height: '100%', + display: 'flex', + flexDirection: 'column', + }, + desktopDrawer: { + width: theme.dimensions.drawerWidthDesktop, + }, + mobileDrawer: { + width: theme.dimensions.drawerWidthTablet, + }, + toolbar: theme.mixins.toolbar, + content: { + flexGrow: 1, + alignItems: 'stretch', + overflow: 'auto', + }, +})); + +const PageTitle = ({ breadcrumbs }) => { + const theme = useTheme(); + const t = useTranslation(); + + const desktop = useMediaQuery(theme.breakpoints.up('md')); + + if (desktop) { + return ( + {t(breadcrumbs.at(0))} + ); + } + return ( + + {breadcrumbs.slice(0, -1).map((breadcrumb) => ( + {t(breadcrumb)} + ))} + {t(breadcrumbs.at(-1))} + + ); +}; + +const PageLayout = ({ menu, breadcrumbs, children }) => { + const classes = useStyles(); + const history = useHistory(); + + const [openDrawer, setOpenDrawer] = useState(false); + + return ( + <> + +
+ +
+ + history.push('/')}> + + + + +
+ + {menu} +
+
{children}
+
+
+ + +
+ setOpenDrawer(false)} + classes={{ paper: classes.mobileDrawer }} + > + {menu} + + + + setOpenDrawer(true)}> + + + + + +
{children}
+
+
+ + ); +}; + +export default PageLayout; diff --git a/modern/src/settings/AccumulatorsPage.js b/modern/src/settings/AccumulatorsPage.js index f8895bbe..0fcde8d1 100644 --- a/modern/src/settings/AccumulatorsPage.js +++ b/modern/src/settings/AccumulatorsPage.js @@ -6,7 +6,8 @@ import { } from '@material-ui/core'; import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; import { useTranslation } from '../common/components/LocalizationProvider'; -import OptionsLayout from './components/OptionsLayout'; +import PageLayout from '../common/components/PageLayout'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles((theme) => ({ container: { @@ -57,7 +58,7 @@ const AccumulatorsPage = () => { }; return ( - + } breadcrumbs={['sharedDeviceAccumulators']}> {item && ( @@ -107,7 +108,7 @@ const AccumulatorsPage = () => { )} - + ); }; diff --git a/modern/src/settings/CalendarPage.js b/modern/src/settings/CalendarPage.js index ec793196..154b3f11 100644 --- a/modern/src/settings/CalendarPage.js +++ b/modern/src/settings/CalendarPage.js @@ -8,6 +8,7 @@ import { DropzoneArea } from 'material-ui-dropzone'; import EditItemView from './components/EditItemView'; import EditAttributesView from './components/EditAttributesView'; import { useTranslation } from '../common/components/LocalizationProvider'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles(() => ({ details: { @@ -37,7 +38,14 @@ const CalendarPage = () => { const validate = () => item && item.name && item.data; return ( - + } + breadcrumbs={['settingsTitle', 'sharedCalendar']} + > {item && ( <> diff --git a/modern/src/settings/CalendarsPage.js b/modern/src/settings/CalendarsPage.js index db4dc770..875530a8 100644 --- a/modern/src/settings/CalendarsPage.js +++ b/modern/src/settings/CalendarsPage.js @@ -5,8 +5,9 @@ import { import MoreVertIcon from '@material-ui/icons/MoreVert'; import { useEffectAsync } from '../reactHelper'; import EditCollectionView from './components/EditCollectionView'; -import OptionsLayout from './components/OptionsLayout'; import { useTranslation } from '../common/components/LocalizationProvider'; +import PageLayout from '../common/components/PageLayout'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles((theme) => ({ columnAction: { @@ -55,9 +56,9 @@ const CalendarsView = ({ updateTimestamp, onMenuClick }) => { }; const CalendarsPage = () => ( - + } breadcrumbs={['settingsTitle', 'sharedCalendars']}> - + ); export default CalendarsPage; diff --git a/modern/src/settings/CommandPage.js b/modern/src/settings/CommandPage.js index 99bb21f2..4785021b 100644 --- a/modern/src/settings/CommandPage.js +++ b/modern/src/settings/CommandPage.js @@ -6,6 +6,7 @@ import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; import EditItemView from './components/EditItemView'; import { useTranslation } from '../common/components/LocalizationProvider'; import BaseCommandView from './components/BaseCommandView'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles(() => ({ details: { @@ -22,7 +23,14 @@ const CommandPage = () => { const validate = () => item && item.type; return ( - + } + breadcrumbs={['settingsTitle', 'sharedSavedCommand']} + > {item && ( }> diff --git a/modern/src/settings/CommandSendPage.js b/modern/src/settings/CommandSendPage.js index 79de1b84..f7e62b24 100644 --- a/modern/src/settings/CommandSendPage.js +++ b/modern/src/settings/CommandSendPage.js @@ -5,9 +5,10 @@ import { } from '@material-ui/core'; import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; import { useTranslation } from '../common/components/LocalizationProvider'; -import OptionsLayout from './components/OptionsLayout'; import BaseCommandView from './components/BaseCommandView'; import SelectField from '../common/components/SelectField'; +import PageLayout from '../common/components/PageLayout'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles((theme) => ({ container: { @@ -62,7 +63,7 @@ const CommandSendPage = () => { const validate = () => savedId || (item && item.type); return ( - + } breadcrumbs={['settingsTitle', 'deviceCommand']}> }> @@ -108,7 +109,7 @@ const CommandSendPage = () => { - + ); }; diff --git a/modern/src/settings/CommandsPage.js b/modern/src/settings/CommandsPage.js index 6081b48c..20b792b8 100644 --- a/modern/src/settings/CommandsPage.js +++ b/modern/src/settings/CommandsPage.js @@ -5,10 +5,11 @@ import { import MoreVertIcon from '@material-ui/icons/MoreVert'; import { useEffectAsync } from '../reactHelper'; import EditCollectionView from './components/EditCollectionView'; -import OptionsLayout from './components/OptionsLayout'; import { useTranslation } from '../common/components/LocalizationProvider'; import { formatBoolean } from '../common/util/formatter'; import { prefixString } from '../common/util/stringUtils'; +import PageLayout from '../common/components/PageLayout'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles((theme) => ({ columnAction: { @@ -61,9 +62,9 @@ const CommandsView = ({ updateTimestamp, onMenuClick }) => { }; const CommandsPage = () => ( - + } breadcrumbs={['settingsTitle', 'sharedSavedCommands']}> - + ); export default CommandsPage; diff --git a/modern/src/settings/ComputedAttributePage.js b/modern/src/settings/ComputedAttributePage.js index 52a583dc..984339b8 100644 --- a/modern/src/settings/ComputedAttributePage.js +++ b/modern/src/settings/ComputedAttributePage.js @@ -6,6 +6,7 @@ import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; import EditItemView from './components/EditItemView'; import { useTranslation } from '../common/components/LocalizationProvider'; import usePositionAttributes from '../common/attributes/usePositionAttributes'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles(() => ({ details: { @@ -42,7 +43,14 @@ const ComputedAttributePage = () => { const validate = () => item && item.description && item.expression; return ( - + } + breadcrumbs={['settingsTitle', 'sharedComputedAttribute']} + > {item && ( }> diff --git a/modern/src/settings/ComputedAttributesPage.js b/modern/src/settings/ComputedAttributesPage.js index 3b60419d..451b47a7 100644 --- a/modern/src/settings/ComputedAttributesPage.js +++ b/modern/src/settings/ComputedAttributesPage.js @@ -5,9 +5,10 @@ import { import MoreVertIcon from '@material-ui/icons/MoreVert'; import { useEffectAsync } from '../reactHelper'; import EditCollectionView from './components/EditCollectionView'; -import OptionsLayout from './components/OptionsLayout'; import { useTranslation } from '../common/components/LocalizationProvider'; import { useAdministrator } from '../common/util/permissions'; +import PageLayout from '../common/components/PageLayout'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles((theme) => ({ columnAction: { @@ -65,9 +66,9 @@ const ComputedAttributeView = ({ updateTimestamp, onMenuClick }) => { }; const ComputedAttributesPage = () => ( - + } breadcrumbs={['settingsTitle', 'sharedComputedAttributes']}> - + ); export default ComputedAttributesPage; diff --git a/modern/src/settings/DevicePage.js b/modern/src/settings/DevicePage.js index e40649a5..491ba60f 100644 --- a/modern/src/settings/DevicePage.js +++ b/modern/src/settings/DevicePage.js @@ -14,6 +14,7 @@ import { prefixString } from '../common/util/stringUtils'; import { useTranslation } from '../common/components/LocalizationProvider'; import useDeviceAttributes from '../common/attributes/useDeviceAttributes'; import { useAdministrator } from '../common/util/permissions'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles(() => ({ details: { @@ -34,7 +35,14 @@ const DevicePage = () => { const validate = () => item && item.name && item.uniqueId; return ( - + } + breadcrumbs={['sharedDevice']} + > {item && ( <> diff --git a/modern/src/settings/DriverPage.js b/modern/src/settings/DriverPage.js index dee11d37..93d09c8e 100644 --- a/modern/src/settings/DriverPage.js +++ b/modern/src/settings/DriverPage.js @@ -7,6 +7,7 @@ import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; import EditItemView from './components/EditItemView'; import EditAttributesView from './components/EditAttributesView'; import { useTranslation } from '../common/components/LocalizationProvider'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles(() => ({ details: { @@ -23,7 +24,14 @@ const DriverPage = () => { const validate = () => item && item.name && item.uniqueId; return ( - + } + breadcrumbs={['settingsTitle', 'sharedDriver']} + > {item && ( <> diff --git a/modern/src/settings/DriversPage.js b/modern/src/settings/DriversPage.js index 5b01bdfa..f5908381 100644 --- a/modern/src/settings/DriversPage.js +++ b/modern/src/settings/DriversPage.js @@ -5,8 +5,9 @@ import { import MoreVertIcon from '@material-ui/icons/MoreVert'; import { useEffectAsync } from '../reactHelper'; import EditCollectionView from './components/EditCollectionView'; -import OptionsLayout from './components/OptionsLayout'; import { useTranslation } from '../common/components/LocalizationProvider'; +import PageLayout from '../common/components/PageLayout'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles((theme) => ({ columnAction: { @@ -57,9 +58,9 @@ const DriversView = ({ updateTimestamp, onMenuClick }) => { }; const DriversPage = () => ( - + } breadcrumbs={['settingsTitle', 'sharedDrivers']}> - + ); export default DriversPage; diff --git a/modern/src/settings/GeofencePage.js b/modern/src/settings/GeofencePage.js index 0fa986d2..e23d49fb 100644 --- a/modern/src/settings/GeofencePage.js +++ b/modern/src/settings/GeofencePage.js @@ -9,6 +9,7 @@ import EditItemView from './components/EditItemView'; import EditAttributesView from './components/EditAttributesView'; import { useTranslation } from '../common/components/LocalizationProvider'; import useGeofenceAttributes from '../common/attributes/useGeofenceAttributes'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles(() => ({ details: { @@ -27,7 +28,14 @@ const GeofencePage = () => { const validate = () => item && item.name; return ( - + } + breadcrumbs={['settingsTitle', 'sharedGeofence']} + > {item && ( <> diff --git a/modern/src/settings/GroupPage.js b/modern/src/settings/GroupPage.js index 750d6ebc..f56a2fd3 100644 --- a/modern/src/settings/GroupPage.js +++ b/modern/src/settings/GroupPage.js @@ -10,6 +10,7 @@ import EditAttributesView from './components/EditAttributesView'; import useDeviceAttributes from '../common/attributes/useDeviceAttributes'; import SelectField from '../common/components/SelectField'; import { useTranslation } from '../common/components/LocalizationProvider'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles(() => ({ details: { @@ -28,7 +29,14 @@ const GroupPage = () => { const validate = () => item && item.name; return ( - + } + breadcrumbs={['settingsTitle', 'groupDialog']} + > {item && ( <> diff --git a/modern/src/settings/GroupsPage.js b/modern/src/settings/GroupsPage.js index 3642c02f..5d23c2d9 100644 --- a/modern/src/settings/GroupsPage.js +++ b/modern/src/settings/GroupsPage.js @@ -5,8 +5,9 @@ import { import MoreVertIcon from '@material-ui/icons/MoreVert'; import { useEffectAsync } from '../reactHelper'; import EditCollectionView from './components/EditCollectionView'; -import OptionsLayout from './components/OptionsLayout'; import { useTranslation } from '../common/components/LocalizationProvider'; +import PageLayout from '../common/components/PageLayout'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles((theme) => ({ columnAction: { @@ -55,9 +56,9 @@ const GroupsView = ({ updateTimestamp, onMenuClick }) => { }; const GroupsPage = () => ( - + } breadcrumbs={['settingsTitle', 'settingsGroups']}> - + ); export default GroupsPage; diff --git a/modern/src/settings/MaintenancePage.js b/modern/src/settings/MaintenancePage.js index b55ce35b..9e53aca1 100644 --- a/modern/src/settings/MaintenancePage.js +++ b/modern/src/settings/MaintenancePage.js @@ -13,6 +13,7 @@ import { } from '../common/util/converter'; import { useTranslation } from '../common/components/LocalizationProvider'; import usePositionAttributes from '../common/attributes/usePositionAttributes'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles(() => ({ details: { @@ -97,7 +98,14 @@ const MaintenancePage = () => { const validate = () => item && item.name && item.type && item.start && item.period; return ( - + } + breadcrumbs={['settingsTitle', 'sharedMaintenance']} + > {item && ( <> diff --git a/modern/src/settings/MaintenancesPage.js b/modern/src/settings/MaintenancesPage.js index 038e5dff..3801f010 100644 --- a/modern/src/settings/MaintenancesPage.js +++ b/modern/src/settings/MaintenancesPage.js @@ -9,8 +9,9 @@ import EditCollectionView from './components/EditCollectionView'; import usePositionAttributes from '../common/attributes/usePositionAttributes'; import { formatDistance, formatSpeed } from '../common/util/formatter'; import { useAttributePreference } from '../common/util/preferences'; -import OptionsLayout from './components/OptionsLayout'; import { useTranslation } from '../common/components/LocalizationProvider'; +import PageLayout from '../common/components/PageLayout'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles((theme) => ({ columnAction: { @@ -85,9 +86,9 @@ const MaintenancesView = ({ updateTimestamp, onMenuClick }) => { }; const MaintenacesPage = () => ( - + } breadcrumbs={['settingsTitle', 'sharedMaintenance']}> - + ); export default MaintenacesPage; diff --git a/modern/src/settings/NotificationPage.js b/modern/src/settings/NotificationPage.js index ed0b3e5e..38ba19e5 100644 --- a/modern/src/settings/NotificationPage.js +++ b/modern/src/settings/NotificationPage.js @@ -8,6 +8,7 @@ import { useTranslation, useTranslationKeys } from '../common/components/Localiz import EditItemView from './components/EditItemView'; import { prefixString, unprefixString } from '../common/util/stringUtils'; import SelectField from '../common/components/SelectField'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles(() => ({ details: { @@ -29,7 +30,14 @@ const NotificationPage = () => { const validate = () => item && item.type && item.notificators; return ( - + } + breadcrumbs={['settingsTitle', 'sharedNotification']} + > {item && ( <> diff --git a/modern/src/settings/NotificationsPage.js b/modern/src/settings/NotificationsPage.js index d96bc3da..7ad5186b 100644 --- a/modern/src/settings/NotificationsPage.js +++ b/modern/src/settings/NotificationsPage.js @@ -7,8 +7,9 @@ import { useEffectAsync } from '../reactHelper'; import EditCollectionView from './components/EditCollectionView'; import { prefixString } from '../common/util/stringUtils'; import { formatBoolean } from '../common/util/formatter'; -import OptionsLayout from './components/OptionsLayout'; import { useTranslation } from '../common/components/LocalizationProvider'; +import PageLayout from '../common/components/PageLayout'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles((theme) => ({ columnAction: { @@ -74,9 +75,9 @@ const NotificationsView = ({ updateTimestamp, onMenuClick }) => { }; const NotificationsPage = () => ( - + } breadcrumbs={['settingsTitle', 'sharedNotifications']}> - + ); export default NotificationsPage; diff --git a/modern/src/settings/PreferencesPage.js b/modern/src/settings/PreferencesPage.js index 8b259bf2..1256a53a 100644 --- a/modern/src/settings/PreferencesPage.js +++ b/modern/src/settings/PreferencesPage.js @@ -4,8 +4,9 @@ import { } from '@material-ui/core'; import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; import { useLocalization, useTranslation } from '../common/components/LocalizationProvider'; -import OptionsLayout from './components/OptionsLayout'; import usePersistedState from '../common/util/usePersistedState'; +import PageLayout from '../common/components/PageLayout'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles((theme) => ({ container: { @@ -28,7 +29,7 @@ const PreferencesPage = () => { const [mapCluster, setMapCluster] = usePersistedState('mapCluster', true); return ( - + } breadcrumbs={['settingsTitle', 'sharedPreferences']}> }> @@ -67,7 +68,7 @@ const PreferencesPage = () => { - + ); }; diff --git a/modern/src/settings/ServerPage.js b/modern/src/settings/ServerPage.js index f98bc691..8943252e 100644 --- a/modern/src/settings/ServerPage.js +++ b/modern/src/settings/ServerPage.js @@ -11,9 +11,10 @@ import { sessionActions } from '../store'; import EditAttributesView from './components/EditAttributesView'; import useDeviceAttributes from '../common/attributes/useDeviceAttributes'; import useUserAttributes from '../common/attributes/useUserAttributes'; -import OptionsLayout from './components/OptionsLayout'; import { useTranslation } from '../common/components/LocalizationProvider'; import SelectField from '../common/components/SelectField'; +import PageLayout from '../common/components/PageLayout'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles((theme) => ({ container: { @@ -57,7 +58,7 @@ const ServerPage = () => { }; return ( - + } breadcrumbs={['settingsTitle', 'settingsServer']}> {item && ( <> @@ -234,7 +235,7 @@ const ServerPage = () => { - + ); }; diff --git a/modern/src/settings/UserPage.js b/modern/src/settings/UserPage.js index 2b5adcca..7200329a 100644 --- a/modern/src/settings/UserPage.js +++ b/modern/src/settings/UserPage.js @@ -13,6 +13,7 @@ import { useTranslation } from '../common/components/LocalizationProvider'; import useUserAttributes from '../common/attributes/useUserAttributes'; import { sessionActions } from '../store'; import SelectField from '../common/components/SelectField'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles(() => ({ details: { @@ -40,7 +41,15 @@ const UserPage = () => { const validate = () => item && item.name && item.email && (item.id || item.password); return ( - + } + breadcrumbs={['settingsTitle', 'settingsUser']} + > {item && ( <> diff --git a/modern/src/settings/UsersPage.js b/modern/src/settings/UsersPage.js index bdadf845..2d8d1199 100644 --- a/modern/src/settings/UsersPage.js +++ b/modern/src/settings/UsersPage.js @@ -6,8 +6,9 @@ import MoreVertIcon from '@material-ui/icons/MoreVert'; import { useEffectAsync } from '../reactHelper'; import EditCollectionView from './components/EditCollectionView'; import { formatBoolean } from '../common/util/formatter'; -import OptionsLayout from './components/OptionsLayout'; import { useTranslation } from '../common/components/LocalizationProvider'; +import PageLayout from '../common/components/PageLayout'; +import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles((theme) => ({ columnAction: { @@ -62,9 +63,9 @@ const UsersView = ({ updateTimestamp, onMenuClick }) => { }; const UsersPage = () => ( - + } breadcrumbs={['settingsTitle', 'settingsUsers']}> - + ); export default UsersPage; diff --git a/modern/src/settings/components/EditItemView.js b/modern/src/settings/components/EditItemView.js index 90e5294a..2283ebda 100644 --- a/modern/src/settings/components/EditItemView.js +++ b/modern/src/settings/components/EditItemView.js @@ -6,8 +6,8 @@ import Button from '@material-ui/core/Button'; import FormControl from '@material-ui/core/FormControl'; import { useEffectAsync } from '../../reactHelper'; -import OptionsLayout from './OptionsLayout'; import { useTranslation } from '../../common/components/LocalizationProvider'; +import PageLayout from '../../common/components/PageLayout'; const useStyles = makeStyles((theme) => ({ container: { @@ -23,7 +23,7 @@ const useStyles = makeStyles((theme) => ({ })); const EditItemView = ({ - children, endpoint, item, setItem, validate, onItemSaved, + children, endpoint, item, setItem, validate, onItemSaved, menu, breadcrumbs, }) => { const history = useHistory(); const classes = useStyles(); @@ -63,7 +63,7 @@ const EditItemView = ({ }; return ( - + {children} @@ -88,7 +88,7 @@ const EditItemView = ({ - + ); }; diff --git a/modern/src/settings/components/SettingsMenu.js b/modern/src/settings/components/SettingsMenu.js new file mode 100644 index 00000000..036f4101 --- /dev/null +++ b/modern/src/settings/components/SettingsMenu.js @@ -0,0 +1,128 @@ +import React from 'react'; +import { + Divider, List, ListItem, ListItemIcon, ListItemText, +} from '@material-ui/core'; +import SettingsIcon from '@material-ui/icons/Settings'; +import CreateIcon from '@material-ui/icons/Create'; +import NotificationsIcon from '@material-ui/icons/Notifications'; +import FolderIcon from '@material-ui/icons/Folder'; +import PersonIcon from '@material-ui/icons/Person'; +import StorageIcon from '@material-ui/icons/Storage'; +import BuildIcon from '@material-ui/icons/Build'; +import PeopleIcon from '@material-ui/icons/People'; +import TodayIcon from '@material-ui/icons/Today'; +import PublishIcon from '@material-ui/icons/Publish'; +import { Link, useLocation } from 'react-router-dom'; +import { useSelector } from 'react-redux'; +import { useTranslation } from '../../common/components/LocalizationProvider'; +import { useAdministrator, useReadonly } from '../../common/util/permissions'; + +const MenuItem = ({ + title, link, icon, selected, +}) => ( + + {icon} + + +); + +const SettingsMenu = () => { + const t = useTranslation(); + const location = useLocation(); + + const readonly = useReadonly(); + const admin = useAdministrator(); + const userId = useSelector((state) => state.session.user?.id); + + return ( + <> + + } + selected={location.pathname === '/settings/preferences'} + /> + {!readonly && ( + <> + } + selected={location.pathname.startsWith('/settings/notification')} + /> + } + selected={location.pathname === `/settings/user/${userId}`} + /> + } + selected={location.pathname.startsWith('/settings/geofence')} + /> + } + selected={location.pathname.startsWith('/settings/group')} + /> + } + selected={location.pathname.startsWith('/settings/driver')} + /> + } + selected={location.pathname.startsWith('/settings/calendar')} + /> + } + selected={location.pathname.startsWith('/settings/attribute')} + /> + } + selected={location.pathname.startsWith('/settings/maintenance')} + /> + } + selected={location.pathname.startsWith('/settings/command')} + /> + + )} + + {admin && ( + <> + + + } + selected={location.pathname === '/settings/server'} + /> + } + selected={location.pathname.startsWith('/settings/user') && location.pathname !== `/settings/user/${userId}`} + /> + + + )} + + ); +}; + +export default SettingsMenu; -- cgit v1.2.3