Merge pull request #3244 from LLK/hotfix/no-confirm-admin

Allow admins to delete comments without confirmation
This commit is contained in:
Paul Kaplan 2019-08-13 12:02:45 -04:00 committed by GitHub
commit d4f5ac7d09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View file

@ -54,7 +54,11 @@ class Comment extends React.Component {
} }
handleDelete () { handleDelete () {
this.setState({deleting: true}); if (this.props.canDeleteWithoutConfirm) {
this.props.onDelete(this.props.id);
} else {
this.setState({deleting: true});
}
} }
handleConfirmDelete () { handleConfirmDelete () {
@ -267,6 +271,7 @@ Comment.propTypes = {
username: PropTypes.string username: PropTypes.string
}), }),
canDelete: PropTypes.bool, canDelete: PropTypes.bool,
canDeleteWithoutConfirm: PropTypes.bool,
canReply: PropTypes.bool, canReply: PropTypes.bool,
canReport: PropTypes.bool, canReport: PropTypes.bool,
canRestore: PropTypes.bool, canRestore: PropTypes.bool,

View file

@ -74,6 +74,7 @@ class TopLevelComment extends React.Component {
const { const {
author, author,
canDelete, canDelete,
canDeleteWithoutConfirm,
canReply, canReply,
canReport, canReport,
canRestore, canRestore,
@ -103,6 +104,7 @@ class TopLevelComment extends React.Component {
content, content,
datetimeCreated, datetimeCreated,
canDelete, canDelete,
canDeleteWithoutConfirm,
canReply, canReply,
canReport, canReport,
canRestore, canRestore,
@ -126,6 +128,7 @@ class TopLevelComment extends React.Component {
<Comment <Comment
author={reply.author} author={reply.author}
canDelete={canDelete} canDelete={canDelete}
canDeleteWithoutConfirm={canDeleteWithoutConfirm}
canReply={canReply} canReply={canReply}
canReport={canReport} canReport={canReport}
canRestore={canRestore && parentVisible} canRestore={canRestore && parentVisible}
@ -168,6 +171,7 @@ TopLevelComment.propTypes = {
username: PropTypes.string username: PropTypes.string
}), }),
canDelete: PropTypes.bool, canDelete: PropTypes.bool,
canDeleteWithoutConfirm: PropTypes.bool,
canReply: PropTypes.bool, canReply: PropTypes.bool,
canReport: PropTypes.bool, canReport: PropTypes.bool,
canRestore: PropTypes.bool, canRestore: PropTypes.bool,
@ -190,6 +194,7 @@ TopLevelComment.propTypes = {
}; };
TopLevelComment.defaultProps = { TopLevelComment.defaultProps = {
canDeleteWithoutConfirm: false,
defaultExpanded: false, defaultExpanded: false,
moreRepliesToLoad: false moreRepliesToLoad: false
}; };

View file

@ -599,6 +599,7 @@ const PreviewPresentation = ({
<TopLevelComment <TopLevelComment
author={comment.author} author={comment.author}
canDelete={canDeleteComments} canDelete={canDeleteComments}
canDeleteWithoutConfirm={isAdmin}
canReply={isLoggedIn && projectInfo.comments_allowed && isShared} canReply={isLoggedIn && projectInfo.comments_allowed && isShared}
canReport={isLoggedIn} canReport={isLoggedIn}
canRestore={canRestoreComments} canRestore={canRestoreComments}