diff options
author | Anton Tananaev <anton@traccar.org> | 2022-05-04 18:02:01 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-05-04 18:02:01 -0700 |
commit | 05623d59c14896da5ac1b2527e93d4af50ec87b6 (patch) | |
tree | 6e9dfb5d6f969b3b46b2725ca8bb264a86685111 /modern/src/components/BottomMenu.js | |
parent | 53fd7f27b8a84b49ef7e4dafbc9e8ac985d7f3af (diff) | |
download | trackermap-web-05623d59c14896da5ac1b2527e93d4af50ec87b6.tar.gz trackermap-web-05623d59c14896da5ac1b2527e93d4af50ec87b6.tar.bz2 trackermap-web-05623d59c14896da5ac1b2527e93d4af50ec87b6.zip |
Handle user permissions
Diffstat (limited to 'modern/src/components/BottomMenu.js')
-rw-r--r-- | modern/src/components/BottomMenu.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/modern/src/components/BottomMenu.js b/modern/src/components/BottomMenu.js index 087d241d..920622ae 100644 --- a/modern/src/components/BottomMenu.js +++ b/modern/src/components/BottomMenu.js @@ -9,9 +9,11 @@ import DescriptionIcon from '@material-ui/icons/Description'; import SettingsIcon from '@material-ui/icons/Settings'; import MapIcon from '@material-ui/icons/Map'; import PersonIcon from '@material-ui/icons/Person'; +import ExitToAppIcon from '@material-ui/icons/ExitToApp'; import { sessionActions } from '../store'; import { useTranslation } from '../LocalizationProvider'; +import { useReadonly } from '../common/permissions'; const BottomMenu = () => { const history = useHistory(); @@ -19,6 +21,7 @@ const BottomMenu = () => { const dispatch = useDispatch(); const t = useTranslation(); + const readonly = useReadonly(); const userId = useSelector((state) => state.session.user?.id); const [anchorEl, setAnchorEl] = useState(null); @@ -48,7 +51,11 @@ const BottomMenu = () => { history.push('/settings/preferences'); break; case 3: - setAnchorEl(event.currentTarget); + if (readonly) { + handleLogout(); + } else { + setAnchorEl(event.currentTarget); + } break; default: break; @@ -73,7 +80,10 @@ const BottomMenu = () => { <BottomNavigationAction label={t('mapTitle')} icon={<MapIcon />} /> <BottomNavigationAction label={t('reportTitle')} icon={<DescriptionIcon />} /> <BottomNavigationAction label={t('settingsTitle')} icon={<SettingsIcon />} /> - <BottomNavigationAction label={t('settingsUser')} icon={<PersonIcon />} /> + {readonly + ? (<BottomNavigationAction label={t('loginLogout')} icon={<ExitToAppIcon />} />) + : (<BottomNavigationAction label={t('settingsUser')} icon={<PersonIcon />} />) + } </BottomNavigation> <Menu anchorEl={anchorEl} keepMounted open={Boolean(anchorEl)} onClose={() => setAnchorEl(null)}> <MenuItem onClick={handleAccount}> |