Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add modal to confirm tile deletion #1625 #1668

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 41 additions & 4 deletions src/components/Board/EditToolbar/EditToolbar.component.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { Fragment } from 'react';
import React, { Fragment, useState } from 'react';
import PropTypes from 'prop-types';
import { injectIntl, intlShape } from 'react-intl';
import classNames from 'classnames';
Expand All @@ -14,6 +14,10 @@ import AddBoxIcon from '@material-ui/icons/AddBox';
import { MdContentCopy } from 'react-icons/md';
import { MdContentPaste } from 'react-icons/md';

import Dialog from '@material-ui/core/Dialog';
import DialogActions from '@material-ui/core/DialogActions';
import DialogContent from '@material-ui/core/DialogContent';
import DialogTitle from '@material-ui/core/DialogTitle';
import SelectedCounter from '../../UI/SelectedCounter';
import IconButton from '../../UI/IconButton';
import messages from './EditToolbar.messages';
Expand Down Expand Up @@ -71,7 +75,10 @@ EditToolbar.propTypes = {
*/
onAddClick: PropTypes.func,
onBoardTypeChange: PropTypes.func,
copiedTiles: PropTypes.arrayOf(PropTypes.object)
copiedTiles: PropTypes.arrayOf(PropTypes.object),
open: PropTypes.bool.isRequired,
onClose: PropTypes.func.isRequired,
onDialogAccecpted: PropTypes.func.isRequired
};

function EditToolbar({
Expand All @@ -98,6 +105,13 @@ function EditToolbar({
}) {
const isItemsSelected = !!selectedItemsCount;
const isFixed = !!isFixedBoard;
const [openDeleteTiles, setOpenDeleteTiles] = useState(false);
const handleClickOpen = () => {
setOpenDeleteTiles(true);
};
const handleClose = () => {
setOpenDeleteTiles(false);
};

return (
<div
Expand Down Expand Up @@ -171,14 +185,37 @@ function EditToolbar({
count={selectedItemsCount}
className="EditToolbar__SelectedCounter"
/>

<IconButton
label={intl.formatMessage(messages.deleteTiles)}
disabled={!isItemsSelected}
onClick={onDeleteClick}
onClick={() => {
handleClickOpen();
}}
>
<DeleteIcon />
</IconButton>
<Dialog open={openDeleteTiles} onClose={handleClose}>
<DialogTitle id="alert-dialog-title">
{intl.formatMessage(messages.deleteTileTitle)}
</DialogTitle>
<DialogContent>
{intl.formatMessage(messages.deleteTileDescription)}
</DialogContent>
<DialogActions>
<Button onClick={handleClose} color="primary">
{intl.formatMessage(messages.deleteTileCancel)}
</Button>
<Button
onClick={onDeleteClick}
variant="contained"
color="primary"
autoFocus
>
{intl.formatMessage(messages.deleteTileOk)}
</Button>
</DialogActions>
</Dialog>

<PremiumFeature>
<IconButton
label={intl.formatMessage(messages.copyTiles)}
Expand Down
16 changes: 16 additions & 0 deletions src/components/Board/EditToolbar/EditToolbar.messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ export default defineMessages({
id: 'cboard.components.Board.EditToolbar.deleteTiles',
defaultMessage: 'Delete selected tiles'
},
deleteTileTitle: {
id: 'cboard.components.Board.EditToolbar.deleteTileTitle',
defaultMessage: 'Delete Tiles'
},
deleteTileDescription: {
id: 'cboard.components.Board.EditToolbar.deleteTileDescription',
defaultMessage: 'Are you sure you want to delete the tile(s)?'
},
deleteTileCancel: {
id: 'cboard.components.Board.EditToolbar.deleteTileCancel',
defaultMessage: 'Cancel'
},
deleteTileOk: {
id: 'cboard.components.EditToolbar.Board.deleteTileOk',
defaultMessage: 'Delete'
},
editTiles: {
id: 'cboard.components.Board.EditToolbar.editTiles',
defaultMessage: 'Edit selected tiles'
Expand Down