aboutsummaryrefslogtreecommitdiff
path: root/modern/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/components')
-rw-r--r--modern/src/components/BottomMenu.js14
-rw-r--r--modern/src/components/PositionValue.js4
-rw-r--r--modern/src/components/registration/LoginForm.js6
3 files changed, 17 insertions, 7 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}>
diff --git a/modern/src/components/PositionValue.js b/modern/src/components/PositionValue.js
index fd331a7d..5a07959d 100644
--- a/modern/src/components/PositionValue.js
+++ b/modern/src/components/PositionValue.js
@@ -1,17 +1,17 @@
import React, { useEffect, useState } from 'react';
import { Link } from '@material-ui/core';
import { Link as RouterLink } from 'react-router-dom';
-import { useSelector } from 'react-redux';
import {
formatAlarm, formatBoolean, formatCoordinate, formatCourse, formatDistance, formatNumber, formatPercentage, formatSpeed, formatTime,
} from '../common/formatter';
import { useAttributePreference, usePreference } from '../common/preferences';
import { useTranslation } from '../LocalizationProvider';
+import { useAdministrator } from '../common/permissions';
const PositionValue = ({ position, property, attribute }) => {
const t = useTranslation();
- const admin = useSelector((state) => state.session.user?.administrator);
+ const admin = useAdministrator();
const key = property || attribute;
const value = property ? position[property] : position.attributes[attribute];
diff --git a/modern/src/components/registration/LoginForm.js b/modern/src/components/registration/LoginForm.js
index 58c50df8..0c28e00b 100644
--- a/modern/src/components/registration/LoginForm.js
+++ b/modern/src/components/registration/LoginForm.js
@@ -36,11 +36,11 @@ const LoginForm = () => {
const [email, setEmail] = usePersistedState('loginEmail', '');
const [password, setPassword] = useState('');
- const registrationEnabled = useSelector((state) => (state.session.server ? state.session.server.registration : false));
- const emailEnabled = useSelector((state) => (state.session.server ? state.session.server.emailEnabled : false));
+ const registrationEnabled = useSelector((state) => state.session.server?.registration);
+ const emailEnabled = useSelector((state) => state.session.server?.emailEnabled);
const [announcementShown, setAnnouncementShown] = useState(false);
- const announcement = useSelector((state) => (state.session.server && state.session.server.announcement));
+ const announcement = useSelector((state) => state.session.server?.announcement);
const handleSubmit = async (event) => {
event.preventDefault();