2016-02-18 21:53:44 +09:00
|
|
|
const PostItem = React.createClass({
|
2016-02-17 17:22:32 +09:00
|
|
|
|
2016-02-18 21:53:44 +09:00
|
|
|
propTypes: {
|
|
|
|
post: React.PropTypes.object.isRequired, // the current comment
|
|
|
|
currentUser: React.PropTypes.object, // the current user
|
|
|
|
},
|
|
|
|
|
|
|
|
renderCategories() {
|
|
|
|
|
|
|
|
({PostCategories} = Telescope.components);
|
|
|
|
|
|
|
|
return this.props.post.categoriesArray ? <PostCategories categories={this.props.post.categoriesArray} /> : "";
|
|
|
|
},
|
|
|
|
|
|
|
|
renderCommenters() {
|
|
|
|
|
2016-02-19 10:12:08 +09:00
|
|
|
({PostCommenters} = Telescope.components);
|
2016-02-18 21:53:44 +09:00
|
|
|
|
2016-02-19 10:12:08 +09:00
|
|
|
return this.props.post.commentersArray ? <PostCommenters commenters={this.props.post.commentersArray}/> : "";
|
2016-02-18 21:53:44 +09:00
|
|
|
},
|
|
|
|
|
|
|
|
renderActions() {
|
|
|
|
return (
|
2016-02-19 10:12:08 +09:00
|
|
|
<div className="post-actions">
|
|
|
|
{Users.can.edit(this.props.currentUser, this.props.post) ? <a href={Posts.getEditUrl(this.props.post)} className="button button--secondary">Edit</a> : ""}
|
|
|
|
</div>
|
2016-02-18 21:53:44 +09:00
|
|
|
)
|
|
|
|
},
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
|
|
|
const post = this.props.post;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="post" style={{borderBottom: "2px solid #eee", paddingBottom: "10px", marginBottom: "10px"}}>
|
|
|
|
|
|
|
|
<h3 className="post-title"><a href={Posts.getLink(post)} target={Posts.getLinkTarget(post)}>{post.title}</a></h3>
|
|
|
|
<p>{Users.getDisplayName(post.user)}, {moment(post.postedAt).fromNow()}, {post.commentCount} comments</p>
|
|
|
|
|
|
|
|
{this.renderCategories()}
|
|
|
|
{this.renderCommenters()}
|
|
|
|
{this.renderActions()}
|
|
|
|
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
});
|
2016-02-15 22:33:44 +09:00
|
|
|
|
|
|
|
module.exports = PostItem;
|