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 () {
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,

View file

@ -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 {
<Comment
author={reply.author}
canDelete={canDelete}
canDeleteWithoutConfirm={canDeleteWithoutConfirm}
canReply={canReply}
canReport={canReport}
canRestore={canRestore && parentVisible}
@ -168,6 +171,7 @@ TopLevelComment.propTypes = {
username: PropTypes.string
}),
canDelete: PropTypes.bool,
canDeleteWithoutConfirm: PropTypes.bool,
canReply: PropTypes.bool,
canReport: PropTypes.bool,
canRestore: PropTypes.bool,
@ -190,6 +194,7 @@ TopLevelComment.propTypes = {
};
TopLevelComment.defaultProps = {
canDeleteWithoutConfirm: false,
defaultExpanded: false,
moreRepliesToLoad: false
};

View file

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