diff options
author | Anton Tananaev <anton@traccar.org> | 2022-05-04 18:02:01 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-05-04 18:02:01 -0700 |
commit | 05623d59c14896da5ac1b2527e93d4af50ec87b6 (patch) | |
tree | 6e9dfb5d6f969b3b46b2725ca8bb264a86685111 /modern/src/EditCollectionView.js | |
parent | 53fd7f27b8a84b49ef7e4dafbc9e8ac985d7f3af (diff) | |
download | trackermap-web-05623d59c14896da5ac1b2527e93d4af50ec87b6.tar.gz trackermap-web-05623d59c14896da5ac1b2527e93d4af50ec87b6.tar.bz2 trackermap-web-05623d59c14896da5ac1b2527e93d4af50ec87b6.zip |
Handle user permissions
Diffstat (limited to 'modern/src/EditCollectionView.js')
-rw-r--r-- | modern/src/EditCollectionView.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/modern/src/EditCollectionView.js b/modern/src/EditCollectionView.js index 59a91c60..c167a53c 100644 --- a/modern/src/EditCollectionView.js +++ b/modern/src/EditCollectionView.js @@ -5,11 +5,11 @@ import Menu from '@material-ui/core/Menu'; import MenuItem from '@material-ui/core/MenuItem'; import Fab from '@material-ui/core/Fab'; import AddIcon from '@material-ui/icons/Add'; -import { useSelector } from 'react-redux'; import RemoveDialog from './RemoveDialog'; import { useTranslation } from './LocalizationProvider'; import dimensions from './theme/dimensions'; +import { useEditable } from './common/permissions'; const useStyles = makeStyles((theme) => ({ fab: { @@ -29,11 +29,12 @@ const EditCollectionView = ({ const history = useHistory(); const t = useTranslation(); + const editable = useEditable(); + const [selectedId, setSelectedId] = useState(null); const [selectedAnchorEl, setSelectedAnchorEl] = useState(null); const [removeDialogShown, setRemoveDialogShown] = useState(false); const [updateTimestamp, setUpdateTimestamp] = useState(Date.now()); - const adminEnabled = useSelector((state) => state.session.user && state.session.user.administrator); const menuShow = (anchorId, itemId) => { setSelectedAnchorEl(anchorId); @@ -69,7 +70,7 @@ const EditCollectionView = ({ return ( <> <Content updateTimestamp={updateTimestamp} onMenuClick={menuShow} filter={filter} /> - {adminEnabled && !disableAdd && ( + {editable && !disableAdd && ( <Fab size="medium" color="primary" className={classes.fab} onClick={handleAdd}> <AddIcon /> </Fab> |