mirror of
https://github.com/vale981/Vulcan
synced 2025-03-10 04:26:41 -04:00
92 lines
No EOL
3 KiB
JavaScript
92 lines
No EOL
3 KiB
JavaScript
import React, { PropTypes, Component } from 'react';
|
|
import { FormattedMessage, FormattedRelative } from 'react-intl';
|
|
import { Button } from 'react-bootstrap';
|
|
import moment from 'moment';
|
|
import { ModalTrigger } from "meteor/nova:core";
|
|
import { Link } from 'react-router';
|
|
|
|
class PostsItem extends Component {
|
|
|
|
renderCategories() {
|
|
return this.props.post.categoriesArray ? <Telescope.components.PostsCategories post={this.props.post} /> : "";
|
|
}
|
|
|
|
renderCommenters() {
|
|
return this.props.post.commentersArray ? <Telescope.components.PostsCommenters post={this.props.post}/> : "";
|
|
}
|
|
|
|
renderActions() {
|
|
|
|
const component = (
|
|
<ModalTrigger title="Edit Post" component={<a className="posts-action-edit"><FormattedMessage id="posts.edit"/></a>}>
|
|
<Telescope.components.PostsEditForm post={this.props.post}/>
|
|
</ModalTrigger>
|
|
);
|
|
|
|
return (
|
|
<div className="post-actions">
|
|
{Users.can.edit(this.context.currentUser, this.props.post) ? component : ""}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
render() {
|
|
|
|
const post = this.props.post;
|
|
|
|
let postClass = "posts-item";
|
|
if (post.sticky) postClass += " posts-sticky";
|
|
|
|
// console.log(post)
|
|
// console.log(post.user)
|
|
|
|
return (
|
|
<div className={postClass}>
|
|
|
|
<div className="posts-item-vote">
|
|
<Telescope.components.Vote post={post} currentUser={this.context.currentUser}/>
|
|
</div>
|
|
|
|
{post.thumbnailUrl ? <Telescope.components.PostsThumbnail post={post}/> : null}
|
|
|
|
<div className="posts-item-content">
|
|
|
|
<h3 className="posts-item-title">
|
|
<Link to={`posts/${post._id}/${post.slug}/`} /*to={{name: "posts.single", params: {_id: post._id, slug: post.slug}}}*/ className="posts-item-title-link" target={Posts.getLinkTarget(post)}>
|
|
{post.title}
|
|
</Link>
|
|
{this.renderCategories()}
|
|
</h3>
|
|
|
|
<div className="posts-item-meta">
|
|
{post.user? <div className="posts-item-user"><Telescope.components.UsersAvatar user={post.user} size="small"/><Telescope.components.UsersName user={post.user}/></div> : null}
|
|
<div className="posts-item-date"><FormattedRelative value={post.postedAt}/></div>
|
|
<div className="posts-item-comments">
|
|
<Link to={`posts/${post._id}/${post.slug}/`} /*to={{name: "posts.single", params: {_id: post._id, slug: post.slug}}}*/>
|
|
<FormattedMessage id="comments.count" values={{count: post.commentCount}}/>
|
|
</Link>
|
|
</div>
|
|
{(this.context.currentUser && this.context.currentUser.isAdmin) ?<Telescope.components.PostsStats post={post} />:null}
|
|
{this.renderActions()}
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{this.renderCommenters()}
|
|
|
|
|
|
</div>
|
|
)
|
|
}
|
|
};
|
|
|
|
PostsItem.propTypes = {
|
|
post: React.PropTypes.object.isRequired
|
|
}
|
|
|
|
PostsItem.contextTypes = {
|
|
currentUser: React.PropTypes.object
|
|
};
|
|
|
|
module.exports = PostsItem;
|
|
export default PostsItem; |