From 5874471b0c18bed8588956d6065386e50dab1cd1 Mon Sep 17 00:00:00 2001 From: igoradamenko Date: Mon, 12 Mar 2018 21:59:39 +0300 Subject: [PATCH] add confirm windows for pin, unpin, block, unblock and delete comment actions --- web/app/components/comment/comment.jsx | 48 ++++++++++++++++---------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/web/app/components/comment/comment.jsx b/web/app/components/comment/comment.jsx index 2b7e0b69..96696cf2 100644 --- a/web/app/components/comment/comment.jsx +++ b/web/app/components/comment/comment.jsx @@ -63,49 +63,59 @@ export default class Comment extends Component { onPinClick() { const { id } = this.props.data; - this.setState({ pinned: true }); + if (confirm('Do you want to pin this comment?')) { + this.setState({ pinned: true }); - api.pin({ id, url }).then(() => { - api.getComment({ id }).then(comment => store.replaceComment(comment)); - }); + api.pin({ id, url }).then(() => { + api.getComment({ id }).then(comment => store.replaceComment(comment)); + }); + } } onUnpinClick() { const { id } = this.props.data; - this.setState({ pinned: false }); + if (confirm('Do you want to unpin this comment?')) { + this.setState({ pinned: false }); - api.unpin({ id, url }).then(() => { - api.getComment({ id }).then(comment => store.replaceComment(comment)); - }); + api.unpin({ id, url }).then(() => { + api.getComment({ id }).then(comment => store.replaceComment(comment)); + }); + } } onBlockClick() { const { id, user: { id: userId } } = this.props.data; - this.setState({ userBlocked: true }); + if (confirm('Do you want to block this user?')) { + this.setState({ userBlocked: true }); - api.blockUser({ id: userId }).then(() => { - api.getComment({ id }).then(comment => store.replaceComment(comment)); - }); + api.blockUser({ id: userId }).then(() => { + api.getComment({ id }).then(comment => store.replaceComment(comment)); + }); + } } onUnblockClick() { const { id, user: { id: userId } } = this.props.data; - this.setState({ userBlocked: false }); + if (confirm('Do you want to unblock this user?')) { + this.setState({ userBlocked: false }); - api.unblockUser({ id: userId }).then(() => { - api.getComment({ id }).then(comment => store.replaceComment(comment)); - }); + api.unblockUser({ id: userId }).then(() => { + api.getComment({ id }).then(comment => store.replaceComment(comment)); + }); + } } onDeleteClick() { const { id } = this.props.data; - api.remove({ id }).then(() => { - api.getComment({ id }).then(comment => store.replaceComment(comment)); - }); + if (confirm('Do you want to delete this comment?')) { + api.remove({ id }).then(() => { + api.getComment({ id }).then(comment => store.replaceComment(comment)); + }); + } } increaseScore() {