Merge branch 'master' into remember-sort

This commit is contained in:
Kim Gardner
2017-09-11 11:53:07 +01:00
committed by GitHub
38 changed files with 813 additions and 205 deletions
@@ -18,7 +18,7 @@ import {getEditableUntilDate} from './util';
import {findCommentWithId} from '../graphql/utils';
import CommentContent from './CommentContent';
import Slot from 'coral-framework/components/Slot';
import IgnoredCommentTombstone from './IgnoredCommentTombstone';
import CommentTombstone from './CommentTombstone';
import InactiveCommentLabel from './InactiveCommentLabel';
import {EditableCommentContent} from './EditableCommentContent';
import {getActionSummary, iPerformedThisAction, forEachError, isCommentActive, getShallowChanges} from 'coral-framework/utils';
@@ -209,6 +209,10 @@ export default class Comment extends React.Component {
}
}
commentIsRejected(comment) {
return comment.status === 'REJECTED';
}
commentIsIgnored(comment) {
const me = this.props.root.me;
return (
@@ -337,9 +341,13 @@ export default class Comment extends React.Component {
emit,
commentClassNames = []
} = this.props;
if (this.commentIsRejected(comment)) {
return <CommentTombstone action='reject' />;
}
if (this.commentIsIgnored(comment)) {
return <IgnoredCommentTombstone />;
return <CommentTombstone action='ignore' />;
}
const view = this.getVisibileReplies();
@@ -2,8 +2,21 @@ import React from 'react';
import t from 'coral-framework/services/i18n';
// Render in place of a Comment when the author of the comment is ignored
class IgnoredCommentTombstone extends React.Component {
// Render in place of a Comment when the author of the comment is <action>
class CommentTombstone extends React.Component {
getCopy() {
const {action} = this.props;
switch (action) {
case 'ignore':
return t('framework.comment_is_ignored');
case 'reject':
return t('framework.comment_is_rejected');
default :
return t('framework.comment_is_hidden');
}
}
render() {
return (
<div>
@@ -14,11 +27,11 @@ class IgnoredCommentTombstone extends React.Component {
padding: '1em',
color: '#3E4F71',
}}>
{t('framework.comment_is_ignored')}
{this.getCopy()}
</p>
</div>
);
}
}
export default IgnoredCommentTombstone;
export default CommentTombstone;
@@ -127,6 +127,27 @@ export const withSetCommentStatus = withMutation(
commentId,
status,
},
optimisticResponse: {
setCommentStatus: {
__typename: 'SetCommentStatusResponse',
errors: null,
}
},
update: (proxy) => {
const fragment = gql`
fragment Talk_SetCommentStatus on Comment {
status
}`;
const fragmentId = `Comment_${commentId}`;
const data = proxy.readFragment({fragment, id: fragmentId});
data.status = status;
proxy.writeFragment({fragment, id: fragmentId, data});
}
});
}
})