diff --git a/.gitignore b/.gitignore index e3ae90b9c..f0c3b2a4b 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,7 @@ plugins/* !plugins/coral-plugin-respect !plugins/coral-plugin-offtopic !plugins/coral-plugin-like +!plugins/coral-plugin-mod !plugins/coral-plugin-love **/node_modules/* diff --git a/client/coral-admin/src/containers/ModerationQueue/components/Comment.js b/client/coral-admin/src/containers/ModerationQueue/components/Comment.js index ffd4db2a6..55a00096d 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 Linkify from 'react-linkify'; -import Highlighter from 'react-highlight-words'; import {Link} from 'react-router'; +import Linkify from 'react-linkify'; -import styles from './styles.css'; import {Icon} from 'coral-ui'; import FlagBox from './FlagBox'; +import styles from './styles.css'; import CommentType from './CommentType'; +import Highlighter from 'react-highlight-words'; +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(); @@ -18,11 +19,19 @@ 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, suspectWords, bannedWords, ...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); - const flagActions = comment.actions && comment.actions.filter(a => a.__typename === 'FlagAction'); + const flagActions = + comment.actions && + comment.actions.filter(a => a.__typename === 'FlagAction'); let commentType = ''; if (comment.status === 'PREMOD') { commentType = 'premod'; @@ -33,12 +42,17 @@ const Comment = ({actions = [], comment, suspectWords, bannedWords, ...props}) = // 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); + const searchWords = [...suspectWords, ...bannedWords] + .filter(w => { + return new RegExp(`(^|\\s)${w}(\\s|$)`).test(comment.body); + }) + .concat(linkText); return ( -
  • +
  • @@ -46,53 +60,95 @@ const Comment = ({actions = [], comment, suspectWords, bannedWords, ...props}) = {comment.user.name} - {timeago().format(comment.created_at || (Date.now() - props.index * 60 * 1000), lang.getLocale().replace('-', '_'))} + {timeago().format( + comment.created_at || Date.now() - props.index * 60 * 1000, + lang.getLocale().replace('-', '_') + )} - props.showBanUserDialog(comment.user, comment.id, comment.status, comment.status !== 'REJECTED')} /> + + props.showBanUserDialog( + comment.user, + comment.id, + comment.status, + comment.status !== 'REJECTED' + )} + />
    - {comment.user.status === 'banned' ? - - - {lang.t('comment.banned_user')} - + {comment.user.status === 'banned' + ? + + {lang.t('comment.banned_user')} + : null} +
    Story: {comment.asset.title} - {!props.currentAsset && ( - Moderate → - )} + {!props.currentAsset && + Moderate →}

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

    +
    - {links ? Contains Link : null} + {links + ? + Contains Link + + : null}
    {actions.map((action, i) => { - const active = (action === 'REJECT' && comment.status === 'REJECTED') || - (action === 'APPROVE' && comment.status === 'ACCEPTED'); - return comment.status === 'ACCEPTED' ? null : props.acceptComment({commentId: comment.id})} - rejectComment={() => comment.status === 'REJECTED' ? null : props.rejectComment({commentId: comment.id})} />; + const active = + (action === 'REJECT' && comment.status === 'REJECTED') || + (action === 'APPROVE' && comment.status === 'ACCEPTED'); + return ( + + (comment.status === 'ACCEPTED' + ? null + : props.acceptComment({commentId: comment.id}))} + rejectComment={() => + (comment.status === 'REJECTED' + ? null + : props.rejectComment({commentId: comment.id}))} + /> + ); })}
    +
    - { - flagActions && flagActions.length - ? - : null - } +
    + +
    + {flagActions && flagActions.length + ? + : null}
  • ); }; 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 = {};