Limiting to user actions.

This commit is contained in:
David Jay
2017-01-04 15:56:52 -05:00
parent 216b21251d
commit 7a239c02ab
4 changed files with 13 additions and 14 deletions
@@ -18,11 +18,11 @@ export default class ModerationList extends React.Component {
static propTypes = {
isActive: PropTypes.bool,
singleView: PropTypes.bool,
commentIds: PropTypes.arrayOf(PropTypes.string).isRequired,
actionIds: PropTypes.arrayOf(PropTypes.string).isRequired,
comments: PropTypes.object.isRequired,
commentIds: PropTypes.arrayOf(PropTypes.string),
actionIds: PropTypes.arrayOf(PropTypes.string),
comments: PropTypes.object,
users: PropTypes.object.isRequired,
actions: PropTypes.object.isRequired,
actions: PropTypes.object,
onClickAction: PropTypes.func.isRequired,
// list of actions (flags, etc) associated with the comments
@@ -141,7 +141,7 @@ export default class ModerationList extends React.Component {
mapModItems = (itemId, index) => {
const {comments, users, actions, modActions, suspectWords, hideActive} = this.props;
const {comments = {}, users, actions = {}, modActions, suspectWords, hideActive} = this.props;
const {active} = this.state;
// Because ids are unique, the id will either appear as an action or as a comment.
@@ -186,7 +186,7 @@ export default class ModerationList extends React.Component {
}
render () {
const {singleView, commentIds, actionIds, comments, actions, key} = this.props;
const {singleView, commentIds = [], actionIds = [], comments, actions, key} = this.props;
// Combine moderations and actions into a single stream and sort by most recently updated.
const moderationIds = [ ...commentIds, ...actionIds ].sort((a, b) => {
@@ -61,16 +61,19 @@ class ModerationContainer extends React.Component {
}
render () {
const {comments} = this.props;
const {comments, actions} = this.props;
const premodIds = comments.ids.filter(id => comments.byId[id].status === 'premod');
const rejectedIds = comments.ids.filter(id => comments.byId[id].status === 'rejected');
const flaggedIds = comments.ids.filter(id => comments.byId[id].flagged === true);
const userActionIds = actions.ids.filter(id => actions.byId[id].item_type === 'user');
return (
<ModerationQueue
onTabClick={this.onTabClick}
onClose={this.onClose}
premodIds={premodIds}
userActionIds={userActionIds}
rejectedIds={rejectedIds}
flaggedIds={flaggedIds}
{...this.props}
@@ -29,7 +29,7 @@ export default (props) => (
commentIds={props.premodIds}
comments={props.comments.byId}
users={props.users.byId}
actionIds={props.actions.ids}
actionIds={props.userActionIds}
actions={props.actions.byId}
onClickAction={props.updateStatus}
onClickShowBanDialog={props.showBanUserDialog}
@@ -50,8 +50,6 @@ export default (props) => (
commentIds={props.rejectedIds}
comments={props.comments.byId}
users={props.users.byId}
actionIds={props.actions.ids}
actions={props.actions.byId}
onClickAction={props.updateStatus}
modActions={['approve']}
loading={props.comments.loading}
@@ -65,8 +63,6 @@ export default (props) => (
commentIds={props.flaggedIds}
comments={props.comments.byId}
users={props.users.byId}
actionIds={props.actions.ids}
actions={props.actions.byId}
onClickAction={props.updateStatus}
modActions={['reject', 'approve']}
loading={props.comments.loading}/>
+2 -2
View File
@@ -1,4 +1,4 @@
import {Map, Set} from 'immutable';
import {Map, Set, fromJS} from 'immutable';
import * as types from '../constants/actions';
const initialState = Map({
@@ -20,5 +20,5 @@ const addActions = (state, action) => {
memo[action.item_id] = action;
return memo;
}, {});
return state.set('byId', map).set('ids', ids);
return state.set('byId', fromJS(map)).set('ids', new Set(ids));
};