Commit 2ac90315 authored by Paul Kaplan's avatar Paul Kaplan

Use can prefix instead of undefined callback

parent 1965a122
...@@ -85,8 +85,9 @@ class Comment extends React.Component { ...@@ -85,8 +85,9 @@ class Comment extends React.Component {
render () { render () {
const { const {
author, author,
deletable, canDelete,
canReply, canReply,
canRestore,
content, content,
datetimeCreated, datetimeCreated,
id, id,
...@@ -113,7 +114,7 @@ class Comment extends React.Component { ...@@ -113,7 +114,7 @@ class Comment extends React.Component {
<div className="action-list"> <div className="action-list">
{visible ? ( {visible ? (
<React.Fragment> <React.Fragment>
{deletable ? ( {canDelete ? (
<span <span
className="comment-delete" className="comment-delete"
onClick={this.handleDelete} onClick={this.handleDelete}
...@@ -133,7 +134,7 @@ class Comment extends React.Component { ...@@ -133,7 +134,7 @@ class Comment extends React.Component {
<span className="comment-visibility"> <span className="comment-visibility">
<FormattedMessage id={`comments.status.${visibility}`} /> <FormattedMessage id={`comments.status.${visibility}`} />
</span> </span>
{this.props.onRestore && ( {canRestore && (
<span <span
className="comment-restore" className="comment-restore"
onClick={this.handleRestore} onClick={this.handleRestore}
...@@ -212,10 +213,11 @@ Comment.propTypes = { ...@@ -212,10 +213,11 @@ Comment.propTypes = {
image: PropTypes.string, image: PropTypes.string,
username: PropTypes.string username: PropTypes.string
}), }),
canDelete: PropTypes.bool,
canReply: PropTypes.bool, canReply: PropTypes.bool,
canRestore: PropTypes.bool,
content: PropTypes.string, content: PropTypes.string,
datetimeCreated: PropTypes.string, datetimeCreated: PropTypes.string,
deletable: PropTypes.bool,
id: PropTypes.number, id: PropTypes.number,
onAddComment: PropTypes.func, onAddComment: PropTypes.func,
onDelete: PropTypes.func, onDelete: PropTypes.func,
......
...@@ -53,10 +53,11 @@ class TopLevelComment extends React.Component { ...@@ -53,10 +53,11 @@ class TopLevelComment extends React.Component {
render () { render () {
const { const {
author, author,
canDelete,
canReply, canReply,
canRestore,
content, content,
datetimeCreated, datetimeCreated,
deletable,
id, id,
onDelete, onDelete,
onReport, onReport,
...@@ -66,7 +67,7 @@ class TopLevelComment extends React.Component { ...@@ -66,7 +67,7 @@ class TopLevelComment extends React.Component {
visibility visibility
} = this.props; } = this.props;
const canRestoreReplies = visibility === 'visible'; const parentVisible = visibility === 'visible';
return ( return (
<FlexRow className="comment-container"> <FlexRow className="comment-container">
...@@ -77,8 +78,9 @@ class TopLevelComment extends React.Component { ...@@ -77,8 +78,9 @@ class TopLevelComment extends React.Component {
author, author,
content, content,
datetimeCreated, datetimeCreated,
deletable, canDelete,
canReply, canReply,
canRestore,
id, id,
onDelete, onDelete,
onReport, onReport,
...@@ -98,10 +100,11 @@ class TopLevelComment extends React.Component { ...@@ -98,10 +100,11 @@ class TopLevelComment extends React.Component {
{(this.state.expanded ? replies : replies.slice(0, 3)).map(reply => ( {(this.state.expanded ? replies : replies.slice(0, 3)).map(reply => (
<Comment <Comment
author={reply.author} author={reply.author}
canDelete={canDelete}
canReply={canReply} canReply={canReply}
canRestore={canRestore && parentVisible}
content={reply.content} content={reply.content}
datetimeCreated={reply.datetime_created} datetimeCreated={reply.datetime_created}
deletable={deletable}
id={reply.id} id={reply.id}
key={reply.id} key={reply.id}
projectId={projectId} projectId={projectId}
...@@ -109,7 +112,7 @@ class TopLevelComment extends React.Component { ...@@ -109,7 +112,7 @@ class TopLevelComment extends React.Component {
onAddComment={this.handleAddComment} onAddComment={this.handleAddComment}
onDelete={this.handleDeleteReply} onDelete={this.handleDeleteReply}
onReport={this.handleReportReply} onReport={this.handleReportReply}
onRestore={canRestoreReplies && this.handleRestoreReply} onRestore={this.handleRestoreReply}
/> />
))} ))}
</FlexRow> </FlexRow>
...@@ -138,7 +141,9 @@ TopLevelComment.propTypes = { ...@@ -138,7 +141,9 @@ TopLevelComment.propTypes = {
image: PropTypes.string, image: PropTypes.string,
username: PropTypes.string username: PropTypes.string
}), }),
canDelete: PropTypes.bool,
canReply: PropTypes.bool, canReply: PropTypes.bool,
canRestore: PropTypes.bool,
content: PropTypes.string, content: PropTypes.string,
datetimeCreated: PropTypes.string, datetimeCreated: PropTypes.string,
deletable: PropTypes.bool, deletable: PropTypes.bool,
......
...@@ -46,6 +46,7 @@ const PreviewPresentation = ({ ...@@ -46,6 +46,7 @@ const PreviewPresentation = ({
backpackOptions, backpackOptions,
canAddToStudio, canAddToStudio,
canReport, canReport,
canRestoreComments,
comments, comments,
editable, editable,
extensions, extensions,
...@@ -363,10 +364,11 @@ const PreviewPresentation = ({ ...@@ -363,10 +364,11 @@ const PreviewPresentation = ({
{comments.map(comment => ( {comments.map(comment => (
<TopLevelComment <TopLevelComment
author={comment.author} author={comment.author}
canDelete={userOwnsProject}
canReply={isLoggedIn && projectInfo.comments_allowed} canReply={isLoggedIn && projectInfo.comments_allowed}
canRestore={canRestoreComments}
content={comment.content} content={comment.content}
datetimeCreated={comment.datetime_created} datetimeCreated={comment.datetime_created}
deletable={userOwnsProject}
id={comment.id} id={comment.id}
key={comment.id} key={comment.id}
parentId={comment.parent_id} parentId={comment.parent_id}
...@@ -411,6 +413,7 @@ PreviewPresentation.propTypes = { ...@@ -411,6 +413,7 @@ PreviewPresentation.propTypes = {
}), }),
canAddToStudio: PropTypes.bool, canAddToStudio: PropTypes.bool,
canReport: PropTypes.bool, canReport: PropTypes.bool,
canRestoreComments: PropTypes.bool,
comments: PropTypes.arrayOf(PropTypes.object), comments: PropTypes.arrayOf(PropTypes.object),
editable: PropTypes.bool, editable: PropTypes.bool,
extensions: PropTypes.arrayOf(PropTypes.object), extensions: PropTypes.arrayOf(PropTypes.object),
......
...@@ -351,6 +351,7 @@ class Preview extends React.Component { ...@@ -351,6 +351,7 @@ class Preview extends React.Component {
backpackOptions={this.props.backpackOptions} backpackOptions={this.props.backpackOptions}
canAddToStudio={this.props.canAddToStudio} canAddToStudio={this.props.canAddToStudio}
canReport={this.props.canReport} canReport={this.props.canReport}
canRestoreComments={this.props.isAdmin}
comments={this.props.comments} comments={this.props.comments}
editable={this.props.isEditable} editable={this.props.isEditable}
extensions={this.state.extensions} extensions={this.state.extensions}
...@@ -383,7 +384,7 @@ class Preview extends React.Component { ...@@ -383,7 +384,7 @@ class Preview extends React.Component {
onReportClose={this.handleReportClose} onReportClose={this.handleReportClose}
onReportComment={this.handleReportComment} onReportComment={this.handleReportComment}
onReportSubmit={this.handleReportSubmit} onReportSubmit={this.handleReportSubmit}
onRestoreComment={this.props.isAdmin && this.handleRestoreComment} onRestoreComment={this.handleRestoreComment}
onSeeInside={this.handleSeeInside} onSeeInside={this.handleSeeInside}
onShare={this.handleShare} onShare={this.handleShare}
onToggleComments={this.handleToggleComments} onToggleComments={this.handleToggleComments}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment