diff options
author | Anton Tananaev <anton@traccar.org> | 2022-05-22 14:34:19 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-05-22 14:34:19 -0700 |
commit | 729c219369e288a60432f0e7722dae36088c0bda (patch) | |
tree | 878e7a289abc3cabbc68f42683220a14389f1d2d /modern/src | |
parent | 2ec46ed25ccb6860dd4cf5e71be762186b411d32 (diff) | |
download | trackermap-web-729c219369e288a60432f0e7722dae36088c0bda.tar.gz trackermap-web-729c219369e288a60432f0e7722dae36088c0bda.tar.bz2 trackermap-web-729c219369e288a60432f0e7722dae36088c0bda.zip |
Convert remove to snackbar
Diffstat (limited to 'modern/src')
-rw-r--r-- | modern/src/common/components/RemoveDialog.js | 37 | ||||
-rw-r--r-- | modern/src/settings/components/EditCollectionView.js | 6 |
2 files changed, 26 insertions, 17 deletions
diff --git a/modern/src/common/components/RemoveDialog.js b/modern/src/common/components/RemoveDialog.js index cbdbb05d..a11af4c2 100644 --- a/modern/src/common/components/RemoveDialog.js +++ b/modern/src/common/components/RemoveDialog.js @@ -1,15 +1,23 @@ import React from 'react'; import Button from '@material-ui/core/Button'; -import Dialog from '@material-ui/core/Dialog'; -import DialogActions from '@material-ui/core/DialogActions'; -import DialogContent from '@material-ui/core/DialogContent'; -import DialogContentText from '@material-ui/core/DialogContentText'; +import { Snackbar, makeStyles } from '@material-ui/core'; import { useTranslation } from './LocalizationProvider'; import { useCatch } from '../../reactHelper'; +import { snackBarDurationLongMs } from '../util/duration'; + +const useStyles = makeStyles((theme) => ({ + button: { + height: 'auto', + marginTop: 0, + marginBottom: 0, + color: theme.palette.colors.negative, + }, +})); const RemoveDialog = ({ open, endpoint, itemId, onResult, }) => { + const classes = useStyles(); const t = useTranslation(); const handleRemove = useCatch(async () => { @@ -22,18 +30,17 @@ const RemoveDialog = ({ }); return ( - <Dialog + <Snackbar open={open} - onClose={() => { onResult(false); }} - > - <DialogContent> - <DialogContentText>{t('sharedRemoveConfirm')}</DialogContentText> - </DialogContent> - <DialogActions> - <Button color="primary" onClick={handleRemove}>{t('sharedRemove')}</Button> - <Button autoFocus onClick={() => onResult(false)}>{t('sharedCancel')}</Button> - </DialogActions> - </Dialog> + autoHideDuration={snackBarDurationLongMs} + onClose={() => onResult(false)} + message={t('sharedRemoveConfirm')} + action={( + <Button size="small" className={classes.button} onClick={handleRemove}> + {t('sharedRemove')} + </Button> + )} + /> ); }; diff --git a/modern/src/settings/components/EditCollectionView.js b/modern/src/settings/components/EditCollectionView.js index ed92c838..b0bf3ea0 100644 --- a/modern/src/settings/components/EditCollectionView.js +++ b/modern/src/settings/components/EditCollectionView.js @@ -60,9 +60,11 @@ const EditCollectionView = ({ menuHide(); }; - const handleRemoveResult = () => { + const handleRemoveResult = (removed) => { setRemoveDialogShown(false); - setUpdateTimestamp(Date.now()); + if (removed) { + setUpdateTimestamp(Date.now()); + } }; const Content = content; |