2017-07-19 16:59:41 +09:00
|
|
|
/*
|
|
|
|
|
|
|
|
An item in the comments list.
|
|
|
|
|
|
|
|
Note: Comments.options.mutations.edit.check is defined in
|
|
|
|
modules/comments/mutations.js and is used both on the server when
|
|
|
|
performing the mutation, and here to check if the form link
|
|
|
|
should be displayed.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import { Components, registerComponent } from 'meteor/vulcan:core';
|
|
|
|
|
|
|
|
import Comments from '../../modules/comments/collection.js';
|
|
|
|
|
2017-07-23 17:14:21 +09:00
|
|
|
const CommentsItem = ({comment, currentUser, pic}) =>
|
2017-07-19 16:59:41 +09:00
|
|
|
|
|
|
|
<div className={`comments-item ${comment.isDeleted ? 'comments-item-deleted' : ''}`}>
|
|
|
|
|
|
|
|
<h4 className="comments-item-author">{comment.user && comment.user.displayName}</h4>
|
|
|
|
|
|
|
|
<p className="comments-item-body">{comment.body}</p>
|
|
|
|
|
2017-07-23 17:14:21 +09:00
|
|
|
{Comments.options.mutations.edit.check(currentUser, comment, pic) ?
|
2017-07-19 16:59:41 +09:00
|
|
|
<Components.ModalTrigger component={<Components.Icon name="edit" />}>
|
2017-10-06 08:49:36 +09:00
|
|
|
<Components.CommentsEditForm currentUser={currentUser} documentId={comment._id} />
|
2017-07-19 16:59:41 +09:00
|
|
|
</Components.ModalTrigger>
|
|
|
|
: null
|
|
|
|
}
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
2017-10-06 08:49:36 +09:00
|
|
|
registerComponent('CommentsItem', CommentsItem);
|