aboutsummaryrefslogtreecommitdiff
path: root/modern/src/EditCollectionView.js
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/EditCollectionView.js')
-rw-r--r--modern/src/EditCollectionView.js27
1 files changed, 15 insertions, 12 deletions
diff --git a/modern/src/EditCollectionView.js b/modern/src/EditCollectionView.js
index 572a1d1..7d5e4b2 100644
--- a/modern/src/EditCollectionView.js
+++ b/modern/src/EditCollectionView.js
@@ -10,7 +10,7 @@ import { useSelector } from 'react-redux';
import t from './common/localization';
import RemoveDialog from './RemoveDialog';
-const useStyles = makeStyles(theme => ({
+const useStyles = makeStyles((theme) => ({
fab: {
position: 'absolute',
bottom: theme.spacing(2),
@@ -18,7 +18,9 @@ const useStyles = makeStyles(theme => ({
},
}));
-const EditCollectionView = ({ content, editPath, endpoint, disableAdd }) => {
+const EditCollectionView = ({
+ content, editPath, endpoint, disableAdd,
+}) => {
const classes = useStyles();
const history = useHistory();
@@ -26,47 +28,48 @@ const EditCollectionView = ({ content, editPath, endpoint, disableAdd }) => {
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 adminEnabled = useSelector((state) => state.session.user && state.session.user.administrator);
const menuShow = (anchorId, itemId) => {
setSelectedAnchorEl(anchorId);
setSelectedId(itemId);
- }
+ };
const menuHide = () => {
setSelectedAnchorEl(null);
- }
+ };
const handleAdd = () => {
history.push(editPath);
menuHide();
- }
+ };
const handleEdit = () => {
history.push(`${editPath}/${selectedId}`);
menuHide();
- }
+ };
const handleRemove = () => {
setRemoveDialogShown(true);
menuHide();
- }
+ };
const handleRemoveResult = () => {
setRemoveDialogShown(false);
setUpdateTimestamp(Date.now());
- }
+ };
const Content = content;
return (
<>
<Content updateTimestamp={updateTimestamp} onMenuClick={menuShow} />
- {adminEnabled && !disableAdd &&
+ {adminEnabled && !disableAdd
+ && (
<Fab size="medium" color="primary" className={classes.fab} onClick={handleAdd}>
<AddIcon />
</Fab>
- }
+ )}
<Menu open={!!selectedAnchorEl} anchorEl={selectedAnchorEl} onClose={menuHide}>
<MenuItem onClick={handleEdit}>{t('sharedEdit')}</MenuItem>
<MenuItem onClick={handleRemove}>{t('sharedRemove')}</MenuItem>
@@ -74,6 +77,6 @@ const EditCollectionView = ({ content, editPath, endpoint, disableAdd }) => {
<RemoveDialog open={removeDialogShown} endpoint={endpoint} itemId={selectedId} onResult={handleRemoveResult} />
</>
);
-}
+};
export default EditCollectionView;