import React, { PropTypes, Component } from 'react'; import { Button } from 'react-bootstrap'; import ReactForms from "meteor/utilities:react-form-containers"; const EditDocument = ReactForms.EditDocument; class PostItem extends Component { renderCategories() { ({PostCategories} = Telescope.components); return this.props.post.categoriesArray ? : ""; } renderCommenters() { ({PostCommenters} = Telescope.components); return this.props.post.commentersArray ? : ""; } renderActions() { ({ModalTrigger, DocumentContainer} = Telescope.components); const component = ( Edit}> Edit Post ); return ( {Users.can.edit(this.props.currentUser, this.props.post) ? component : ""} ) } render() { ({UserAvatar, UserName, Vote, PostStats, PostThumbnail} = Telescope.components); const post = this.props.post; let postClass = "post-item"; if (post.sticky) postClass += " post-sticky"; // console.log(post) // console.log(post.user) return ( {post.thumbnailUrl ? : null} {post.title} {this.renderCategories()} {moment(post.postedAt).fromNow()} {post.commentCount} comments {this.renderActions()} {this.renderCommenters()} ) } }; PostItem.propTypes = { post: React.PropTypes.object.isRequired, // the current comment currentUser: React.PropTypes.object, // the current user } PostItem.contextTypes = { currentUser: React.PropTypes.object }; module.exports = PostItem;