From 1beb6c174a0622126d704ecc2dd26a8d1b70460d Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 5 Sep 2022 11:08:49 -0700 Subject: Handle limit commands --- modern/src/common/components/SelectField.js | 5 +++-- modern/src/settings/CommandSendPage.js | 6 +++++- modern/src/settings/CommandsPage.js | 16 ++++++++++------ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/modern/src/common/components/SelectField.js b/modern/src/common/components/SelectField.js index bbc661c2..2ee2f147 100644 --- a/modern/src/common/components/SelectField.js +++ b/modern/src/common/components/SelectField.js @@ -39,8 +39,9 @@ const SelectField = ({ value={value} onChange={onChange} > - {!multiple && emptyValue !== null - && {emptyTitle}} + {!multiple && emptyValue !== null && ( + {emptyTitle} + )} {items.map((item) => ( {titleGetter(item)} ))} diff --git a/modern/src/settings/CommandSendPage.js b/modern/src/settings/CommandSendPage.js index 55e26ec8..d853f995 100644 --- a/modern/src/settings/CommandSendPage.js +++ b/modern/src/settings/CommandSendPage.js @@ -16,6 +16,7 @@ import SelectField from '../common/components/SelectField'; import PageLayout from '../common/components/PageLayout'; import SettingsMenu from './components/SettingsMenu'; import { useCatch } from '../reactHelper'; +import { useRestriction } from '../common/util/permissions'; const useStyles = makeStyles((theme) => ({ container: { @@ -48,6 +49,8 @@ const CommandSendPage = () => { const [savedId, setSavedId] = useState(0); const [item, setItem] = useState({}); + const limitCommands = useRestriction('limitCommands'); + const handleSend = useCatch(async () => { let command; if (savedId) { @@ -90,13 +93,14 @@ const CommandSendPage = () => { setSavedId(e.target.value)} endpoint={`/api/commands/send?deviceId=${deviceId}`} titleGetter={(it) => it.description} label={t('sharedSavedCommand')} /> - {!savedId && ( + {!limitCommands && !savedId && ( )} diff --git a/modern/src/settings/CommandsPage.js b/modern/src/settings/CommandsPage.js index 80ee7df1..01acb33e 100644 --- a/modern/src/settings/CommandsPage.js +++ b/modern/src/settings/CommandsPage.js @@ -13,6 +13,7 @@ import CollectionFab from './components/CollectionFab'; import CollectionActions from './components/CollectionActions'; import TableShimmer from '../common/components/TableShimmer'; import SearchHeader, { filterByKeyword } from './components/SearchHeader'; +import { useRestriction } from '../common/util/permissions'; const useStyles = makeStyles((theme) => ({ columnAction: { @@ -29,6 +30,7 @@ const CommandsPage = () => { const [items, setItems] = useState([]); const [searchKeyword, setSearchKeyword] = useState(''); const [loading, setLoading] = useState(false); + const limitCommands = useRestriction('limitCommands'); useEffectAsync(async () => { setLoading(true); @@ -53,7 +55,7 @@ const CommandsPage = () => { {t('sharedDescription')} {t('sharedType')} {t('commandSendSms')} - + {!limitCommands && } @@ -62,14 +64,16 @@ const CommandsPage = () => { {item.description} {t(prefixString('command', item.type))} {formatBoolean(item.textChannel, t)} - - - + {!limitCommands && ( + + + + )} - )) : ()} + )) : ()} - + ); }; -- cgit v1.2.3