diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-03 16:22:21 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-03 16:22:21 -0700 |
commit | b418d001a498b5a5108bb13983b4f3aba6c60dbc (patch) | |
tree | 464dd5e4fc3f13a6209c05df4d3db3cbbe8e85d6 /modern/src/settings/DevicePage.js | |
parent | 5d17af8102f17d41610acb9ff34aabbff871cda1 (diff) | |
download | trackermap-web-b418d001a498b5a5108bb13983b4f3aba6c60dbc.tar.gz trackermap-web-b418d001a498b5a5108bb13983b4f3aba6c60dbc.tar.bz2 trackermap-web-b418d001a498b5a5108bb13983b4f3aba6c60dbc.zip |
Support feature disabling
Diffstat (limited to 'modern/src/settings/DevicePage.js')
-rw-r--r-- | modern/src/settings/DevicePage.js | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/modern/src/settings/DevicePage.js b/modern/src/settings/DevicePage.js index d7b67b0b..fb49dbcc 100644 --- a/modern/src/settings/DevicePage.js +++ b/modern/src/settings/DevicePage.js @@ -22,6 +22,7 @@ import useDeviceAttributes from '../common/attributes/useDeviceAttributes'; import { useAdministrator } from '../common/util/permissions'; import SettingsMenu from './components/SettingsMenu'; import useCommonDeviceAttributes from '../common/attributes/useCommonDeviceAttributes'; +import useFeatures from '../common/util/useFeatures'; const useStyles = makeStyles((theme) => ({ details: { @@ -41,6 +42,8 @@ const DevicePage = () => { const commonDeviceAttributes = useCommonDeviceAttributes(t); const deviceAttributes = useDeviceAttributes(t); + const features = useFeatures(); + const [item, setItem] = useState(); const validate = () => item && item.name && item.uniqueId; @@ -160,23 +163,27 @@ const DevicePage = () => { titleGetter={(it) => t(prefixString('event', it.type))} label={t('sharedNotifications')} /> - <LinkField - endpointAll="/api/drivers" - endpointLinked={`/api/drivers?deviceId=${item.id}`} - baseId={item.id} - keyBase="deviceId" - keyLink="driverId" - label={t('sharedDrivers')} - /> - <LinkField - endpointAll="/api/attributes/computed" - endpointLinked={`/api/attributes/computed?deviceId=${item.id}`} - baseId={item.id} - keyBase="deviceId" - keyLink="attributeId" - titleGetter={(it) => it.description} - label={t('sharedComputedAttributes')} - /> + {!features.disableDrivers && ( + <LinkField + endpointAll="/api/drivers" + endpointLinked={`/api/drivers?deviceId=${item.id}`} + baseId={item.id} + keyBase="deviceId" + keyLink="driverId" + label={t('sharedDrivers')} + /> + )} + {!features.disableComputedAttributes && ( + <LinkField + endpointAll="/api/attributes/computed" + endpointLinked={`/api/attributes/computed?deviceId=${item.id}`} + baseId={item.id} + keyBase="deviceId" + keyLink="attributeId" + titleGetter={(it) => it.description} + label={t('sharedComputedAttributes')} + /> + )} <LinkField endpointAll="/api/commands" endpointLinked={`/api/commands?deviceId=${item.id}`} @@ -186,14 +193,16 @@ const DevicePage = () => { titleGetter={(it) => it.description} label={t('sharedSavedCommands')} /> - <LinkField - endpointAll="/api/maintenance" - endpointLinked={`/api/maintenance?deviceId=${item.id}`} - baseId={item.id} - keyBase="deviceId" - keyLink="maintenanceId" - label={t('sharedMaintenance')} - /> + {!features.disableMaintenance && ( + <LinkField + endpointAll="/api/maintenance" + endpointLinked={`/api/maintenance?deviceId=${item.id}`} + baseId={item.id} + keyBase="deviceId" + keyLink="maintenanceId" + label={t('sharedMaintenance')} + /> + )} </AccordionDetails> </Accordion> )} |