Commit b7b7b079 authored by Paul Kaplan's avatar Paul Kaplan

Combine comment reported and deleted flags into visibility string

To prepare for server including visibility
parent 6d8235c7
...@@ -227,5 +227,18 @@ ...@@ -227,5 +227,18 @@
"comments.post": "Post", "comments.post": "Post",
"comments.cancel": "Cancel", "comments.cancel": "Cancel",
"comments.lengthWarning": "{remainingCharacters, plural, one {1 character left} other {{remainingCharacters} characters left}}", "comments.lengthWarning": "{remainingCharacters, plural, one {1 character left} other {{remainingCharacters} characters left}}",
"comments.seeMoreReplies": "{repliesCount, plural, one {See 1 more reply} other {See all {repliesCount} replies}}" "comments.seeMoreReplies": "{repliesCount, plural, one {See 1 more reply} other {See all {repliesCount} replies}}",
"comments.status.delbyusr": "Deleted by project owner",
"comments.status.censbyfilter": "Censored by filter",
"comments.status.delbyparentcomment": "Parent comment deleted",
"comments.status.censbyadmin": "Censored by admin",
"comments.status.delbyadmin": "Deleted by admin",
"comments.status.parentcommentcensored": "Parent comment censored",
"comments.status.delbyclass": "Deleted by class",
"comments.status.hiddenduetourl": "Hidden due to URL",
"comments.status.markedbyfilter": "Marked by filter",
"comments.status.suspended": "Suspended",
"comments.status.acctdel": "Account deleted",
"comments.status.deleted": "Deleted",
"comments.status.reported": "Reported"
} }
...@@ -233,7 +233,7 @@ module.exports.setCommentDeleted = (commentId, topLevelCommentId) => ({ ...@@ -233,7 +233,7 @@ module.exports.setCommentDeleted = (commentId, topLevelCommentId) => ({
commentId: commentId, commentId: commentId,
topLevelCommentId: topLevelCommentId, topLevelCommentId: topLevelCommentId,
comment: { comment: {
deleted: true visibility: 'deleted'
} }
}); });
...@@ -242,7 +242,7 @@ module.exports.setCommentReported = (commentId, topLevelCommentId) => ({ ...@@ -242,7 +242,7 @@ module.exports.setCommentReported = (commentId, topLevelCommentId) => ({
commentId: commentId, commentId: commentId,
topLevelCommentId: topLevelCommentId, topLevelCommentId: topLevelCommentId,
comment: { comment: {
reported: true visibility: 'reported'
} }
}); });
......
...@@ -13,6 +13,10 @@ const ReportCommentModal = require('../../../components/modal/comments/report-co ...@@ -13,6 +13,10 @@ const ReportCommentModal = require('../../../components/modal/comments/report-co
require('./comment.scss'); require('./comment.scss');
const CommentVisibility = {
VISIBLE: 'visible' // Has to match the server response for visibility
};
class Comment extends React.Component { class Comment extends React.Component {
constructor (props) { constructor (props) {
super(props); super(props);
...@@ -81,15 +85,16 @@ class Comment extends React.Component { ...@@ -81,15 +85,16 @@ class Comment extends React.Component {
const { const {
author, author,
deletable, deletable,
deleted,
canReply, canReply,
content, content,
datetimeCreated, datetimeCreated,
id, id,
projectId, projectId,
reported visibility
} = this.props; } = this.props;
const visible = visibility === CommentVisibility.VISIBLE;
return ( return (
<div <div
className="flex-row comment" className="flex-row comment"
...@@ -105,27 +110,35 @@ class Comment extends React.Component { ...@@ -105,27 +110,35 @@ class Comment extends React.Component {
href={`/users/${author.username}`} href={`/users/${author.username}`}
>{author.username}</a> >{author.username}</a>
<div className="action-list"> <div className="action-list">
{deletable ? ( {visible ? (
<span <React.Fragment>
className="comment-delete" {deletable ? (
onClick={this.handleDelete} <span
> className="comment-delete"
<FormattedMessage id="comments.delete" /> onClick={this.handleDelete}
>
<FormattedMessage id="comments.delete" />
</span>
) : null}
<span
className="comment-report"
onClick={this.handleReport}
>
<FormattedMessage id="comments.report" />
</span>
</React.Fragment>
) : (
<span className="comment-visibility">
<FormattedMessage id={`comments.status.${visibility}`} />
{/* TODO restore action will go here */}
</span> </span>
) : null} )}
<span
className="comment-report"
onClick={this.handleReport}
>
<FormattedMessage id="comments.report" />
</span>
</div> </div>
</FlexRow> </FlexRow>
<div <div
className={classNames({ className={classNames({
'comment-bubble': true, 'comment-bubble': true,
'comment-bubble-deleted': deleted, 'comment-bubble-reported': !visible
'comment-bubble-reported': reported
})} })}
> >
{/* TODO: at the moment, comment content does not properly display {/* TODO: at the moment, comment content does not properly display
...@@ -193,13 +206,12 @@ Comment.propTypes = { ...@@ -193,13 +206,12 @@ Comment.propTypes = {
content: PropTypes.string, content: PropTypes.string,
datetimeCreated: PropTypes.string, datetimeCreated: PropTypes.string,
deletable: PropTypes.bool, deletable: PropTypes.bool,
deleted: PropTypes.bool,
id: PropTypes.number, id: PropTypes.number,
onAddComment: PropTypes.func, onAddComment: PropTypes.func,
onDelete: PropTypes.func, onDelete: PropTypes.func,
onReport: PropTypes.func, onReport: PropTypes.func,
projectId: PropTypes.string, projectId: PropTypes.string,
reported: PropTypes.bool visibility: PropTypes.string
}; };
module.exports = Comment; module.exports = Comment;
...@@ -82,6 +82,7 @@ ...@@ -82,6 +82,7 @@
opacity: .5; opacity: .5;
font-size: .75rem; font-size: .75rem;
font-weight: 500; font-weight: 500;
cursor: pointer;
&:before { &:before {
display: inline-block; display: inline-block;
...@@ -93,6 +94,11 @@ ...@@ -93,6 +94,11 @@
} }
} }
.comment-visibility {
opacity: .5;
font-size: .75rem;
}
.comment-delete { .comment-delete {
margin-right: 1rem; margin-right: 1rem;
...@@ -150,19 +156,6 @@ ...@@ -150,19 +156,6 @@
content: ""; content: "";
} }
&.comment-bubble-deleted {
$deleted-outline: $active-gray;
$deleted-background: rgb(215, 222, 234);
border-color: $deleted-outline;
background-color: $deleted-background;
&:before {
border-color: $deleted-outline transparent $deleted-outline $deleted-outline;
background: $deleted-background;
}
}
&.comment-bubble-reported { &.comment-bubble-reported {
$reported-outline: #ff6680; $reported-outline: #ff6680;
$reported-background: rgb(236, 206, 223); $reported-background: rgb(236, 206, 223);
......
...@@ -52,13 +52,12 @@ class TopLevelComment extends React.Component { ...@@ -52,13 +52,12 @@ class TopLevelComment extends React.Component {
content, content,
datetimeCreated, datetimeCreated,
deletable, deletable,
deleted,
id, id,
onDelete, onDelete,
onReport, onReport,
replies, replies,
reported, projectId,
projectId visibility
} = this.props; } = this.props;
return ( return (
...@@ -71,12 +70,11 @@ class TopLevelComment extends React.Component { ...@@ -71,12 +70,11 @@ class TopLevelComment extends React.Component {
content, content,
datetimeCreated, datetimeCreated,
deletable, deletable,
deleted,
canReply, canReply,
id, id,
onDelete, onDelete,
onReport, onReport,
reported visibility
}} }}
/> />
{replies.length > 0 && {replies.length > 0 &&
...@@ -95,11 +93,10 @@ class TopLevelComment extends React.Component { ...@@ -95,11 +93,10 @@ class TopLevelComment extends React.Component {
content={reply.content} content={reply.content}
datetimeCreated={reply.datetime_created} datetimeCreated={reply.datetime_created}
deletable={deletable} deletable={deletable}
deleted={reply.deleted}
id={reply.id} id={reply.id}
key={reply.id} key={reply.id}
projectId={projectId} projectId={projectId}
reported={reply.reported} visibility={reply.visibility}
onAddComment={this.handleAddComment} onAddComment={this.handleAddComment}
onDelete={this.handleDeleteReply} onDelete={this.handleDeleteReply}
onReport={this.handleReportReply} onReport={this.handleReportReply}
...@@ -135,7 +132,6 @@ TopLevelComment.propTypes = { ...@@ -135,7 +132,6 @@ TopLevelComment.propTypes = {
content: PropTypes.string, content: PropTypes.string,
datetimeCreated: PropTypes.string, datetimeCreated: PropTypes.string,
deletable: PropTypes.bool, deletable: PropTypes.bool,
deleted: PropTypes.bool,
id: PropTypes.number, id: PropTypes.number,
onAddComment: PropTypes.func, onAddComment: PropTypes.func,
onDelete: PropTypes.func, onDelete: PropTypes.func,
...@@ -143,7 +139,7 @@ TopLevelComment.propTypes = { ...@@ -143,7 +139,7 @@ TopLevelComment.propTypes = {
parentId: PropTypes.number, parentId: PropTypes.number,
projectId: PropTypes.string, projectId: PropTypes.string,
replies: PropTypes.arrayOf(PropTypes.object), replies: PropTypes.arrayOf(PropTypes.object),
reported: PropTypes.bool visibility: PropTypes.string
}; };
module.exports = TopLevelComment; module.exports = TopLevelComment;
...@@ -366,13 +366,12 @@ const PreviewPresentation = ({ ...@@ -366,13 +366,12 @@ const PreviewPresentation = ({
content={comment.content} content={comment.content}
datetimeCreated={comment.datetime_created} datetimeCreated={comment.datetime_created}
deletable={userOwnsProject} deletable={userOwnsProject}
deleted={comment.deleted}
id={comment.id} id={comment.id}
key={comment.id} key={comment.id}
parentId={comment.parent_id} parentId={comment.parent_id}
projectId={projectId} projectId={projectId}
replies={replies && replies[comment.id] ? replies[comment.id] : []} replies={replies && replies[comment.id] ? replies[comment.id] : []}
reported={comment.reported} visibility={comment.visibility}
onAddComment={onAddComment} onAddComment={onAddComment}
onDelete={onDeleteComment} onDelete={onDeleteComment}
onReport={onReportComment} onReport={onReportComment}
......
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