Updating bio moderation to graphQL architecture.

This commit is contained in:
David Jay
2017-01-26 15:31:15 -05:00
parent 31abe57cb2
commit 06331d3c07
7 changed files with 27 additions and 11 deletions
@@ -35,7 +35,7 @@ const BanUserDialog = ({open, handleClose, onClickBanUser, user = {}}) => (
<Button cStyle="cancel" className={styles.cancel} onClick={() => handleClose()} raised>
{lang.t('bandialog.cancel')}
</Button>
<Button cStyle="black" className={styles.ban} onClick={() => onClickBanUser(user.userId, user.commentId)} raised>
<Button cStyle="black" className={styles.ban} onClick={() => onClickBanUser('BANNED', user.userId, user.commentId)} raised>
{lang.t('bandialog.yes_ban_user')}
</Button>
</div>
+1 -1
View File
@@ -61,7 +61,7 @@ const getActionButton = (option, i, props) => {
}
if (option === 'ban') {
return (
<div className={styles.ban}>
<div className={styles.ban} key={i}>
<Button
className={`ban ${styles.banButton}`}
cStyle='darkGrey'
@@ -130,15 +130,15 @@ export default class ModerationList extends React.Component {
}
// Update the status right away if this is a comment
if (action.item_type === 'comments') {
if (action.item_type === 'COMMENTS') {
this.props.updateCommentStatus(menuOption, id);
} else if (action.item_type === 'users') {
} else if (action.item_type === 'USERS') {
// If a user bio or name is rejected, bring up a dialog before suspending them.
if (menuOption === 'rejected') {
this.setState({suspendUserModal: action});
} else if (menuOption === 'accepted') {
this.props.userStatusUpdate('active', action.item_id);
this.props.userStatusUpdate('ACTIVE', action.item_id);
}
}
}
@@ -20,7 +20,7 @@ const UserAction = props => {
// Do not display unless the user status is 'pending' or 'banned'.
// This means that they have already been reviewed and approved.
return (userStatus === 'pending' || userStatus === 'banned') &&
return (userStatus === 'PENDING' || userStatus === 'BANNED') &&
<li tabIndex={props.index} className={`${styles.listItem} ${props.isActive && !props.hideActive ? styles.activeItem : ''}`}>
<div className={styles.itemHeader}>
<div className={styles.author}>
@@ -66,7 +66,7 @@ export default UserAction;
const getActionButton = (option, i, props) => {
const {user, onClickShowBanDialog, onClickAction, menuOptionsMap, action} = props;
const status = user.status;
const banned = (user.status === 'banned');
const banned = (user.status === 'BANNED');
if (option === 'flag' && status) {
return null;
@@ -14,6 +14,15 @@ export default (props) => (
<div>
<div className='mdl-tabs'>
<div className={`mdl-tabs__tab-bar ${styles.tabBar}`}>
<a href='#all'
onClick={(e) => {
e.preventDefault();
props.onTabClick('all');
}}
className={`mdl-tabs__tab ${styles.tab} ${props.activeTab === 'all' ? styles.active : ''}`}
>
{lang.t('modqueue.all')}
</a>
<a href='#pending'
onClick={(e) => {
e.preventDefault();
+4 -2
View File
@@ -14,6 +14,7 @@ class FlagButton extends Component {
reason: '',
note: '',
step: 0,
posted: false,
localPost: null,
localDelete: false
}
@@ -38,7 +39,7 @@ class FlagButton extends Component {
onPopupContinue = () => {
const {postAction, id, author_id} = this.props;
const {itemType, reason, step, localPost} = this.state;
const {itemType, reason, step, posted} = this.state;
// Proceed to the next step or close the menu if we've reached the end
if (step + 1 >= this.props.getPopupMenu.length) {
@@ -48,7 +49,8 @@ class FlagButton extends Component {
}
// If itemType and reason are both set, post the action
if (itemType && reason && !localPost) {
if (itemType && reason && !posted) {
this.setState({posted: true});
// Set the text from the "other" field if it exists.
let item_id;
+7 -2
View File
@@ -1,8 +1,10 @@
const ActionModel = require('../../models/action');
const ActionsService = require('../../services/actions');
const UsersService = require('../../services/users');
/**
* Creates an action on a item.
* Creates an action on a item. If the item is a user flag, sets the user's status to
* pending.
* @param {Object} user the user performing the request
* @param {String} item_id id of the item to add the action to
* @param {String} item_type type of the item
@@ -16,7 +18,10 @@ const createAction = ({user = {}}, {item_id, item_type, action_type, metadata =
user_id: user.id,
action_type,
metadata
});
}).then((result) =>
item_type === 'USERS' && action_type === 'FLAG' ?
UsersService.setStatus(user.id, 'PENDING').then(() => result)
: result);
};
/**