From 4993f83ad1a5ad78a0b076503ab8c0b8f1bbf073 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 18 Jul 2022 16:51:46 -0700 Subject: Option to disable email change --- modern/src/common/components/BottomMenu.js | 4 ++-- modern/src/common/util/permissions.js | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'modern/src/common') diff --git a/modern/src/common/components/BottomMenu.js b/modern/src/common/components/BottomMenu.js index 37bdcf10..504e642a 100644 --- a/modern/src/common/components/BottomMenu.js +++ b/modern/src/common/components/BottomMenu.js @@ -13,7 +13,7 @@ import ExitToAppIcon from '@mui/icons-material/ExitToApp'; import { sessionActions } from '../../store'; import { useTranslation } from './LocalizationProvider'; -import { useReadonly } from '../util/permissions'; +import { useRestriction } from '../util/permissions'; const BottomMenu = () => { const navigate = useNavigate(); @@ -21,7 +21,7 @@ const BottomMenu = () => { const dispatch = useDispatch(); const t = useTranslation(); - const readonly = useReadonly(); + const readonly = useRestriction('readonly'); const userId = useSelector((state) => state.session.user.id); const socket = useSelector((state) => state.session.socket); diff --git a/modern/src/common/util/permissions.js b/modern/src/common/util/permissions.js index c866c41e..76e0aa58 100644 --- a/modern/src/common/util/permissions.js +++ b/modern/src/common/util/permissions.js @@ -11,13 +11,6 @@ export const useManager = () => useSelector((state) => { return admin || manager; }); -export const useReadonly = () => useSelector((state) => { - const admin = state.session.user.administrator; - const serverReadonly = state.session.server.readonly; - const userReadonly = state.session.user.readonly; - return !admin && (serverReadonly || userReadonly); -}); - export const useDeviceReadonly = () => useSelector((state) => { const admin = state.session.user.administrator; const serverReadonly = state.session.server.readonly; @@ -26,3 +19,10 @@ export const useDeviceReadonly = () => useSelector((state) => { const userDeviceReadonly = state.session.user.deviceReadonly; return !admin && (serverReadonly || userReadonly || serverDeviceReadonly || userDeviceReadonly); }); + +export const useRestriction = (key) => useSelector((state) => { + const admin = state.session.user.administrator; + const serverValue = state.session.server[key]; + const userValue = state.session.user[key]; + return !admin && (serverValue || userValue); +}); -- cgit v1.2.3