import React, { PropTypes, Component } from 'react'; import { Button } from 'react-bootstrap'; import Core from "meteor/nova:core"; const ModalTrigger = Core.ModalTrigger; import SmartContainers from "meteor/utilities:react-list-container"; const DocumentContainer = SmartContainers.DocumentContainer; class PostItem extends Component { renderCategories() { ({PostCategories} = Telescope.components); return this.props.post.categoriesArray ? : ""; } renderCommenters() { ({PostCommenters} = Telescope.components); return this.props.post.commentersArray ? : ""; } renderActions() { ({PostEditForm} = Telescope.components); const component = ( Edit}> ); 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()} {post.user? : null} {moment(post.postedAt).fromNow()} {post.commentCount} comments {this.renderActions()} {this.renderCommenters()} ) } }; PostItem.propTypes = { post: React.PropTypes.object.isRequired, currentUser: React.PropTypes.object } PostItem.contextTypes = { currentUser: React.PropTypes.object }; module.exports = PostItem; export default PostItem;