From ef0055e6895f4bd1f1e30e63ca7f801be501c100 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Tue, 20 Dec 2016 16:42:16 -0700 Subject: [PATCH] highlight suspect words --- client/coral-admin/src/components/Comment.js | 7 ++-- .../coral-admin/src/components/CommentList.js | 34 +++++++------------ .../ModerationQueue/ModerationQueue.js | 14 ++++---- package.json | 1 + 4 files changed, 27 insertions(+), 29 deletions(-) diff --git a/client/coral-admin/src/components/Comment.js b/client/coral-admin/src/components/Comment.js index 291825c71..17bd56714 100644 --- a/client/coral-admin/src/components/Comment.js +++ b/client/coral-admin/src/components/Comment.js @@ -8,6 +8,7 @@ import I18n from 'coral-framework/modules/i18n/i18n'; import translations from '../translations.json'; import {Icon} from 'react-mdl'; +import Highlighter from 'react-highlight-words'; import {FabButton, Button} from 'coral-ui'; const linkify = new Linkify(); @@ -31,7 +32,7 @@ export default props => { {links ? Contains Link : null}
- {props.actions.map((action, i) => getActionButton(action, i, props))} + {props.modActions.map((action, i) => getActionButton(action, i, props))}
@@ -42,7 +43,9 @@ export default props => {
- {comment.body} +
diff --git a/client/coral-admin/src/components/CommentList.js b/client/coral-admin/src/components/CommentList.js index c6682e5de..1d63577c1 100644 --- a/client/coral-admin/src/components/CommentList.js +++ b/client/coral-admin/src/components/CommentList.js @@ -5,7 +5,7 @@ import Hammer from 'hammerjs'; import Comment from 'components/Comment'; // Each action has different meaning and configuration -const actions = { +const modActions = { 'reject': {status: 'rejected', icon: 'close', key: 'r'}, 'approve': {status: 'accepted', icon: 'done', key: 't'}, 'flag': {status: 'flagged', icon: 'flag', filter: 'Untouched'}, @@ -21,18 +21,12 @@ export default class CommentList extends React.Component { comments: PropTypes.object.isRequired, users: PropTypes.object.isRequired, onClickAction: PropTypes.func, - actions: PropTypes.arrayOf(PropTypes.string), + modActions: PropTypes.arrayOf(PropTypes.string), loading: PropTypes.bool, // list of actions (flags, etc) associated with the comments - commentActions: PropTypes.arrayOf( - PropTypes.shape({ - action_type: PropTypes.string, - count: PropTypes.number, - current_user: PropTypes.string, - item_id: PropTypes.string, - item_type: PropTypes.string - }) - ), + actions: PropTypes.shape({ + ids: PropTypes.arrayOf(PropTypes.string) + }).isRequired, suspectWords: PropTypes.arrayOf(PropTypes.string) } @@ -65,22 +59,22 @@ export default class CommentList extends React.Component { // Add swipe to approve or reject bindGestures () { - const {actions} = this.props; + const {modActions} = this.props; this._hammer = new Hammer(this.base); this._hammer.get('swipe').set({direction: Hammer.DIRECTION_HORIZONTAL}); - if (actions.indexOf('reject') !== -1) { + if (modActions.indexOf('reject') !== -1) { this._hammer.on('swipeleft', () => this.props.singleView && this.actionKeyHandler('Rejected')); } - if (actions.indexOf('approve') !== -1) { + if (modActions.indexOf('approve') !== -1) { this._hammer.on('swiperight', () => this.props.singleView && this.actionKeyHandler('Approved')); } } // Add key handlers. Each action has one and added j/k for moving around bindKeyHandlers () { - this.props.actions.filter(action => actions[action].key).forEach(action => { - key(actions[action].key, 'commentList', () => this.props.isActive && this.actionKeyHandler(actions[action].status)); + this.props.modActions.filter(action => modActions[action].key).forEach(action => { + key(modActions[action].key, 'commentList', () => this.props.isActive && this.actionKeyHandler(modActions[action].status)); }); key('j', 'commentList', () => this.props.isActive && this.moveKeyHandler('down')); key('k', 'commentList', () => this.props.isActive && this.moveKeyHandler('up')); @@ -143,7 +137,7 @@ export default class CommentList extends React.Component { } render () { - const {singleView, commentIds, comments, users, hideActive, key, suspectWords, commentActions} = this.props; + const {singleView, commentIds, comments, users, hideActive, key, suspectWords} = this.props; const {active} = this.state; return ( @@ -154,9 +148,7 @@ export default class CommentList extends React.Component { {commentIds.map((commentId, index) => { const comment = comments[commentId]; const author = users[comment.author_id]; - const localActions = commentActions.filter(action => action.item_id === commentId); return ; })} diff --git a/client/coral-admin/src/containers/ModerationQueue/ModerationQueue.js b/client/coral-admin/src/containers/ModerationQueue/ModerationQueue.js index 2e59e20ee..1d661ed01 100644 --- a/client/coral-admin/src/containers/ModerationQueue/ModerationQueue.js +++ b/client/coral-admin/src/containers/ModerationQueue/ModerationQueue.js @@ -111,7 +111,7 @@ class ModerationQueue extends React.Component {
this.onCommentAction(action, comment)} onClickShowBanDialog={(userId, userName, commentId) => this.showBanUserDialog(userId, userName, commentId)} - actions={['reject', 'approve', 'ban']} + modActions={['reject', 'approve', 'ban']} loading={comments.loading} />
this.onCommentAction(action, comment)} - actions={['approve']} + modActions={['approve']} loading={comments.loading} />
this.onCommentAction(action, comment)} - actions={['reject', 'approve']} + modActions={['reject', 'approve']} loading={comments.loading} />