diff options
Diffstat (limited to 'modern/src/common')
-rw-r--r-- | modern/src/common/attributes/useCommonUserAttributes.js | 24 | ||||
-rw-r--r-- | modern/src/common/util/useFeatures.js | 30 |
2 files changed, 42 insertions, 12 deletions
diff --git a/modern/src/common/attributes/useCommonUserAttributes.js b/modern/src/common/attributes/useCommonUserAttributes.js index fa6d7d8f..c17b5c5d 100644 --- a/modern/src/common/attributes/useCommonUserAttributes.js +++ b/modern/src/common/attributes/useCommonUserAttributes.js @@ -5,18 +5,6 @@ export default (t) => useMemo(() => ({ name: t('attributeNotificationTokens'), type: 'string', }, - /* 'web.liveRouteLength': { - name: t('attributeWebLiveRouteLength'), - type: 'number', - }, - 'web.selectZoom': { - name: t('attributeWebSelectZoom'), - type: 'number', - }, - 'web.maxZoom': { - name: t('attributeWebMaxZoom'), - type: 'number', - }, 'ui.disableEvents': { name: t('attributeUiDisableEvents'), type: 'boolean', @@ -41,6 +29,18 @@ export default (t) => useMemo(() => ({ name: t('attributeUiDisableMaintenance'), type: 'boolean', }, + /* 'web.liveRouteLength': { + name: t('attributeWebLiveRouteLength'), + type: 'number', + }, + 'web.selectZoom': { + name: t('attributeWebSelectZoom'), + type: 'number', + }, + 'web.maxZoom': { + name: t('attributeWebMaxZoom'), + type: 'number', + }, 'ui.hidePositionAttributes': { name: t('attributeUiHidePositionAttributes'), type: 'string', diff --git a/modern/src/common/util/useFeatures.js b/modern/src/common/util/useFeatures.js new file mode 100644 index 00000000..f0a8299a --- /dev/null +++ b/modern/src/common/util/useFeatures.js @@ -0,0 +1,30 @@ +import { useSelector } from 'react-redux'; + +const get = (server, user, key) => { + if (server && user) { + if (server.forceSettings) { + return server.attributes[key] || user.attributes[key] || false; + } + return user.attributes[key] || server.attributes[key] || false; + } + return false; +}; + +export default () => useSelector((state) => { + const { server, user } = state.session; + + const disableVehicleFetures = get(server, user, 'ui.disableVehicleFetures'); + const disableDrivers = disableVehicleFetures || get(server, user, 'ui.disableDrivers'); + const disableMaintenance = disableVehicleFetures || get(server, user, 'ui.disableMaintenance'); + const disableEvents = get(server, user, 'ui.disableEvents'); + const disableComputedAttributes = get(server, user, 'ui.disableComputedAttributes'); + const disableCalendars = get(server, user, 'ui.disableCalendars'); + + return { + disableDrivers, + disableMaintenance, + disableEvents, + disableComputedAttributes, + disableCalendars, + }; +}); |