diff --git a/web/react/components/post.jsx b/web/react/components/post.jsx index b798dc7ca5..7bc6a8c01b 100644 --- a/web/react/components/post.jsx +++ b/web/react/components/post.jsx @@ -3,7 +3,6 @@ var PostHeader = require('./post_header.jsx'); var PostBody = require('./post_body.jsx'); -var PostInfo = require('./post_info.jsx'); var AppDispatcher = require('../dispatcher/app_dispatcher.jsx'); var Constants = require('../utils/constants.jsx'); var UserStore = require('../stores/user_store.jsx'); @@ -13,6 +12,8 @@ var client = require('../utils/client.jsx'); var AsyncClient = require('../utils/async_client.jsx'); var ActionTypes = Constants.ActionTypes; +var PostInfo = require('./post_info.jsx'); + module.exports = React.createClass({ displayName: "Post", handleCommentClick: function(e) { diff --git a/web/react/components/post_info.jsx b/web/react/components/post_info.jsx index f6ab0ed8a2..c5b015cb91 100644 --- a/web/react/components/post_info.jsx +++ b/web/react/components/post_info.jsx @@ -6,11 +6,18 @@ var utils = require('../utils/utils.jsx'); var Constants = require('../utils/constants.jsx'); -module.exports = React.createClass({ - getInitialState: function() { - return { }; - }, - render: function() { +export default class PostInfo extends React.Component { + constructor(props) { + 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; var isAdmin = UserStore.getCurrentUser().roles.indexOf('admin') > -1; @@ -20,6 +27,89 @@ module.exports = React.createClass({ type = 'Comment'; } + if (!this.shouldShowComment(post.state, type, isOwner)) { + return ''; + } + + var dropdownContents = []; + var dataComments = 0; + if (type === 'Post') { + dataComments = this.props.commentCount; + } + + if (isOwner) { + dropdownContents.push( +