diff options
author | Anton Tananaev <anton@traccar.org> | 2022-06-22 09:10:05 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-06-22 09:10:05 -0700 |
commit | adca1297c6eebefdcdb6a5be25adc2f2b9d15559 (patch) | |
tree | 85408a68b4e236bab1d961641200c977ef64a514 /modern/src/main | |
parent | 50a97b2ec3a3a22955cae8bfd6a766b3abb2cf27 (diff) | |
download | trackermap-web-adca1297c6eebefdcdb6a5be25adc2f2b9d15559.tar.gz trackermap-web-adca1297c6eebefdcdb6a5be25adc2f2b9d15559.tar.bz2 trackermap-web-adca1297c6eebefdcdb6a5be25adc2f2b9d15559.zip |
List items and disabled device
Diffstat (limited to 'modern/src/main')
-rw-r--r-- | modern/src/main/DevicesList.js | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/modern/src/main/DevicesList.js b/modern/src/main/DevicesList.js index baf18dd8..e1db7853 100644 --- a/modern/src/main/DevicesList.js +++ b/modern/src/main/DevicesList.js @@ -1,12 +1,9 @@ import React, { useRef } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import makeStyles from '@mui/styles/makeStyles'; -import { IconButton, Tooltip } from '@mui/material'; -import Avatar from '@mui/material/Avatar'; -import List from '@mui/material/List'; -import ListItem from '@mui/material/ListItem'; -import ListItemAvatar from '@mui/material/ListItemAvatar'; -import ListItemText from '@mui/material/ListItemText'; +import { + IconButton, Tooltip, Avatar, List, ListItemAvatar, ListItemText, ListItemButton, +} from '@mui/material'; import { FixedSizeList } from 'react-window'; import AutoSizer from 'react-virtualized-auto-sizer'; import BatteryFullIcon from '@mui/icons-material/BatteryFull'; @@ -26,6 +23,7 @@ import { } from '../common/util/formatter'; import { useTranslation } from '../common/components/LocalizationProvider'; import { mapIcons } from '../map/core/preloadImages'; +import { useAdministrator } from '../common/util/permissions'; const useStyles = makeStyles((theme) => ({ list: { @@ -70,6 +68,8 @@ const DeviceRow = ({ data, index, style }) => { const dispatch = useDispatch(); const t = useTranslation(); + const admin = useAdministrator(); + const { items } = data; const item = items[index]; const position = useSelector((state) => state.positions.items[item.id]); @@ -83,7 +83,12 @@ const DeviceRow = ({ data, index, style }) => { return ( <div style={style}> - <ListItem button key={item.id} className={classes.listItem} onClick={() => dispatch(devicesActions.select(item.id))}> + <ListItemButton + key={item.id} + className={classes.listItem} + onClick={() => dispatch(devicesActions.select(item.id))} + disabled={!admin && item.disabled} + > <ListItemAvatar> <Avatar> <img className={classes.icon} src={mapIcons[item.category || 'default']} alt="" /> @@ -137,7 +142,7 @@ const DeviceRow = ({ data, index, style }) => { )} </> )} - </ListItem> + </ListItemButton> </div> ); }; |