From e5b727e1bc85e6c38a15c8917aae57a70533da46 Mon Sep 17 00:00:00 2001 From: Desmond Kyeremeh Date: Thu, 1 Jul 2021 14:03:37 +0000 Subject: Apply OptionsLayout to settings pages --- modern/src/settings/ComputedAttributesPage.js | 34 +++++++++++++++++---------- modern/src/settings/DriversPage.js | 26 ++++++++++++-------- modern/src/settings/GroupsPage.js | 26 ++++++++++++-------- modern/src/settings/MaintenancesPage.js | 26 ++++++++++++-------- modern/src/settings/NotificationsPage.js | 32 ++++++++++++++++--------- 5 files changed, 90 insertions(+), 54 deletions(-) (limited to 'modern/src') diff --git a/modern/src/settings/ComputedAttributesPage.js b/modern/src/settings/ComputedAttributesPage.js index 1a6feab..49c35d6 100644 --- a/modern/src/settings/ComputedAttributesPage.js +++ b/modern/src/settings/ComputedAttributesPage.js @@ -6,19 +6,22 @@ import { useSelector } from 'react-redux'; import t from '../common/localization'; import { useEffectAsync } from '../reactHelper'; import EditCollectionView from '../EditCollectionView'; +import OptionsLayout from './OptionsLayout'; const useStyles = makeStyles(theme => ({ columnAction: { width: theme.spacing(1), - padding: theme.spacing(0, 1), - }, + padding: theme.spacing(0, 1) + } })); const ComputedAttributeView = ({ updateTimestamp, onMenuClick }) => { const classes = useStyles(); const [items, setItems] = useState([]); - const adminEnabled = useSelector(state => state.session.user && state.session.user.administrator); + const adminEnabled = useSelector( + state => state.session.user && state.session.user.administrator + ); useEffectAsync(async () => { const response = await fetch('/api/attributes/computed'); @@ -40,15 +43,17 @@ const ComputedAttributeView = ({ updateTimestamp, onMenuClick }) => { - {items.map((item) => ( + {items.map(item => ( - {adminEnabled && + {adminEnabled && ( - onMenuClick(event.currentTarget, item.id)}> + onMenuClick(event.currentTarget, item.id)} + > - } + )} {item.description} {item.attribute} {item.expression} @@ -59,15 +64,18 @@ const ComputedAttributeView = ({ updateTimestamp, onMenuClick }) => { ); -} +}; const ComputedAttributesPage = () => { return ( - <> - - - + + + ); -} +}; export default ComputedAttributesPage; diff --git a/modern/src/settings/DriversPage.js b/modern/src/settings/DriversPage.js index 957e225..13cb1c6 100644 --- a/modern/src/settings/DriversPage.js +++ b/modern/src/settings/DriversPage.js @@ -5,12 +5,13 @@ import MoreVertIcon from '@material-ui/icons/MoreVert'; import t from '../common/localization'; import { useEffectAsync } from '../reactHelper'; import EditCollectionView from '../EditCollectionView'; +import OptionsLayout from './OptionsLayout'; const useStyles = makeStyles(theme => ({ columnAction: { width: theme.spacing(1), - padding: theme.spacing(0, 1), - }, + padding: theme.spacing(0, 1) + } })); const DriversView = ({ updateTimestamp, onMenuClick }) => { @@ -36,10 +37,12 @@ const DriversView = ({ updateTimestamp, onMenuClick }) => { - {items.map((item) => ( + {items.map(item => ( - onMenuClick(event.currentTarget, item.id)}> + onMenuClick(event.currentTarget, item.id)} + > @@ -51,15 +54,18 @@ const DriversView = ({ updateTimestamp, onMenuClick }) => { ); -} +}; const DriversPage = () => { return ( - <> - - - + + + ); -} +}; export default DriversPage; diff --git a/modern/src/settings/GroupsPage.js b/modern/src/settings/GroupsPage.js index e274062..2de6241 100644 --- a/modern/src/settings/GroupsPage.js +++ b/modern/src/settings/GroupsPage.js @@ -5,12 +5,13 @@ import MoreVertIcon from '@material-ui/icons/MoreVert'; import t from '../common/localization'; import { useEffectAsync } from '../reactHelper'; import EditCollectionView from '../EditCollectionView'; +import OptionsLayout from './OptionsLayout'; const useStyles = makeStyles(theme => ({ columnAction: { width: theme.spacing(1), - padding: theme.spacing(0, 1), - }, + padding: theme.spacing(0, 1) + } })); const GroupsView = ({ updateTimestamp, onMenuClick }) => { @@ -35,10 +36,12 @@ const GroupsView = ({ updateTimestamp, onMenuClick }) => { - {items.map((item) => ( + {items.map(item => ( - onMenuClick(event.currentTarget, item.id)}> + onMenuClick(event.currentTarget, item.id)} + > @@ -49,15 +52,18 @@ const GroupsView = ({ updateTimestamp, onMenuClick }) => { ); -} +}; const GroupsPage = () => { return ( - <> - - - + + + ); -} +}; export default GroupsPage; diff --git a/modern/src/settings/MaintenancesPage.js b/modern/src/settings/MaintenancesPage.js index 7ba4bd2..3fd0b39 100644 --- a/modern/src/settings/MaintenancesPage.js +++ b/modern/src/settings/MaintenancesPage.js @@ -9,12 +9,13 @@ import EditCollectionView from '../EditCollectionView'; import positionAttributes from '../attributes/positionAttributes'; import { formatDistance, formatSpeed } from '../common/formatter'; import { useAttributePreference } from '../common/preferences'; +import OptionsLayout from './OptionsLayout'; const useStyles = makeStyles(theme => ({ columnAction: { width: theme.spacing(1), - padding: theme.spacing(0, 1), - }, + padding: theme.spacing(0, 1) + } })); const MaintenancesView = ({ updateTimestamp, onMenuClick }) => { @@ -45,7 +46,7 @@ const MaintenancesView = ({ updateTimestamp, onMenuClick }) => { } return value; - } + }; return ( @@ -63,7 +64,9 @@ const MaintenancesView = ({ updateTimestamp, onMenuClick }) => { {items.map(item => ( - onMenuClick(event.currentTarget, item.id)}> + onMenuClick(event.currentTarget, item.id)} + > @@ -77,15 +80,18 @@ const MaintenancesView = ({ updateTimestamp, onMenuClick }) => { ); -} +}; const MaintenacesPage = () => { return ( - <> - - - + + + ); -} +}; export default MaintenacesPage; diff --git a/modern/src/settings/NotificationsPage.js b/modern/src/settings/NotificationsPage.js index 15da0de..3756e96 100644 --- a/modern/src/settings/NotificationsPage.js +++ b/modern/src/settings/NotificationsPage.js @@ -7,12 +7,13 @@ import { useEffectAsync } from '../reactHelper'; import EditCollectionView from '../EditCollectionView'; import { prefixString } from '../common/stringUtils'; import { formatBoolean } from '../common/formatter'; +import OptionsLayout from './OptionsLayout'; const useStyles = makeStyles(theme => ({ columnAction: { width: theme.spacing(1), - padding: theme.spacing(0, 1), - }, + padding: theme.spacing(0, 1) + } })); const NotificationsView = ({ updateTimestamp, onMenuClick }) => { @@ -54,29 +55,38 @@ const NotificationsView = ({ updateTimestamp, onMenuClick }) => { {items.map(item => ( - onMenuClick(event.currentTarget, item.id)}> + onMenuClick(event.currentTarget, item.id)} + > {t(prefixString('event', item.type))} {formatBoolean(item.always)} - {formatList('alarm', item.attributes.alarms)} - {formatList('notificator', item.notificators)} + + {formatList('alarm', item.attributes.alarms)} + + + {formatList('notificator', item.notificators)} + ))} ); -} +}; const NotificationsPage = () => { return ( - <> - - - + + + ); -} +}; export default NotificationsPage; -- cgit v1.2.3