@@ -52,16 +52,16 @@ export default props => {
const getActionButton = (action, i, props) => {
const status = props.comment.get('status');
const flagged = props.comment.get('flagged');
+ const banned = (props.author.get('status') === 'banned');
if (action === 'flag' && (status || flagged === true)) {
return null;
}
- if (action === 'ban') {
+ if (action === 'ban' && !banned) {
return (
-
+ onClick={() => props.onClickAction(props.actionsMap[action].status, props.comment.get('id'), props.author.get('id'))}>{lang.t('comment.ban_user')}
);
}
return (
diff --git a/client/coral-admin/src/components/CommentList.js b/client/coral-admin/src/components/CommentList.js
index 2df70209e..99664226e 100644
--- a/client/coral-admin/src/components/CommentList.js
+++ b/client/coral-admin/src/components/CommentList.js
@@ -10,7 +10,7 @@ const actions = {
'reject': {status: 'rejected', icon: 'close', key: 'r'},
'approve': {status: 'accepted', icon: 'done', key: 't'},
'flag': {status: 'flagged', icon: 'flag', filter: 'Untouched'},
- 'ban': {status: 'ban'}
+ 'ban': {status: 'banned'}
};
// Renders a comment list and allow performing actions
@@ -100,7 +100,8 @@ export default class CommentList extends React.Component {
// If we are performing an action over a comment (aka removing from the list) we need to select a new active.
// TODO: In the future this can be improved and look at the actual state to
// resolve since the content of the list could change externally. For now it works as expected
- onClickAction (action, id) {
+ onClickAction (action, id, author_id) {
+ // activate the next comment
if (id === this.state.active) {
const {commentIds} = this.props;
if (commentIds.last() === this.state.active) {
@@ -109,7 +110,7 @@ export default class CommentList extends React.Component {
this.setState({active: commentIds.get(Math.min(commentIds.indexOf(this.state.active) + 1, commentIds.size - 1))});
}
}
- this.props.onClickAction(action, id);
+ this.props.onClickAction(action, id, author_id);
}
render () {
diff --git a/client/coral-admin/src/containers/ModerationQueue/ModerationQueue.js b/client/coral-admin/src/containers/ModerationQueue/ModerationQueue.js
index b1a01c234..ba7ffa69a 100644
--- a/client/coral-admin/src/containers/ModerationQueue/ModerationQueue.js
+++ b/client/coral-admin/src/containers/ModerationQueue/ModerationQueue.js
@@ -6,7 +6,7 @@ import ModerationKeysModal from 'components/ModerationKeysModal';
import CommentList from 'components/CommentList';
import {updateStatus} from 'actions/comments';
-import {updateUserStatus} from 'actions/users';
+import {banUser} from 'actions/users';
import styles from './ModerationQueue.css';
import I18n from 'coral-framework/modules/i18n/i18n';
@@ -52,11 +52,11 @@ class ModerationQueue extends React.Component {
}
// Dispatch the update status action
- onCommentAction (action, id) {
- // if we are banning a user by the action then dispatch updateUserStatus
+ onCommentAction (action, id, author_id) {
+ // if we are banning a user by the action then dispatch banUser
// action = 'banned' in the case of banning
if (action === 'banned') {
- this.props.dispatch(updateUserStatus(action, id));
+ this.props.dispatch(banUser(action, id, author_id));
}
// If not banning then change the status to approved or flagged as action = status
@@ -69,7 +69,7 @@ class ModerationQueue extends React.Component {
// Render the tabbed lists moderation queues
render () {
- const {comments, commenters} = this.props;
+ const {comments, users} = this.props;
const {activeTab, singleView, modalOpen} = this.state;
return (
@@ -94,8 +94,8 @@ class ModerationQueue extends React.Component {
.get('status'))
}
comments={comments.get('byId')}
- commenters={commenters.get('byId')}
- onClickAction={(action, id) => this.onCommentAction(action, id)}
+ users={users.get('byId')}
+ onClickAction={(action, id, author_id) => this.onCommentAction(action, id, author_id)}
actions={['reject', 'approve', 'ban']}
loading={comments.loading} />