From f0614dc939051aab3544874b44510c59c683be10 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 17 Mar 2024 12:35:48 -0700 Subject: Option to disable saved commands --- .../src/common/attributes/useCommonUserAttributes.js | 4 ++++ modern/src/common/util/useFeatures.js | 2 ++ modern/src/resources/l10n/en.json | 1 + modern/src/settings/DeviceConnectionsPage.jsx | 20 +++++++++++--------- modern/src/settings/GroupConnectionsPage.jsx | 20 +++++++++++--------- modern/src/settings/components/SettingsMenu.jsx | 14 ++++++++------ 6 files changed, 37 insertions(+), 24 deletions(-) (limited to 'modern') diff --git a/modern/src/common/attributes/useCommonUserAttributes.js b/modern/src/common/attributes/useCommonUserAttributes.js index 1f811e56..294ddea8 100644 --- a/modern/src/common/attributes/useCommonUserAttributes.js +++ b/modern/src/common/attributes/useCommonUserAttributes.js @@ -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', diff --git a/modern/src/common/util/useFeatures.js b/modern/src/common/util/useFeatures.js index cafb2c7c..30361589 100644 --- a/modern/src/common/util/useFeatures.js +++ b/modern/src/common/util/useFeatures.js @@ -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, diff --git a/modern/src/resources/l10n/en.json b/modern/src/resources/l10n/en.json index 39fb219b..a9303f63 100644 --- a/modern/src/resources/l10n/en.json +++ b/modern/src/resources/l10n/en.json @@ -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", diff --git a/modern/src/settings/DeviceConnectionsPage.jsx b/modern/src/settings/DeviceConnectionsPage.jsx index 10d0c3f6..c711d719 100644 --- a/modern/src/settings/DeviceConnectionsPage.jsx +++ b/modern/src/settings/DeviceConnectionsPage.jsx @@ -76,15 +76,17 @@ const DeviceConnectionsPage = () => { label={t('sharedComputedAttributes')} /> )} - it.description} - label={t('sharedSavedCommands')} - /> + {!features.disableSavedCommands && ( + it.description} + label={t('sharedSavedCommands')} + /> + )} {!features.disableMaintenance && ( { label={t('sharedComputedAttributes')} /> )} - it.description} - label={t('sharedSavedCommands')} - /> + {!features.disableSavedCommands && ( + it.description} + label={t('sharedSavedCommands')} + /> + )} {!features.disableMaintenance && ( { selected={location.pathname.startsWith('/settings/maintenance')} /> )} - } - selected={location.pathname.startsWith('/settings/command')} - /> + {!features.disableSavedCommands && ( + } + selected={location.pathname.startsWith('/settings/command')} + /> + )} {supportLink && (