aboutsummaryrefslogtreecommitdiff
path: root/modern/src
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-05-22 17:22:36 -0700
committerAnton Tananaev <anton@traccar.org>2023-05-22 17:22:36 -0700
commit59affb12da6b7469912b0333042d040fa550a6a0 (patch)
tree43c7eb03ef1e8fc02eccc1f07adc29d5097de98d /modern/src
parent7f978889b45672285da1e73461e67bc78e78e1bb (diff)
downloadtrackermap-web-59affb12da6b7469912b0333042d040fa550a6a0.tar.gz
trackermap-web-59affb12da6b7469912b0333042d040fa550a6a0.tar.bz2
trackermap-web-59affb12da6b7469912b0333042d040fa550a6a0.zip
Hide option if SMS disabled (fix #1126)
Diffstat (limited to 'modern/src')
-rw-r--r--modern/src/settings/CommandGroupPage.js13
-rw-r--r--modern/src/settings/components/BaseCommandView.js13
2 files changed, 18 insertions, 8 deletions
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')}
/>
- <FormControlLabel
- control={<Checkbox checked={item.textChannel} onChange={(event) => setItem({ ...item, textChannel: event.target.checked })} />}
- label={t('commandSendSms')}
- />
+ {textEnabled && (
+ <FormControlLabel
+ control={<Checkbox checked={item.textChannel} onChange={(event) => setItem({ ...item, textChannel: event.target.checked })} />}
+ label={t('commandSendSms')}
+ />
+ )}
</AccordionDetails>
</Accordion>
<div className={classes.buttons}>
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 }) => {
/>
);
})}
- <FormControlLabel
- control={<Checkbox checked={item.textChannel} onChange={(event) => setItem({ ...item, textChannel: event.target.checked })} />}
- label={t('commandSendSms')}
- />
+ {textEnabled && (
+ <FormControlLabel
+ control={<Checkbox checked={item.textChannel} onChange={(event) => setItem({ ...item, textChannel: event.target.checked })} />}
+ label={t('commandSendSms')}
+ />
+ )}
</>
);
};