From 384b9d592e73ae423cb0d2d2ae11dbc4b60da17f Mon Sep 17 00:00:00 2001 From: JoramWilander Date: Tue, 6 Oct 2015 11:52:55 -0400 Subject: Allow team admin to delete comments. --- web/react/components/post_info.jsx | 14 ++-- web/react/components/rhs_comment.jsx | 129 ++++++++++++++++++++--------------- 2 files changed, 78 insertions(+), 65 deletions(-) (limited to 'web/react') diff --git a/web/react/components/post_info.jsx b/web/react/components/post_info.jsx index dba75ac5f..c1e8979a4 100644 --- a/web/react/components/post_info.jsx +++ b/web/react/components/post_info.jsx @@ -13,12 +13,6 @@ export default class PostInfo extends React.Component { super(props); this.state = {}; } - shouldShowComment(state, type, isOwner) { - if (state === Constants.POST_FAILED || state === Constants.POST_LOADING) { - return false; - } - return isOwner || (this.props.allowReply === 'true' && type !== 'Comment'); - } createDropdown() { var post = this.props.post; var isOwner = UserStore.getCurrentId() === post.user_id; @@ -33,10 +27,6 @@ export default class PostInfo extends React.Component { type = 'Comment'; } - if (!this.shouldShowComment(post.state, type, isOwner)) { - return ''; - } - var dropdownContents = []; var dataComments = 0; if (type === 'Post') { @@ -106,6 +96,10 @@ export default class PostInfo extends React.Component { ); } + if (dropdownContents.length === 0) { + return ''; + } + return (
+ + Edit + + + ); + } - var type = 'Post'; - if (post.root_id.length > 0) { - type = 'Comment'; + if (isOwner || isAdmin) { + dropdownContents.push( +
  • + + Delete + +
  • + ); + } + + if (dropdownContents.length === 0) { + return ''; + } + + return ( +
    +
    -
    - ); - } + var dropdown = this.createDropdown(); var fileAttachment; if (post.filenames && post.filenames.length > 0) { @@ -190,7 +209,7 @@ export default class RhsComment extends React.Component {
  • - {ownerOptions} + {dropdown}
  • -- cgit v1.2.3-1-g7c22