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 c0b526e98d79c1c7f806ebfa55c75bab2cfb6437 Mon Sep 17 00:00:00 2001 From: Kim Gardner Date: Tue, 9 May 2017 08:03:18 -0400 Subject: [PATCH 5/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 From 3c06ee9360f6595319454c7a9f555ee65ec4fc16 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 9 May 2017 12:21:21 -0300 Subject: [PATCH 6/7] Adds slots to admin stream --- .../ModerationQueue/components/Comment.js | 23 +++++++++++++++++-- 1 file changed, 21 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..8726cc75c 100644 --- a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js +++ b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js @@ -1,16 +1,17 @@ import React, {PropTypes} from 'react'; import timeago from 'timeago.js'; +import {Link} from 'react-router'; import Linkify from 'react-linkify'; import Highlighter from 'react-highlight-words'; -import {Link} from 'react-router'; import styles from './styles.css'; import {Icon} from 'coral-ui'; import FlagBox from './FlagBox'; import CommentType from './CommentType'; +import Slot from 'coral-framework/components/Slot'; +import {getActionSummary} from 'coral-framework/utils'; import ActionButton from 'coral-admin/src/components/ActionButton'; import BanUserButton from 'coral-admin/src/components/BanUserButton'; -import {getActionSummary} from 'coral-framework/utils'; const linkify = new Linkify(); @@ -50,6 +51,10 @@ const Comment = ({actions = [], comment, ...props}) => { {lang.t('comment.banned_user')} : null} +
Story: {comment.asset.title} @@ -62,6 +67,10 @@ const Comment = ({actions = [], comment, ...props}) => { +

{links ? Contains Link : null} @@ -78,9 +87,19 @@ const Comment = ({actions = [], comment, ...props}) => { rejectComment={() => props.rejectComment({commentId: comment.id})} />; })}
+
+
+ +
{ flagActions && flagActions.length ? From 52b0819e7874802182dfa317efb761927a26c81c Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 9 May 2017 14:02:35 -0300 Subject: [PATCH 7/7] Adding example for plugins within the Admin Comment Queue --- .gitignore | 1 + plugins/coral-plugin-mod/client/.babelrc | 14 ++++++++ .../coral-plugin-mod/client/.eslintrc.json | 23 +++++++++++++ .../coral-plugin-mod/client/components/Box.js | 8 +++++ .../client/components/Container.js | 32 +++++++++++++++++++ .../client/components/styles.css | 8 +++++ plugins/coral-plugin-mod/client/index.js | 7 ++++ plugins/coral-plugin-mod/index.js | 4 +++ 8 files changed, 97 insertions(+) create mode 100644 plugins/coral-plugin-mod/client/.babelrc create mode 100644 plugins/coral-plugin-mod/client/.eslintrc.json create mode 100644 plugins/coral-plugin-mod/client/components/Box.js create mode 100644 plugins/coral-plugin-mod/client/components/Container.js create mode 100644 plugins/coral-plugin-mod/client/components/styles.css create mode 100644 plugins/coral-plugin-mod/client/index.js create mode 100644 plugins/coral-plugin-mod/index.js diff --git a/.gitignore b/.gitignore index a619f0988..9f04eb4b8 100644 --- a/.gitignore +++ b/.gitignore @@ -20,5 +20,6 @@ plugins/* !plugins/coral-plugin-respect !plugins/coral-plugin-offtopic !plugins/coral-plugin-like +!plugins/coral-plugin-mod **/node_modules/* diff --git a/plugins/coral-plugin-mod/client/.babelrc b/plugins/coral-plugin-mod/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/coral-plugin-mod/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/coral-plugin-mod/client/.eslintrc.json b/plugins/coral-plugin-mod/client/.eslintrc.json new file mode 100644 index 000000000..9fe56bd14 --- /dev/null +++ b/plugins/coral-plugin-mod/client/.eslintrc.json @@ -0,0 +1,23 @@ +{ + "env": { + "browser": true, + "es6": true, + "mocha": true + }, + "parserOptions": { + "sourceType": "module", + "ecmaFeatures": { + "experimentalObjectRestSpread": true, + "jsx": true + } + }, + "parser": "babel-eslint", + "plugins": [ + "react" + ], + "rules": { + "react/jsx-uses-react": "error", + "react/jsx-uses-vars": "error", + "no-console": ["warn", { "allow": ["warn", "error"] }] + } +} diff --git a/plugins/coral-plugin-mod/client/components/Box.js b/plugins/coral-plugin-mod/client/components/Box.js new file mode 100644 index 000000000..15f5320b1 --- /dev/null +++ b/plugins/coral-plugin-mod/client/components/Box.js @@ -0,0 +1,8 @@ +import React from 'react'; +import styles from './styles.css' + +export default (props) => ( +
+ Comment Status: {props.comment.status} +
+) \ No newline at end of file diff --git a/plugins/coral-plugin-mod/client/components/Container.js b/plugins/coral-plugin-mod/client/components/Container.js new file mode 100644 index 000000000..712031fdf --- /dev/null +++ b/plugins/coral-plugin-mod/client/components/Container.js @@ -0,0 +1,32 @@ +import React from 'react'; +import Box from './Box'; +import {Button} from 'coral-ui' +import styles from './styles.css'; + +export default class Footer extends React.Component { + constructor() { + super(); + + this.state = { + show: false + }; + } + + handleClick = () => { + this.setState(state => ({ + show: !state.show + })) + } + + render() { + const {show} = this.state; + return ( +
+ + {show ? : null} +
+ ); + } +} diff --git a/plugins/coral-plugin-mod/client/components/styles.css b/plugins/coral-plugin-mod/client/components/styles.css new file mode 100644 index 000000000..59bb63c3d --- /dev/null +++ b/plugins/coral-plugin-mod/client/components/styles.css @@ -0,0 +1,8 @@ +.container { + padding: 0 14px 10px; +} + +.box { + font-size: 12px; + padding: 10px 14px; +} \ No newline at end of file diff --git a/plugins/coral-plugin-mod/client/index.js b/plugins/coral-plugin-mod/client/index.js new file mode 100644 index 000000000..b0ea304f4 --- /dev/null +++ b/plugins/coral-plugin-mod/client/index.js @@ -0,0 +1,7 @@ +import Container from './components/Container'; + +export default { + slots: { + adminCommentDetailArea: [Container], + } +}; diff --git a/plugins/coral-plugin-mod/index.js b/plugins/coral-plugin-mod/index.js new file mode 100644 index 000000000..42d90e144 --- /dev/null +++ b/plugins/coral-plugin-mod/index.js @@ -0,0 +1,4 @@ +const {readFileSync} = require('fs'); +const path = require('path'); + +module.exports = {};