From 59affb12da6b7469912b0333042d040fa550a6a0 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 22 May 2023 17:22:36 -0700 Subject: Hide option if SMS disabled (fix #1126) --- modern/src/settings/CommandGroupPage.js | 13 +++++++++---- modern/src/settings/components/BaseCommandView.js | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) (limited to 'modern/src') diff --git a/modern/src/settings/CommandGroupPage.js b/modern/src/settings/CommandGroupPage.js index b4852c26..e2ba3946 100644 --- a/modern/src/settings/CommandGroupPage.js +++ b/modern/src/settings/CommandGroupPage.js @@ -1,4 +1,5 @@ import React, { useState } from 'react'; +import { useSelector } from 'react-redux'; import { useNavigate, useParams } from 'react-router-dom'; import { Accordion, @@ -50,6 +51,8 @@ const CommandDevicePage = () => { const { id } = useParams(); + const textEnabled = useSelector((state) => state.session.server.textEnabled); + const [item, setItem] = useState({ type: 'custom', attributes: {} }); const handleSend = useCatch(async () => { @@ -88,10 +91,12 @@ const CommandDevicePage = () => { onChange={(e) => setItem({ ...item, attributes: { ...item.attributes, data: e.target.value } })} label={t('commandData')} /> - setItem({ ...item, textChannel: event.target.checked })} />} - label={t('commandSendSms')} - /> + {textEnabled && ( + setItem({ ...item, textChannel: event.target.checked })} />} + label={t('commandSendSms')} + /> + )}
diff --git a/modern/src/settings/components/BaseCommandView.js b/modern/src/settings/components/BaseCommandView.js index 1ba6a37c..acf39090 100644 --- a/modern/src/settings/components/BaseCommandView.js +++ b/modern/src/settings/components/BaseCommandView.js @@ -1,4 +1,5 @@ import React, { useEffect, useState } from 'react'; +import { useSelector } from 'react-redux'; import { TextField, FormControlLabel, Checkbox, } from '@mui/material'; @@ -10,6 +11,8 @@ import useCommandAttributes from '../../common/attributes/useCommandAttributes'; const BaseCommandView = ({ deviceId, item, setItem }) => { const t = useTranslation(); + const textEnabled = useSelector((state) => state.session.server.textEnabled); + const availableAttributes = useCommandAttributes(t); const [attributes, setAttributes] = useState([]); @@ -63,10 +66,12 @@ const BaseCommandView = ({ deviceId, item, setItem }) => { /> ); })} - setItem({ ...item, textChannel: event.target.checked })} />} - label={t('commandSendSms')} - /> + {textEnabled && ( + setItem({ ...item, textChannel: event.target.checked })} />} + label={t('commandSendSms')} + /> + )} ); }; -- cgit v1.2.3