aboutsummaryrefslogtreecommitdiff
path: root/modern/src/settings
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/settings')
-rw-r--r--modern/src/settings/DevicePage.js59
-rw-r--r--modern/src/settings/GroupPage.js59
-rw-r--r--modern/src/settings/components/SettingsMenu.js59
3 files changed, 103 insertions, 74 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>
)}
diff --git a/modern/src/settings/GroupPage.js b/modern/src/settings/GroupPage.js
index b817ba7e..c4c0fa5c 100644
--- a/modern/src/settings/GroupPage.js
+++ b/modern/src/settings/GroupPage.js
@@ -15,6 +15,7 @@ import SettingsMenu from './components/SettingsMenu';
import useCommonDeviceAttributes from '../common/attributes/useCommonDeviceAttributes';
import useGroupAttributes from '../common/attributes/useGroupAttributes';
import { prefixString } from '../common/util/stringUtils';
+import useFeatures from '../common/util/useFeatures';
const useStyles = makeStyles((theme) => ({
details: {
@@ -32,6 +33,8 @@ const GroupPage = () => {
const commonDeviceAttributes = useCommonDeviceAttributes(t);
const groupAttributes = useGroupAttributes(t);
+ const features = useFeatures();
+
const [item, setItem] = useState();
const validate = () => item && item.name;
@@ -115,23 +118,27 @@ const GroupPage = () => {
titleGetter={(it) => t(prefixString('event', it.type))}
label={t('sharedNotifications')}
/>
- <LinkField
- endpointAll="/api/drivers"
- endpointLinked={`/api/drivers?groupId=${item.id}`}
- baseId={item.id}
- keyBase="groupId"
- keyLink="driverId"
- label={t('sharedDrivers')}
- />
- <LinkField
- endpointAll="/api/attributes/computed"
- endpointLinked={`/api/attributes/computed?groupId=${item.id}`}
- baseId={item.id}
- keyBase="groupId"
- keyLink="attributeId"
- titleGetter={(it) => it.description}
- label={t('sharedComputedAttributes')}
- />
+ {!features.disableDrivers && (
+ <LinkField
+ endpointAll="/api/drivers"
+ endpointLinked={`/api/drivers?groupId=${item.id}`}
+ baseId={item.id}
+ keyBase="groupId"
+ keyLink="driverId"
+ label={t('sharedDrivers')}
+ />
+ )}
+ {!features.disableComputedAttributes && (
+ <LinkField
+ endpointAll="/api/attributes/computed"
+ endpointLinked={`/api/attributes/computed?groupId=${item.id}`}
+ baseId={item.id}
+ keyBase="groupId"
+ keyLink="attributeId"
+ titleGetter={(it) => it.description}
+ label={t('sharedComputedAttributes')}
+ />
+ )}
<LinkField
endpointAll="/api/commands"
endpointLinked={`/api/commands?groupId=${item.id}`}
@@ -141,14 +148,16 @@ const GroupPage = () => {
titleGetter={(it) => it.description}
label={t('sharedSavedCommands')}
/>
- <LinkField
- endpointAll="/api/maintenance"
- endpointLinked={`/api/maintenance?groupId=${item.id}`}
- baseId={item.id}
- keyBase="groupId"
- keyLink="maintenanceId"
- label={t('sharedMaintenance')}
- />
+ {!features.disableMaintenance && (
+ <LinkField
+ endpointAll="/api/maintenance"
+ endpointLinked={`/api/maintenance?groupId=${item.id}`}
+ baseId={item.id}
+ keyBase="groupId"
+ keyLink="maintenanceId"
+ label={t('sharedMaintenance')}
+ />
+ )}
</AccordionDetails>
</Accordion>
)}
diff --git a/modern/src/settings/components/SettingsMenu.js b/modern/src/settings/components/SettingsMenu.js
index fae3ad86..ef5b07d7 100644
--- a/modern/src/settings/components/SettingsMenu.js
+++ b/modern/src/settings/components/SettingsMenu.js
@@ -16,6 +16,7 @@ import { Link, useLocation } from 'react-router-dom';
import { useSelector } from 'react-redux';
import { useTranslation } from '../../common/components/LocalizationProvider';
import { useAdministrator, useManager, useReadonly } from '../../common/util/permissions';
+import useFeatures from '../../common/util/useFeatures';
const MenuItem = ({
title, link, icon, selected,
@@ -35,6 +36,8 @@ const SettingsMenu = () => {
const manager = useManager();
const userId = useSelector((state) => state.session.user?.id);
+ const features = useFeatures();
+
return (
<>
<List>
@@ -70,30 +73,38 @@ const SettingsMenu = () => {
icon={<FolderIcon />}
selected={location.pathname.startsWith('/settings/group')}
/>
- <MenuItem
- title={t('sharedDrivers')}
- link="/settings/drivers"
- icon={<PersonIcon />}
- selected={location.pathname.startsWith('/settings/driver')}
- />
- <MenuItem
- title={t('sharedCalendars')}
- link="/settings/calendars"
- icon={<TodayIcon />}
- selected={location.pathname.startsWith('/settings/calendar')}
- />
- <MenuItem
- title={t('sharedComputedAttributes')}
- link="/settings/attributes"
- icon={<StorageIcon />}
- selected={location.pathname.startsWith('/settings/attribute')}
- />
- <MenuItem
- title={t('sharedMaintenance')}
- link="/settings/maintenances"
- icon={<BuildIcon />}
- selected={location.pathname.startsWith('/settings/maintenance')}
- />
+ {!features.disableDrivers && (
+ <MenuItem
+ title={t('sharedDrivers')}
+ link="/settings/drivers"
+ icon={<PersonIcon />}
+ selected={location.pathname.startsWith('/settings/driver')}
+ />
+ )}
+ {!features.disableCalendars && (
+ <MenuItem
+ title={t('sharedCalendars')}
+ link="/settings/calendars"
+ icon={<TodayIcon />}
+ selected={location.pathname.startsWith('/settings/calendar')}
+ />
+ )}
+ {!features.disableComputedAttributes && (
+ <MenuItem
+ title={t('sharedComputedAttributes')}
+ link="/settings/attributes"
+ icon={<StorageIcon />}
+ selected={location.pathname.startsWith('/settings/attribute')}
+ />
+ )}
+ {!features.disableMaintenance && (
+ <MenuItem
+ title={t('sharedMaintenance')}
+ link="/settings/maintenances"
+ icon={<BuildIcon />}
+ selected={location.pathname.startsWith('/settings/maintenance')}
+ />
+ )}
<MenuItem
title={t('sharedSavedCommands')}
link="/settings/commands"