From 3467e96f1d3006f1d9b0de170879205293f418a3 Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Mon, 12 Aug 2019 14:44:05 -0400 Subject: [PATCH] Allow admins to delete comments without confirmation --- src/views/preview/comment/comment.jsx | 7 ++++++- src/views/preview/comment/top-level-comment.jsx | 5 +++++ src/views/preview/presentation.jsx | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/views/preview/comment/comment.jsx b/src/views/preview/comment/comment.jsx index ef23195ea..527d69c88 100644 --- a/src/views/preview/comment/comment.jsx +++ b/src/views/preview/comment/comment.jsx @@ -54,7 +54,11 @@ class Comment extends React.Component { } handleDelete () { - this.setState({deleting: true}); + if (this.props.canDeleteWithoutConfirm) { + this.props.onDelete(this.props.id); + } else { + this.setState({deleting: true}); + } } handleConfirmDelete () { @@ -267,6 +271,7 @@ Comment.propTypes = { username: PropTypes.string }), canDelete: PropTypes.bool, + canDeleteWithoutConfirm: PropTypes.bool, canReply: PropTypes.bool, canReport: PropTypes.bool, canRestore: PropTypes.bool, diff --git a/src/views/preview/comment/top-level-comment.jsx b/src/views/preview/comment/top-level-comment.jsx index ecc15208e..d74ef2df3 100644 --- a/src/views/preview/comment/top-level-comment.jsx +++ b/src/views/preview/comment/top-level-comment.jsx @@ -74,6 +74,7 @@ class TopLevelComment extends React.Component { const { author, canDelete, + canDeleteWithoutConfirm, canReply, canReport, canRestore, @@ -103,6 +104,7 @@ class TopLevelComment extends React.Component { content, datetimeCreated, canDelete, + canDeleteWithoutConfirm, canReply, canReport, canRestore, @@ -126,6 +128,7 @@ class TopLevelComment extends React.Component {