diff options
Diffstat (limited to 'modern/src/settings/components/CollectionActions.js')
-rw-r--r-- | modern/src/settings/components/CollectionActions.js | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/modern/src/settings/components/CollectionActions.js b/modern/src/settings/components/CollectionActions.js index c5e14949..e69553bd 100644 --- a/modern/src/settings/components/CollectionActions.js +++ b/modern/src/settings/components/CollectionActions.js @@ -1,16 +1,31 @@ import React, { useState } from 'react'; -import { IconButton, Menu, MenuItem } from '@mui/material'; +import { + IconButton, Menu, MenuItem, useMediaQuery, useTheme, +} from '@mui/material'; import MoreVertIcon from '@mui/icons-material/MoreVert'; +import EditIcon from '@mui/icons-material/Edit'; +import DeleteIcon from '@mui/icons-material/Delete'; import { useNavigate } from 'react-router-dom'; +import { makeStyles } from '@mui/styles'; import RemoveDialog from '../../common/components/RemoveDialog'; import { useTranslation } from '../../common/components/LocalizationProvider'; +const useStyles = makeStyles(() => ({ + row: { + display: 'flex', + }, +})); + const CollectionActions = ({ itemId, editPath, endpoint, setTimestamp, }) => { + const theme = useTheme(); + const classes = useStyles(); const navigate = useNavigate(); const t = useTranslation(); + const phone = useMediaQuery(theme.breakpoints.down('sm')); + const [menuAnchorEl, setMenuAnchorEl] = useState(null); const [removing, setRemoving] = useState(false); @@ -33,13 +48,26 @@ const CollectionActions = ({ return ( <> - <IconButton size="small" onClick={(event) => setMenuAnchorEl(event.currentTarget)}> - <MoreVertIcon /> - </IconButton> - <Menu open={!!menuAnchorEl} anchorEl={menuAnchorEl} onClose={() => setMenuAnchorEl(null)}> - <MenuItem onClick={handleEdit}>{t('sharedEdit')}</MenuItem> - <MenuItem onClick={handleRemove}>{t('sharedRemove')}</MenuItem> - </Menu> + {phone ? ( + <> + <IconButton size="small" onClick={(event) => setMenuAnchorEl(event.currentTarget)}> + <MoreVertIcon fontSize="small" /> + </IconButton> + <Menu open={!!menuAnchorEl} anchorEl={menuAnchorEl} onClose={() => setMenuAnchorEl(null)}> + <MenuItem onClick={handleEdit}>{t('sharedEdit')}</MenuItem> + <MenuItem onClick={handleRemove}>{t('sharedRemove')}</MenuItem> + </Menu> + </> + ) : ( + <div className={classes.row}> + <IconButton size="small" onClick={handleEdit}> + <EditIcon fontSize="small" /> + </IconButton> + <IconButton size="small" onClick={handleRemove}> + <DeleteIcon fontSize="small" /> + </IconButton> + </div> + )} <RemoveDialog style={{ transform: 'none' }} open={removing} endpoint={endpoint} itemId={itemId} onResult={handleRemoveResult} /> </> ); |