Merge branch 'master' into refactor-configure

This commit is contained in:
Chi Vinh Le
2017-11-15 19:49:09 +01:00
19 changed files with 96 additions and 12 deletions
@@ -48,7 +48,7 @@ class SuspendUserDialogContainer extends Component {
SuspendUserDialogContainer.propTypes = {
open: PropTypes.bool,
hideSuspendUserDialog: PropTypes.func,
username: PropTypes.object,
username: PropTypes.string,
};
const withOrganizationName = withQuery(gql`
@@ -111,6 +111,17 @@ class ModerationContainer extends Component {
return this.handleCommentChange(prev, comment, notifyText);
},
},
{
document: COMMENT_RESET_SUBSCRIPTION,
variables,
updateQuery: (prev, {subscriptionData: {data: {commentReset: comment}}}) => {
const user = comment.status_history[comment.status_history.length - 1].assigned_by;
const notifyText = this.props.auth.user.id === user.id
? ''
: t('modqueue.notify_reset', user.username, prepareNotificationText(comment.body));
return this.handleCommentChange(prev, comment, notifyText);
},
},
{
document: COMMENT_EDITED_SUBSCRIPTION,
variables,
@@ -299,6 +310,23 @@ const COMMENT_REJECTED_SUBSCRIPTION = gql`
${Comment.fragments.comment}
`;
const COMMENT_RESET_SUBSCRIPTION = gql`
subscription CommentReset($asset_id: ID){
commentReset(asset_id: $asset_id){
...${getDefinitionName(Comment.fragments.comment)}
status_history {
type
created_at
assigned_by {
id
username
}
}
}
}
${Comment.fragments.comment}
`;
const LOAD_MORE_QUERY = gql`
query CoralAdmin_Moderation_LoadMore($limit: Int = 10, $cursor: Cursor, $sortOrder: SORT_ORDER, $asset_id: ID, $tags:[String!], $statuses:[COMMENT_STATUS!], $action_type: ACTION_TYPE) {
comments(query: {limit: $limit, cursor: $cursor, asset_id: $asset_id, statuses: $statuses, sortOrder: $sortOrder, action_type: $action_type, tags: $tags}) {
@@ -345,7 +345,10 @@ export default class Comment extends React.Component {
if (!highlighted && this.commentIsRejected(comment)) {
return <CommentTombstone action='reject' onUndo={() => {
this.props.setCommentStatus({commentId: comment.id, status: 'NONE'});
this.props.setCommentStatus({
commentId: comment.id,
status: comment.status_history[comment.status_history.length - 2].type,
});
}}/>;
}
@@ -25,7 +25,7 @@ class CommentTombstone extends React.Component {
<p className={styles.commentTombstone}>
{this.getCopy()}
{this.props.action === 'reject' &&
<span className={styles.undo} onClick={this.props.onUndo}>Undo</span>
<span className={styles.undo} onClick={this.props.onUndo}>{t('comment.undo_reject')}</span>
}
</p>
</div>
@@ -76,6 +76,9 @@ const singleCommentFragment = gql`
id
username
}
status_history {
type
}
action_summaries {
__typename
count
@@ -102,6 +102,9 @@ export default {
}
}
}
status_history {
type
}
action_summaries {
count
current_user {
@@ -182,6 +185,7 @@ export default {
editableUntil: new Date().toISOString(),
edited: false,
},
status_history: [],
id: `pending-${uuid()}`,
}
}
+7 -1
View File
@@ -3,6 +3,7 @@ import cn from 'classnames';
import styles from './Slot.css';
import {connect} from 'react-redux';
import omit from 'lodash/omit';
import kebabCase from 'lodash/kebabCase';
import PropTypes from 'prop-types';
import isEqual from 'lodash/isEqual';
import {getShallowChanges} from 'coral-framework/utils';
@@ -58,6 +59,7 @@ class Slot extends React.Component {
childFactory,
defaultComponent: DefaultComponent,
queryData,
fill,
} = this.props;
const {plugins} = this.context;
let children = this.getChildren();
@@ -72,7 +74,7 @@ class Slot extends React.Component {
}
return (
<Component className={cn({[styles.inline]: inline, [styles.debug]: pluginConfig.debug}, className)}>
<Component className={cn({[styles.inline]: inline, [styles.debug]: pluginConfig.debug}, className, `talk-slot-${kebabCase(fill)}`)}>
{children}
</Component>
);
@@ -85,6 +87,10 @@ Slot.defaultProps = {
Slot.propTypes = {
fill: PropTypes.string.isRequired,
inline: PropTypes.bool,
className: PropTypes.string,
reduxState: PropTypes.object,
defaultComponent: PropTypes.component,
/**
* You may specify the component to use as the root wrapper.
@@ -138,6 +138,9 @@ export const withSetCommentStatus = withMutation(
const fragment = gql`
fragment Talk_SetCommentStatus on Comment {
status
status_history {
type
}
}`;
const fragmentId = `Comment_${commentId}`;
@@ -145,6 +148,8 @@ export const withSetCommentStatus = withMutation(
const data = proxy.readFragment({fragment, id: fragmentId});
data.status = status;
data.status_history = data.status_history ? data.status_history : [];
data.status_history.push({__typename: 'CommentStatusHistory', type: status});
proxy.writeFragment({fragment, id: fragmentId, data});
}
+14 -1
View File
@@ -13,6 +13,18 @@
border-bottom: solid 1px #EBEBEB;
}
.main {
min-width: 70%;
}
.sidebar {
min-width: 30%;
}
.commentBody {
word-wrap: break-word;
}
.assetURL {
text-decoration: none;
font-weight: bold;
@@ -44,7 +56,8 @@
margin-top: 0;
margin-bottom: 0;
list-style-type: none;
min-width: 136px;
min-width: 140px;
padding: 0px 10px;
}
li {
+1 -1
View File
@@ -19,7 +19,7 @@ class Comment extends React.Component {
return (
<div className={styles.myComment}>
<div>
<div className={styles.main}>
<Slot
fill="commentContent"
defaultComponent={CommentContent}