From 67b17160cb54b7fb1b02cedc6f68aaf2c03396bc Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Thu, 4 May 2017 14:42:43 -0600 Subject: [PATCH 1/7] don't accept/reject when a comment is already accepted/rejected respectively --- .../src/containers/ModerationQueue/components/Comment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js index e5afd9726..8c4b6f174 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js +++ b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js @@ -74,8 +74,8 @@ const Comment = ({actions = [], comment, ...props}) => { user={comment.user} status={comment.status} active={active} - acceptComment={() => props.acceptComment({commentId: comment.id})} - rejectComment={() => props.rejectComment({commentId: comment.id})} />; + acceptComment={() => comment.status === 'ACCEPTED' ? null : props.acceptComment({commentId: comment.id})} + rejectComment={() => comment.status === 'REJECTED' ? null : props.rejectComment({commentId: comment.id})} />; })} From 4507059a04f5f0f7b63a98de382f8309097a22f7 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Thu, 4 May 2017 15:43:23 -0600 Subject: [PATCH 2/7] same thing for BanUserDialog and the keyboard shortcuts --- client/coral-admin/src/actions/moderation.js | 2 +- client/coral-admin/src/components/BanUserDialog.js | 8 ++++---- .../coral-admin/src/containers/Dashboard/Dashboard.js | 8 +------- .../containers/ModerationQueue/ModerationContainer.js | 10 ++++++---- .../containers/ModerationQueue/components/Comment.js | 2 +- client/coral-admin/src/reducers/moderation.js | 5 ++++- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/client/coral-admin/src/actions/moderation.js b/client/coral-admin/src/actions/moderation.js index b7117181e..c93dc0c76 100644 --- a/client/coral-admin/src/actions/moderation.js +++ b/client/coral-admin/src/actions/moderation.js @@ -4,7 +4,7 @@ export const toggleModal = open => ({type: actions.TOGGLE_MODAL, open}); export const singleView = () => ({type: actions.SINGLE_VIEW}); // Ban User Dialog -export const showBanUserDialog = (user, commentId, showRejectedNote) => ({type: actions.SHOW_BANUSER_DIALOG, user, commentId, showRejectedNote}); +export const showBanUserDialog = (user, commentId, commentStatus, showRejectedNote) => ({type: actions.SHOW_BANUSER_DIALOG, user, commentId, commentStatus, showRejectedNote}); export const hideBanUserDialog = (showDialog) => ({type: actions.HIDE_BANUSER_DIALOG, showDialog}); // hide shortcuts note diff --git a/client/coral-admin/src/components/BanUserDialog.js b/client/coral-admin/src/components/BanUserDialog.js index ee5830249..b259012f3 100644 --- a/client/coral-admin/src/components/BanUserDialog.js +++ b/client/coral-admin/src/components/BanUserDialog.js @@ -8,14 +8,14 @@ import I18n from 'coral-framework/modules/i18n/i18n'; import translations from '../translations'; const lang = new I18n(translations); -const onBanClick = (userId, commentId, handleBanUser, rejectComment, handleClose) => (e) => { +const onBanClick = (userId, commentId, commentStatus, handleBanUser, rejectComment, handleClose) => (e) => { e.preventDefault(); handleBanUser({userId}) .then(handleClose) - .then(() => rejectComment({commentId})); + .then(() => commentStatus === 'REJECTED' ? null : rejectComment({commentId})); }; -const BanUserDialog = ({open, handleClose, handleBanUser, rejectComment, user, commentId, showRejectedNote}) => ( +const BanUserDialog = ({open, handleClose, handleBanUser, rejectComment, user, commentId, commentStatus, showRejectedNote}) => ( {lang.t('bandialog.cancel')} - diff --git a/client/coral-admin/src/containers/Dashboard/Dashboard.js b/client/coral-admin/src/containers/Dashboard/Dashboard.js index f5d0aa39b..e6cfa27cd 100644 --- a/client/coral-admin/src/containers/Dashboard/Dashboard.js +++ b/client/coral-admin/src/containers/Dashboard/Dashboard.js @@ -6,7 +6,6 @@ import {getMetrics} from 'coral-admin/src/graphql/queries'; import FlagWidget from './FlagWidget'; import ActivityWidget from './ActivityWidget'; import CountdownTimer from 'coral-admin/src/components/CountdownTimer'; -import {showBanUserDialog, hideBanUserDialog} from 'coral-admin/src/actions/moderation'; import {Spinner} from 'coral-ui'; @@ -43,12 +42,7 @@ const mapStateToProps = state => { }; }; -const mapDispatchToProps = dispatch => ({ - showBanUserDialog: (user, commentId) => dispatch(showBanUserDialog(user, commentId)), - hideBanUserDialog: () => dispatch(hideBanUserDialog(false)) -}); - export default compose( - connect(mapStateToProps, mapDispatchToProps), + connect(mapStateToProps), getMetrics )(Dashboard); diff --git a/client/coral-admin/src/containers/ModerationQueue/ModerationContainer.js b/client/coral-admin/src/containers/ModerationQueue/ModerationContainer.js index 7a3aab909..9606be543 100644 --- a/client/coral-admin/src/containers/ModerationQueue/ModerationContainer.js +++ b/client/coral-admin/src/containers/ModerationQueue/ModerationContainer.js @@ -43,12 +43,13 @@ class ModerationContainer extends Component { const {acceptComment, rejectComment} = this.props; const {selectedIndex} = this.state; const comments = this.getComments(); - const commentId = {commentId: comments[selectedIndex].id}; + const comment = comments[selectedIndex]; + const commentId = {commentId: comment.id}; if (accept) { - acceptComment(commentId); + comment.status !== 'ACCEPTED' && acceptComment(commentId); } else { - rejectComment(commentId); + comment.status !== 'REJECTED' && rejectComment(commentId); } } @@ -185,6 +186,7 @@ class ModerationContainer extends Component { open={moderation.banDialog} user={moderation.user} commentId={moderation.commentId} + commentStatus={moderation.commentStatus} handleClose={props.hideBanUserDialog} handleBanUser={props.banUser} showRejectedNote={moderation.showRejectedNote} @@ -212,7 +214,7 @@ const mapDispatchToProps = dispatch => ({ singleView: () => dispatch(singleView()), updateAssets: assets => dispatch(updateAssets(assets)), fetchSettings: () => dispatch(fetchSettings()), - showBanUserDialog: (user, commentId, showRejectedNote) => dispatch(showBanUserDialog(user, commentId, showRejectedNote)), + showBanUserDialog: (user, commentId, commentStatus, showRejectedNote) => dispatch(showBanUserDialog(user, commentId, commentStatus, showRejectedNote)), hideBanUserDialog: () => dispatch(hideBanUserDialog(false)), hideShortcutsNote: () => dispatch(hideShortcutsNote()), }); diff --git a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js index 8c4b6f174..d8982e4dc 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js +++ b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js @@ -41,7 +41,7 @@ const Comment = ({actions = [], comment, ...props}) => { {timeago().format(comment.created_at || (Date.now() - props.index * 60 * 1000), lang.getLocale().replace('-', '_'))} - props.showBanUserDialog(comment.user, comment.id, comment.status !== 'REJECTED')} /> + props.showBanUserDialog(comment.user, comment.id, comment.status, comment.status !== 'REJECTED')} /> {comment.user.status === 'banned' ? diff --git a/client/coral-admin/src/reducers/moderation.js b/client/coral-admin/src/reducers/moderation.js index a40ac865f..8f51cea6b 100644 --- a/client/coral-admin/src/reducers/moderation.js +++ b/client/coral-admin/src/reducers/moderation.js @@ -6,6 +6,7 @@ const initialState = Map({ modalOpen: false, user: Map({}), commentId: null, + commentStatus: null, banDialog: false, shortcutsNoteVisible: window.localStorage.getItem('coral:shortcutsNote') || 'show' }); @@ -14,12 +15,14 @@ export default function moderation (state = initialState, action) { switch (action.type) { case actions.HIDE_BANUSER_DIALOG: return state - .set('banDialog', false); + .set('banDialog', false) + .set('commentStatus', null); case actions.SHOW_BANUSER_DIALOG: return state .merge({ user: Map(action.user), commentId: action.commentId, + commentStatus: action.commentStatus, showRejectedNote: action.showRejectedNote, banDialog: true }); From f3f0b9c858f5e262ac0ebf7c6b6844ae226cb8ca Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Thu, 4 May 2017 15:55:46 -0600 Subject: [PATCH 3/7] change mouse cursor for disabled buttons --- client/coral-admin/src/components/ModerationList.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/coral-admin/src/components/ModerationList.css b/client/coral-admin/src/components/ModerationList.css index 1e871f97c..4d4f37c9a 100644 --- a/client/coral-admin/src/components/ModerationList.css +++ b/client/coral-admin/src/components/ModerationList.css @@ -193,10 +193,12 @@ box-shadow: none; color: white; background-color: #519954; + cursor: not-allowed; } .reject__active, .rejected__active { color: white; background-color: #D03235; box-shadow: none; + cursor: not-allowed; } From 50d832c2f89d979234aaa85a44eca654beef7094 Mon Sep 17 00:00:00 2001 From: David Erwin Date: Mon, 8 May 2017 16:21:24 -0400 Subject: [PATCH 4/7] Remove pseudocode --- docs/frontend/PLUGINS.md | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/docs/frontend/PLUGINS.md b/docs/frontend/PLUGINS.md index fa582877c..2ca36a4f1 100644 --- a/docs/frontend/PLUGINS.md +++ b/docs/frontend/PLUGINS.md @@ -95,18 +95,12 @@ Slots properties take an`Array` so we can add as many components as we want. `Note: the concepts in this section are still to be implemented. Code samples are for discussion and may change.` -In order to allow you to build more complex plugins, we have wrapped some of our functionality in higher order componenets that expose a simple api. +In order to allow you to build more complex plugins, we have wrapped some of our functionality in higher order components that expose a simple api. ### Reactions Reactions provide users the ability to 'like', 'respect', etc... comments. -``` - - - -``` - Note: some server side work will need to accompany this client side component. See the like and respect plugins as examples. ### Comment Stream @@ -117,10 +111,6 @@ Comment streams may be created with filtering and ordering in place: * filter by tag * sort by date ascending / descrnding -``` - -``` - ### Comment Commit hooks // docs for the pre/post comment submit commit hooks From 242f3ea5ea5c59ec4e49c9152d5febe7d5bbfe89 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Mon, 8 May 2017 17:01:36 -0600 Subject: [PATCH 5/7] do not highlight partial word matches in admin since this is not how the backend works --- .../containers/ModerationQueue/components/Comment.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js index e5afd9726..fedb72d45 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js +++ b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js @@ -18,7 +18,7 @@ import I18n from 'coral-framework/modules/i18n/i18n'; import translations from 'coral-admin/src/translations.json'; const lang = new I18n(translations); -const Comment = ({actions = [], comment, ...props}) => { +const Comment = ({actions = [], comment, suspectWords, bannedWords, ...props}) => { const links = linkify.getMatches(comment.body); const linkText = links ? links.map(link => link.raw) : []; const flagActionSummaries = getActionSummary('FlagActionSummary', comment); @@ -30,6 +30,13 @@ const Comment = ({actions = [], comment, ...props}) => { commentType = 'flagged'; } + // since words are checked against word boundaries on the backend, + // this should be the behavior on the front end as well. + // currently the highlighter plugin does not support this out of the box. + const searchWords = [...suspectWords, ...bannedWords].filter(w => { + return new RegExp(`(^|\\s)${w}(\\s|$)`).test(comment.body); + }).concat(linkText); + return (
  • @@ -60,7 +67,7 @@ const Comment = ({actions = [], comment, ...props}) => {

    From 2490e6598162df2ed422bc45b1f6d0255c7f6e94 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Mon, 8 May 2017 17:09:23 -0600 Subject: [PATCH 6/7] merge master --- client/coral-admin/src/AppRouter.js | 4 ++-- .../ModerationQueue/components/Comment.js | 3 ++- .../components/ModerationMenu.js | 12 +++++------ .../ModerationQueue/components/styles.css | 21 +++++++++++++++++++ .../src/graphql/fragments/commentView.graphql | 1 + client/coral-admin/src/translations.json | 2 ++ graph/pubsub.js | 2 +- 7 files changed, 35 insertions(+), 10 deletions(-) diff --git a/client/coral-admin/src/AppRouter.js b/client/coral-admin/src/AppRouter.js index af3423acc..989316dd9 100644 --- a/client/coral-admin/src/AppRouter.js +++ b/client/coral-admin/src/AppRouter.js @@ -1,5 +1,5 @@ import React from 'react'; -import {Router, Route, IndexRoute, IndexRedirect, browserHistory} from 'react-router'; +import {Router, Route, IndexRedirect, browserHistory} from 'react-router'; import Stories from 'containers/Stories/Stories'; import Configure from 'containers/Configure/Configure'; @@ -18,7 +18,7 @@ const routes = (
    - + diff --git a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js index fedb72d45..a5647fd92 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js +++ b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js @@ -68,7 +68,7 @@ const Comment = ({actions = [], comment, suspectWords, bannedWords, ...props}) =

    + textToHighlight={comment.body} /> {lang.t('comment.view_context')}

    {links ? Contains Link : null} @@ -113,6 +113,7 @@ Comment.propTypes = { }), asset: PropTypes.shape({ title: PropTypes.string, + url: PropTypes.string, id: PropTypes.string }) }) diff --git a/client/coral-admin/src/containers/ModerationQueue/components/ModerationMenu.js b/client/coral-admin/src/containers/ModerationQueue/components/ModerationMenu.js index 39594274e..7a50e6270 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/ModerationMenu.js +++ b/client/coral-admin/src/containers/ModerationQueue/components/ModerationMenu.js @@ -28,12 +28,6 @@ const ModerationMenu = ( activeClassName={styles.active}> {lang.t('modqueue.all')} - - {lang.t('modqueue.approved')} - {lang.t('modqueue.flagged')} + + {lang.t('modqueue.approved')} + Date: Tue, 9 May 2017 08:03:18 -0400 Subject: [PATCH 7/7] Fix typo --- docs/frontend/PLUGINS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/frontend/PLUGINS.md b/docs/frontend/PLUGINS.md index 2ca36a4f1..8377d0359 100644 --- a/docs/frontend/PLUGINS.md +++ b/docs/frontend/PLUGINS.md @@ -109,7 +109,7 @@ Comment streams may be created with filtering and ordering in place: * filter by user * filter by tag -* sort by date ascending / descrnding +* sort by date ascending / descending ### Comment Commit hooks