Option to disable saved commands

This commit is contained in:
Anton Tananaev 2024-03-17 12:35:48 -07:00
parent 7016950dac
commit f0614dc939
6 changed files with 37 additions and 24 deletions

View File

@ -81,6 +81,10 @@ export default (t) => useMemo(() => ({
name: t('attributeNotificationTokens'),
type: 'string',
},
'ui.disableSavedCommands': {
name: t('attributeUiDisableSavedCommands'),
type: 'boolean',
},
'ui.disableGroups': {
name: t('attributeUiDisableGroups'),
type: 'boolean',

View File

@ -18,6 +18,7 @@ const featureSelector = createSelector(
(state) => state.session.server,
(state) => state.session.user,
(server, user) => {
const disableSavedCommands = get(server, user, 'ui.disableSavedCommands');
const disableAttributes = get(server, user, 'ui.disableAttributes');
const disableVehicleFeatures = get(server, user, 'ui.disableVehicleFeatures');
const disableDrivers = disableVehicleFeatures || get(server, user, 'ui.disableDrivers');
@ -28,6 +29,7 @@ const featureSelector = createSelector(
const disableCalendars = get(server, user, 'ui.disableCalendars');
return {
disableSavedCommands,
disableAttributes,
disableDrivers,
disableMaintenance,

View File

@ -147,6 +147,7 @@
"attributeMailSmtpAuth": "Mail: SMTP Auth Enable",
"attributeMailSmtpUsername": "Mail: SMTP Username",
"attributeMailSmtpPassword": "Mail: SMTP Password",
"attributeUiDisableSavedCommands": "UI: Disable Saved Commands",
"attributeUiDisableAttributes": "UI: Disable Attributes",
"attributeUiDisableGroups": "UI: Disable Groups",
"attributeUiDisableEvents": "UI: Disable Events",

View File

@ -76,15 +76,17 @@ const DeviceConnectionsPage = () => {
label={t('sharedComputedAttributes')}
/>
)}
<LinkField
endpointAll="/api/commands"
endpointLinked={`/api/commands?deviceId=${id}`}
baseId={id}
keyBase="deviceId"
keyLink="commandId"
titleGetter={(it) => it.description}
label={t('sharedSavedCommands')}
/>
{!features.disableSavedCommands && (
<LinkField
endpointAll="/api/commands"
endpointLinked={`/api/commands?deviceId=${id}`}
baseId={id}
keyBase="deviceId"
keyLink="commandId"
titleGetter={(it) => it.description}
label={t('sharedSavedCommands')}
/>
)}
{!features.disableMaintenance && (
<LinkField
endpointAll="/api/maintenance"

View File

@ -76,15 +76,17 @@ const GroupConnectionsPage = () => {
label={t('sharedComputedAttributes')}
/>
)}
<LinkField
endpointAll="/api/commands"
endpointLinked={`/api/commands?groupId=${id}`}
baseId={id}
keyBase="groupId"
keyLink="commandId"
titleGetter={(it) => it.description}
label={t('sharedSavedCommands')}
/>
{!features.disableSavedCommands && (
<LinkField
endpointAll="/api/commands"
endpointLinked={`/api/commands?groupId=${id}`}
baseId={id}
keyBase="groupId"
keyLink="commandId"
titleGetter={(it) => it.description}
label={t('sharedSavedCommands')}
/>
)}
{!features.disableMaintenance && (
<LinkField
endpointAll="/api/maintenance"

View File

@ -119,12 +119,14 @@ const SettingsMenu = () => {
selected={location.pathname.startsWith('/settings/maintenance')}
/>
)}
<MenuItem
title={t('sharedSavedCommands')}
link="/settings/commands"
icon={<PublishIcon />}
selected={location.pathname.startsWith('/settings/command')}
/>
{!features.disableSavedCommands && (
<MenuItem
title={t('sharedSavedCommands')}
link="/settings/commands"
icon={<PublishIcon />}
selected={location.pathname.startsWith('/settings/command')}
/>
)}
{supportLink && (
<MenuItem
title={t('settingsSupport')}