From 1b1f2a3608e54e027b71fcc76c5309cc389050a5 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 21 Jun 2017 10:42:01 -0300 Subject: [PATCH 1/9] Changing moderation keys: d approve and f reject --- .../src/routes/Moderation/components/Moderation.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/coral-admin/src/routes/Moderation/components/Moderation.js b/client/coral-admin/src/routes/Moderation/components/Moderation.js index 63c9e13ab..63fbac6df 100644 --- a/client/coral-admin/src/routes/Moderation/components/Moderation.js +++ b/client/coral-admin/src/routes/Moderation/components/Moderation.js @@ -31,8 +31,8 @@ export default class Moderation extends Component { key('esc', () => toggleModal(false)); key('j', this.select(true)); key('k', this.select(false)); - key('r', this.moderate(false)); - key('t', this.moderate(true)); + key('f', this.moderate(false)); + key('d', this.moderate(true)); } onClose = () => { From b0156fa11f2d8ecd8a937e6351873a2d75860898 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 21 Jun 2017 10:53:12 -0300 Subject: [PATCH 2/9] missing header css --- .../src/routes/Configure/components/StreamSettings.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/coral-admin/src/routes/Configure/components/StreamSettings.js b/client/coral-admin/src/routes/Configure/components/StreamSettings.js index 2de82ec1f..e8c522ae0 100644 --- a/client/coral-admin/src/routes/Configure/components/StreamSettings.js +++ b/client/coral-admin/src/routes/Configure/components/StreamSettings.js @@ -165,7 +165,7 @@ const StreamSettings = ({updateSettings, settingsError, settings, errors}) => { checked={settings.autoCloseStream} />
- {t('configure.close_after')} +
{t('configure.comment_count_header')}

Date: Wed, 21 Jun 2017 11:04:45 -0300 Subject: [PATCH 3/9] Show user details from flag history --- .../src/routes/Moderation/components/Comment.js | 1 + .../src/routes/Moderation/components/FlagBox.css | 14 ++++++++++++++ .../src/routes/Moderation/components/FlagBox.js | 13 +++++++++---- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/client/coral-admin/src/routes/Moderation/components/Comment.js b/client/coral-admin/src/routes/Moderation/components/Comment.js index 3d946f9fc..3d3e2803f 100644 --- a/client/coral-admin/src/routes/Moderation/components/Comment.js +++ b/client/coral-admin/src/routes/Moderation/components/Comment.js @@ -217,6 +217,7 @@ class Comment extends React.Component { ? viewUserDetail(comment.user.id)} /> : null} diff --git a/client/coral-admin/src/routes/Moderation/components/FlagBox.css b/client/coral-admin/src/routes/Moderation/components/FlagBox.css index 5b8ea4f91..402a88045 100644 --- a/client/coral-admin/src/routes/Moderation/components/FlagBox.css +++ b/client/coral-admin/src/routes/Moderation/components/FlagBox.css @@ -67,3 +67,17 @@ color: black; } } + +.username { + color: #393B44; + text-decoration: none; + cursor: pointer; + font-weight: 600; + padding: 2px 5px; + border-radius: 2px; + margin-left: -5px; + transition: background-color 200ms ease; +&:hover { + background-color: #E0E0E0; + } +} diff --git a/client/coral-admin/src/routes/Moderation/components/FlagBox.js b/client/coral-admin/src/routes/Moderation/components/FlagBox.js index 7dff51fdb..caa8b3fbc 100644 --- a/client/coral-admin/src/routes/Moderation/components/FlagBox.js +++ b/client/coral-admin/src/routes/Moderation/components/FlagBox.js @@ -33,7 +33,7 @@ class FlagBox extends Component { } render() { - const {actionSummaries, actions} = this.props; + const {actionSummaries, actions, viewUserDetail} = this.props; const {showDetail} = this.state; return ( @@ -59,9 +59,14 @@ class FlagBox extends Component {
  • {this.reasonMap(summary.reason)} ({summary.count})
      - { - actionList.map((action, j) =>
    • {action.user.username} {action.message}
    • ) - } + {actionList.map((action, j) => +
    • + + {action.user.username} + + {action.message} +
    • + )}
  • ); From 8bb38c5ee5c6f6be3f5bc69a050ba6476736909f Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Thu, 22 Jun 2017 21:50:19 +0700 Subject: [PATCH 4/9] Refactor and reuse "Actions" in "Moderate" and "Community" --- .../coral-admin/src/actions/banUserDialog.js | 7 + client/coral-admin/src/actions/community.js | 10 +- client/coral-admin/src/actions/moderation.js | 10 -- .../src/actions/suspendUserDialog.js | 7 + .../components/BanUserDialog.css | 0 .../src/components/BanUserDialog.js | 44 +++++ .../components/SuspendUserDialog.css | 0 .../components/SuspendUserDialog.js | 6 +- .../src/constants/banUserDialog.js | 2 + client/coral-admin/src/constants/community.js | 4 +- .../coral-admin/src/constants/moderation.js | 4 - .../src/constants/suspendUserDialog.js | 2 + .../src/containers/BanUserDialog.js | 63 +++++++ client/coral-admin/src/containers/Layout.js | 8 +- .../src/containers/SuspendUserDialog.js | 83 +++++++++ .../coral-admin/src/reducers/banUserDialog.js | 30 ++++ client/coral-admin/src/reducers/community.js | 14 +- client/coral-admin/src/reducers/index.js | 4 + client/coral-admin/src/reducers/moderation.js | 40 +---- .../src/reducers/suspendUserDialog.js | 30 ++++ .../Community/components/ActionButton.js | 7 +- .../Community/components/BanUserButton.css | 11 -- .../Community/components/BanUserButton.js | 24 --- .../Community/components/BanUserDialog.css | 164 ------------------ .../Community/components/BanUserDialog.js | 51 ------ .../routes/Community/components/Community.js | 18 +- .../Community/components/FlaggedAccounts.js | 4 +- ...serDialog.css => RejectUsernameDialog.css} | 0 ...dUserDialog.js => RejectUsernameDialog.js} | 34 ++-- .../src/routes/Community/components/User.js | 38 ++-- .../routes/Community/containers/Community.js | 13 +- .../Moderation/components/BanUserDialog.js | 52 ------ .../routes/Moderation/components/Comment.js | 18 +- .../Moderation/components/Moderation.js | 20 --- .../Moderation/containers/Moderation.js | 48 +---- client/coral-framework/hocs/withMutation.js | 2 +- client/coral-framework/hocs/withQuery.js | 2 +- graph/typeDefs.graphql | 2 +- locales/en.yml | 54 +++--- locales/es.yml | 54 +++--- 40 files changed, 430 insertions(+), 554 deletions(-) create mode 100644 client/coral-admin/src/actions/banUserDialog.js create mode 100644 client/coral-admin/src/actions/suspendUserDialog.js rename client/coral-admin/src/{routes/Moderation => }/components/BanUserDialog.css (100%) create mode 100644 client/coral-admin/src/components/BanUserDialog.js rename client/coral-admin/src/{routes/Moderation => }/components/SuspendUserDialog.css (100%) rename client/coral-admin/src/{routes/Moderation => }/components/SuspendUserDialog.js (98%) create mode 100644 client/coral-admin/src/constants/banUserDialog.js create mode 100644 client/coral-admin/src/constants/suspendUserDialog.js create mode 100644 client/coral-admin/src/containers/BanUserDialog.js create mode 100644 client/coral-admin/src/containers/SuspendUserDialog.js create mode 100644 client/coral-admin/src/reducers/banUserDialog.js create mode 100644 client/coral-admin/src/reducers/suspendUserDialog.js delete mode 100644 client/coral-admin/src/routes/Community/components/BanUserButton.css delete mode 100644 client/coral-admin/src/routes/Community/components/BanUserButton.js delete mode 100644 client/coral-admin/src/routes/Community/components/BanUserDialog.css delete mode 100644 client/coral-admin/src/routes/Community/components/BanUserDialog.js rename client/coral-admin/src/routes/Community/components/{SuspendUserDialog.css => RejectUsernameDialog.css} (100%) rename client/coral-admin/src/routes/Community/components/{SuspendUserDialog.js => RejectUsernameDialog.js} (71%) delete mode 100644 client/coral-admin/src/routes/Moderation/components/BanUserDialog.js diff --git a/client/coral-admin/src/actions/banUserDialog.js b/client/coral-admin/src/actions/banUserDialog.js new file mode 100644 index 000000000..8b068051c --- /dev/null +++ b/client/coral-admin/src/actions/banUserDialog.js @@ -0,0 +1,7 @@ +import {SHOW_BAN_USER_DIALOG, HIDE_BAN_USER_DIALOG} from '../constants/banUserDialog'; + +export const showBanUserDialog = ({userId, username, commentId, commentStatus}) => + ({type: SHOW_BAN_USER_DIALOG, userId, username, commentId, commentStatus}); + +export const hideBanUserDialog = () => ({type: HIDE_BAN_USER_DIALOG}); + diff --git a/client/coral-admin/src/actions/community.js b/client/coral-admin/src/actions/community.js index ddae062a4..70c9b7592 100644 --- a/client/coral-admin/src/actions/community.js +++ b/client/coral-admin/src/actions/community.js @@ -10,8 +10,8 @@ import { SET_COMMENTER_STATUS, SHOW_BANUSER_DIALOG, HIDE_BANUSER_DIALOG, - SHOW_SUSPENDUSER_DIALOG, - HIDE_SUSPENDUSER_DIALOG + SHOW_REJECT_USERNAME_DIALOG, + HIDE_REJECT_USERNAME_DIALOG } from '../constants/community'; import coralApi from '../../../coral-framework/helpers/request'; @@ -69,6 +69,6 @@ export const setCommenterStatus = (id, status) => (dispatch) => { export const showBanUserDialog = (user) => ({type: SHOW_BANUSER_DIALOG, user}); export const hideBanUserDialog = () => ({type: HIDE_BANUSER_DIALOG}); -// Suspend User Dialog -export const showSuspendUserDialog = (user) => ({type: SHOW_SUSPENDUSER_DIALOG, user}); -export const hideSuspendUserDialog = () => ({type: HIDE_SUSPENDUSER_DIALOG}); +// Reject Username Dialog +export const showRejectUsernameDialog = (user) => ({type: SHOW_REJECT_USERNAME_DIALOG, user}); +export const hideRejectUsernameDialog = () => ({type: HIDE_REJECT_USERNAME_DIALOG}); diff --git a/client/coral-admin/src/actions/moderation.js b/client/coral-admin/src/actions/moderation.js index 08dadd8ee..1c803d87d 100644 --- a/client/coral-admin/src/actions/moderation.js +++ b/client/coral-admin/src/actions/moderation.js @@ -3,16 +3,6 @@ import * as actions from 'constants/moderation'; export const toggleModal = (open) => ({type: actions.TOGGLE_MODAL, open}); export const singleView = () => ({type: actions.SINGLE_VIEW}); -// Ban User Dialog -export const showBanUserDialog = (user, commentId, commentStatus, showRejectedNote) => ({type: actions.SHOW_BANUSER_DIALOG, user, commentId, commentStatus, showRejectedNote}); -export const hideBanUserDialog = () => ({type: actions.HIDE_BANUSER_DIALOG}); - -// Suspend User Dialog -export const showSuspendUserDialog = (userId, username, commentId, commentStatus) => - ({type: actions.SHOW_SUSPEND_USER_DIALOG, userId, username, commentId, commentStatus}); - -export const hideSuspendUserDialog = () => ({type: actions.HIDE_SUSPEND_USER_DIALOG}); - // hide shortcuts note export const hideShortcutsNote = () => { try { diff --git a/client/coral-admin/src/actions/suspendUserDialog.js b/client/coral-admin/src/actions/suspendUserDialog.js new file mode 100644 index 000000000..06913147d --- /dev/null +++ b/client/coral-admin/src/actions/suspendUserDialog.js @@ -0,0 +1,7 @@ +import {SHOW_SUSPEND_USER_DIALOG, HIDE_SUSPEND_USER_DIALOG} from '../constants/suspendUserDialog.js'; + +export const showSuspendUserDialog = ({userId, username, commentId, commentStatus}) => + ({type: SHOW_SUSPEND_USER_DIALOG, userId, username, commentId, commentStatus}); + +export const hideSuspendUserDialog = () => ({type: HIDE_SUSPEND_USER_DIALOG}); + diff --git a/client/coral-admin/src/routes/Moderation/components/BanUserDialog.css b/client/coral-admin/src/components/BanUserDialog.css similarity index 100% rename from client/coral-admin/src/routes/Moderation/components/BanUserDialog.css rename to client/coral-admin/src/components/BanUserDialog.css diff --git a/client/coral-admin/src/components/BanUserDialog.js b/client/coral-admin/src/components/BanUserDialog.js new file mode 100644 index 000000000..bade3578d --- /dev/null +++ b/client/coral-admin/src/components/BanUserDialog.js @@ -0,0 +1,44 @@ +import React, {PropTypes} from 'react'; +import {Dialog} from 'coral-ui'; +import styles from './BanUserDialog.css'; + +import Button from 'coral-ui/components/Button'; +import t from 'coral-framework/services/i18n'; + +const BanUserDialog = ({open, onCancel, onPerform, username, info}) => ( + + × +
    +
    +

    {t('bandialog.ban_user')}

    +
    +
    +

    {t('bandialog.are_you_sure', username)}

    + {info} +
    +
    + + +
    +
    +
    +); + +BanUserDialog.propTypes = { + open: PropTypes.bool, + onPerform: PropTypes.func.isRequired, + onCancel: PropTypes.func.isRequired, + username: PropTypes.string, + info: PropTypes.string, +}; + +export default BanUserDialog; diff --git a/client/coral-admin/src/routes/Moderation/components/SuspendUserDialog.css b/client/coral-admin/src/components/SuspendUserDialog.css similarity index 100% rename from client/coral-admin/src/routes/Moderation/components/SuspendUserDialog.css rename to client/coral-admin/src/components/SuspendUserDialog.css diff --git a/client/coral-admin/src/routes/Moderation/components/SuspendUserDialog.js b/client/coral-admin/src/components/SuspendUserDialog.js similarity index 98% rename from client/coral-admin/src/routes/Moderation/components/SuspendUserDialog.js rename to client/coral-admin/src/components/SuspendUserDialog.js index 212757f20..d2ef23891 100644 --- a/client/coral-admin/src/routes/Moderation/components/SuspendUserDialog.js +++ b/client/coral-admin/src/components/SuspendUserDialog.js @@ -49,7 +49,6 @@ class SuspendUserDialog extends React.Component { handlePerform = () => { this.props.onPerform({ - id: this.props.userId, message: this.state.message, // Add 1 minute more to help `timeago.js` to display the correct duration. @@ -153,11 +152,10 @@ class SuspendUserDialog extends React.Component { SuspendUserDialog.propTypes = { open: PropTypes.bool.isRequired, - onCancel: PropTypes.func.isRequired, onPerform: PropTypes.func.isRequired, - username: PropTypes.string, - userId: PropTypes.string, + onCancel: PropTypes.func.isRequired, organizationName: PropTypes.string, + username: PropTypes.string, }; export default SuspendUserDialog; diff --git a/client/coral-admin/src/constants/banUserDialog.js b/client/coral-admin/src/constants/banUserDialog.js new file mode 100644 index 000000000..90a7031b3 --- /dev/null +++ b/client/coral-admin/src/constants/banUserDialog.js @@ -0,0 +1,2 @@ +export const SHOW_BAN_USER_DIALOG = 'SHOW_BAN_USER_DIALOG'; +export const HIDE_BAN_USER_DIALOG = 'HIDE_BAN_USER_DIALOG'; diff --git a/client/coral-admin/src/constants/community.js b/client/coral-admin/src/constants/community.js index a46e721a6..be11e9b0c 100644 --- a/client/coral-admin/src/constants/community.js +++ b/client/coral-admin/src/constants/community.js @@ -13,5 +13,5 @@ export const FETCH_FLAGGED_COMMENTERS_FAILURE = 'FETCH_FLAGGED_COMMENTERS_FAILUR export const SHOW_BANUSER_DIALOG = 'SHOW_BANUSER_DIALOG'; export const HIDE_BANUSER_DIALOG = 'HIDE_BANUSER_DIALOG'; -export const SHOW_SUSPENDUSER_DIALOG = 'SHOW_SUSPENDUSER_DIALOG'; -export const HIDE_SUSPENDUSER_DIALOG = 'HIDE_SUSPENDUSER_DIALOG'; +export const SHOW_REJECT_USERNAME_DIALOG = 'SHOW_REJECT_USERNAME_DIALOG'; +export const HIDE_REJECT_USERNAME_DIALOG = 'HIDE_REJECT_USERNAME_DIALOG'; diff --git a/client/coral-admin/src/constants/moderation.js b/client/coral-admin/src/constants/moderation.js index 6fefcccfb..2c3fc08db 100644 --- a/client/coral-admin/src/constants/moderation.js +++ b/client/coral-admin/src/constants/moderation.js @@ -1,10 +1,6 @@ export const TOGGLE_MODAL = 'TOGGLE_MODAL'; export const SINGLE_VIEW = 'SINGLE_VIEW'; -export const SHOW_BANUSER_DIALOG = 'SHOW_BANUSER_DIALOG'; -export const HIDE_BANUSER_DIALOG = 'HIDE_BANUSER_DIALOG'; export const HIDE_SHORTCUTS_NOTE = 'HIDE_SHORTCUTS_NOTE'; -export const SHOW_SUSPEND_USER_DIALOG = 'SHOW_SUSPEND_USER_DIALOG'; -export const HIDE_SUSPEND_USER_DIALOG = 'HIDE_SUSPEND_USER_DIALOG'; export const VIEW_USER_DETAIL = 'VIEW_USER_DETAIL'; export const HIDE_USER_DETAIL = 'HIDE_USER_DETAIL'; export const SET_SORT_ORDER = 'MODERATION_SET_SORT_ORDER'; diff --git a/client/coral-admin/src/constants/suspendUserDialog.js b/client/coral-admin/src/constants/suspendUserDialog.js new file mode 100644 index 000000000..13673dfe5 --- /dev/null +++ b/client/coral-admin/src/constants/suspendUserDialog.js @@ -0,0 +1,2 @@ +export const SHOW_SUSPEND_USER_DIALOG = 'SHOW_SUSPEND_USER_DIALOG'; +export const HIDE_SUSPEND_USER_DIALOG = 'HIDE_SUSPEND_USER_DIALOG'; diff --git a/client/coral-admin/src/containers/BanUserDialog.js b/client/coral-admin/src/containers/BanUserDialog.js new file mode 100644 index 000000000..2c72b3380 --- /dev/null +++ b/client/coral-admin/src/containers/BanUserDialog.js @@ -0,0 +1,63 @@ +import React, {Component} from 'react'; +import {connect} from 'react-redux'; +import {bindActionCreators} from 'redux'; +import BanUserDialog from '../components/BanUserDialog'; +import {hideBanUserDialog} from '../actions/banUserDialog'; +import {withSetUserStatus, withSetCommentStatus} from 'coral-framework/graphql/mutations'; +import {compose} from 'react-apollo'; +import t from 'coral-framework/services/i18n'; + +class BanUserDialogContainer extends Component { + + banUser = async () => { + const {userId, commentId, commentStatus, setUserStatus, setCommentStatus, hideBanUserDialog} = this.props; + await setUserStatus({userId, status: 'BANNED'}); + hideBanUserDialog(); + if (commentId && commentStatus && commentStatus !== 'REJECTED') { + await setCommentStatus({commentId, status: 'REJECTED'}); + } + } + + getInfo() { + let note = t('bandialog.note_ban_user'); + if (this.props.commentStatus && this.props.commentStatus !== 'REJECTED') { + note = t('bandialog.note_reject_comment'); + } + return t('bandialog.note', note); + } + + render() { + return ( + + ); + } +} + +const mapStateToProps = ({banUserDialog: {open, userId, username, commentId, commentStatus}}) => ({ + open, + userId, + username, + commentId, + commentStatus, +}); + +const mapDispatchToProps = (dispatch) => ({ + ...bindActionCreators({ + hideBanUserDialog, + }, dispatch), +}); + +export default compose( + withSetUserStatus, + withSetCommentStatus, + connect( + mapStateToProps, + mapDispatchToProps, + ), +)(BanUserDialogContainer); diff --git a/client/coral-admin/src/containers/Layout.js b/client/coral-admin/src/containers/Layout.js index 340a18e3b..dacf768c0 100644 --- a/client/coral-admin/src/containers/Layout.js +++ b/client/coral-admin/src/containers/Layout.js @@ -5,6 +5,8 @@ import {fetchConfig} from '../actions/config'; import AdminLogin from '../components/AdminLogin'; import {logout} from 'coral-framework/actions/auth'; import {FullLoading} from '../components/FullLoading'; +import BanUserDialog from './BanUserDialog'; +import SuspendUserDialog from './SuspendUserDialog'; import {toggleModal as toggleShortcutModal} from '../actions/moderation'; import {checkLogin, handleLogin, requestPasswordReset} from '../actions/auth'; import {can} from 'coral-framework/services/perms'; @@ -52,7 +54,11 @@ class LayoutContainer extends Component { handleLogout={handleLogout} toggleShortcutModal={toggleShortcutModal} {...this.props} - /> + > + + + {this.props.children} + ); } else if (loggedIn) { return ( diff --git a/client/coral-admin/src/containers/SuspendUserDialog.js b/client/coral-admin/src/containers/SuspendUserDialog.js new file mode 100644 index 000000000..bd95328a3 --- /dev/null +++ b/client/coral-admin/src/containers/SuspendUserDialog.js @@ -0,0 +1,83 @@ +import React, {Component} from 'react'; +import {connect} from 'react-redux'; +import {bindActionCreators} from 'redux'; +import SuspendUserDialog from '../components/SuspendUserDialog'; +import {hideSuspendUserDialog} from '../actions/suspendUserDialog'; +import {withSetCommentStatus, withSuspendUser} from 'coral-framework/graphql/mutations'; +import {compose, gql} from 'react-apollo'; +import * as notification from 'coral-admin/src/services/notification'; +import t, {timeago} from 'coral-framework/services/i18n'; +import withQuery from 'coral-framework/hocs/withQuery'; +import get from 'lodash/get'; + +class SuspendUserDialogContainer extends Component { + + suspendUser = async ({message, until}) => { + const {userId, username, commentStatus, commentId, hideSuspendUserDialog, setCommentStatus, suspendUser} = this.props; + hideSuspendUserDialog(); + try { + const result = await suspendUser({id: userId, message, until}); + if (result.data.suspendUser.errors) { + throw result.data.suspendUser.errors; + } + notification.success( + t('suspenduser.notify_suspend_until', username, timeago(until)), + ); + if (commentId && commentStatus && commentStatus !== 'REJECTED') { + return setCommentStatus({commentId, status: 'REJECTED'}) + .then((result) => { + if (result.data.setCommentStatus.errors) { + throw result.data.setCommentStatus.errors; + } + }); + } + } + catch(err) { + notification.showMutationErrors(err); + } + }; + + render() { + return ( + + ); + } +} + +const withOrganizationName = withQuery(gql` + query CoralAdmin_SuspendUserDialog { + settings { + organizationName + } + } +`); + +const mapStateToProps = ({suspendUserDialog: {open, userId, username, commentId, commentStatus}}) => ({ + open, + userId, + username, + commentId, + commentStatus, +}); + +const mapDispatchToProps = (dispatch) => ({ + ...bindActionCreators({ + hideSuspendUserDialog, + }, dispatch), +}); + +export default compose( + connect( + mapStateToProps, + mapDispatchToProps, + ), + withSuspendUser, + withSetCommentStatus, + withOrganizationName, +)(SuspendUserDialogContainer); diff --git a/client/coral-admin/src/reducers/banUserDialog.js b/client/coral-admin/src/reducers/banUserDialog.js new file mode 100644 index 000000000..1d66339ec --- /dev/null +++ b/client/coral-admin/src/reducers/banUserDialog.js @@ -0,0 +1,30 @@ +import {SHOW_BAN_USER_DIALOG, HIDE_BAN_USER_DIALOG} from '../constants/banUserDialog'; + +const initialState = { + open: false, + userId: null, + username: '', + commentId: null, + commentStatus: '', +}; + +export default function banUserDialog(state = initialState, action) { + switch (action.type) { + case SHOW_BAN_USER_DIALOG: + return { + ...state, + open: true, + userId: action.userId, + username: action.username, + commentId: action.commentId, + commentStatus: action.commentStatus, + }; + case HIDE_BAN_USER_DIALOG: + return { + ...state, + open: false, + }; + default: + return state; + } +} diff --git a/client/coral-admin/src/reducers/community.js b/client/coral-admin/src/reducers/community.js index 7127c6fbe..3fba504f8 100644 --- a/client/coral-admin/src/reducers/community.js +++ b/client/coral-admin/src/reducers/community.js @@ -9,8 +9,8 @@ import { SET_COMMENTER_STATUS, SHOW_BANUSER_DIALOG, HIDE_BANUSER_DIALOG, - SHOW_SUSPENDUSER_DIALOG, - HIDE_SUSPENDUSER_DIALOG + SHOW_REJECT_USERNAME_DIALOG, + HIDE_REJECT_USERNAME_DIALOG } from '../constants/community'; const initialState = Map({ @@ -24,7 +24,7 @@ const initialState = Map({ pagePeople: 0, user: Map({}), banDialog: false, - suspendDialog: false + rejectUsernameDialog: false }); export default function community (state = initialState, action) { @@ -79,14 +79,14 @@ export default function community (state = initialState, action) { user: Map(action.user), banDialog: true }); - case HIDE_SUSPENDUSER_DIALOG: + case HIDE_REJECT_USERNAME_DIALOG: return state - .set('suspendDialog', false); - case SHOW_SUSPENDUSER_DIALOG: + .set('rejectUsernameDialog', false); + case SHOW_REJECT_USERNAME_DIALOG: return state .merge({ user: Map(action.user), - suspendDialog: true + rejectUsernameDialog: true }); default : return state; diff --git a/client/coral-admin/src/reducers/index.js b/client/coral-admin/src/reducers/index.js index 04c8b6590..f94b50817 100644 --- a/client/coral-admin/src/reducers/index.js +++ b/client/coral-admin/src/reducers/index.js @@ -5,9 +5,13 @@ import community from './community'; import moderation from './moderation'; import install from './install'; import config from './config'; +import banUserDialog from './banUserDialog'; +import suspendUserDialog from './suspendUserDialog'; export default { auth, + banUserDialog, + suspendUserDialog, assets, settings, community, diff --git a/client/coral-admin/src/reducers/moderation.js b/client/coral-admin/src/reducers/moderation.js index fd6f7c0ea..a2c8975ff 100644 --- a/client/coral-admin/src/reducers/moderation.js +++ b/client/coral-admin/src/reducers/moderation.js @@ -1,61 +1,23 @@ -import {fromJS, Map, Set} from 'immutable'; +import {fromJS, Set} from 'immutable'; import * as actions from '../constants/moderation'; const initialState = fromJS({ singleView: false, modalOpen: false, - user: {}, - commentId: null, - commentStatus: null, userDetailId: null, userDetailActiveTab: 'all', userDetailStatuses: ['NONE', 'ACCEPTED', 'REJECTED', 'PREMOD'], userDetailSelectedIds: new Set(), - banDialog: false, storySearchVisible: false, storySearchString: '', shortcutsNoteVisible: window.localStorage.getItem('coral:shortcutsNote') || 'show', sortOrder: 'REVERSE_CHRONOLOGICAL', - suspendUserDialog: { - show: false, - userId: null, - username: '', - commentId: null, - commentStatus: '', - }, }); export default function moderation (state = initialState, action) { switch (action.type) { case actions.MODERATION_CLEAR_STATE: return initialState; - case actions.HIDE_BANUSER_DIALOG: - return state - .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 - }); - case actions.SHOW_SUSPEND_USER_DIALOG: - return state - .mergeDeep({ - suspendUserDialog: { - show: true, - userId: action.userId, - username: action.username, - commentId: action.commentId, - commentStatus: action.commentStatus, - } - }); - case actions.HIDE_SUSPEND_USER_DIALOG: - return state - .setIn(['suspendUserDialog', 'show'], false); case actions.SET_ACTIVE_TAB: return state .set('activeTab', action.activeTab); diff --git a/client/coral-admin/src/reducers/suspendUserDialog.js b/client/coral-admin/src/reducers/suspendUserDialog.js new file mode 100644 index 000000000..733dd337b --- /dev/null +++ b/client/coral-admin/src/reducers/suspendUserDialog.js @@ -0,0 +1,30 @@ +import {SHOW_SUSPEND_USER_DIALOG, HIDE_SUSPEND_USER_DIALOG} from '../constants/suspendUserDialog'; + +const initialState = { + open: false, + userId: null, + username: '', + commentId: null, + commentStatus: '', +}; + +export default function suspendUserDialog(state = initialState, action) { + switch (action.type) { + case SHOW_SUSPEND_USER_DIALOG: + return { + ...state, + open: true, + userId: action.userId, + username: action.username, + commentId: action.commentId, + commentStatus: action.commentStatus, + }; + case HIDE_SUSPEND_USER_DIALOG: + return { + ...state, + open: false, + }; + default: + return state; + } +} diff --git a/client/coral-admin/src/routes/Community/components/ActionButton.js b/client/coral-admin/src/routes/Community/components/ActionButton.js index 67f16acad..b0b68b063 100644 --- a/client/coral-admin/src/routes/Community/components/ActionButton.js +++ b/client/coral-admin/src/routes/Community/components/ActionButton.js @@ -1,23 +1,18 @@ import React from 'react'; import styles from './Community.css'; -import BanUserButton from './BanUserButton'; import {Button} from 'coral-ui'; import {menuActionsMap} from '../../Moderation/helpers/moderationQueueActionsMap'; import t from 'coral-framework/services/i18n'; const ActionButton = ({type = '', user, ...props}) => { - if (type === 'BAN') { - return props.showBanUserDialog(user)} />; - } - return ( ); diff --git a/client/coral-admin/src/routes/Community/components/BanUserButton.css b/client/coral-admin/src/routes/Community/components/BanUserButton.css deleted file mode 100644 index 6e8e50f71..000000000 --- a/client/coral-admin/src/routes/Community/components/BanUserButton.css +++ /dev/null @@ -1,11 +0,0 @@ -.banButton { - -webkit-transform: scale(.8); - transform: scale(.8); - margin: 0; - - i { - vertical-align: middle; - margin-right: 5px; - font-size: 14px; - } -} diff --git a/client/coral-admin/src/routes/Community/components/BanUserButton.js b/client/coral-admin/src/routes/Community/components/BanUserButton.js deleted file mode 100644 index cc4935204..000000000 --- a/client/coral-admin/src/routes/Community/components/BanUserButton.js +++ /dev/null @@ -1,24 +0,0 @@ -import React, {PropTypes} from 'react'; -import {Button, Icon} from 'coral-ui'; -import styles from './BanUserButton.css'; - -import t from 'coral-framework/services/i18n'; - -const BanUserButton = ({user, ...props}) => ( -
    - -
    -); - -BanUserButton.propTypes = { - onClick: PropTypes.func.isRequired -}; - -export default BanUserButton; diff --git a/client/coral-admin/src/routes/Community/components/BanUserDialog.css b/client/coral-admin/src/routes/Community/components/BanUserDialog.css deleted file mode 100644 index a46b9da32..000000000 --- a/client/coral-admin/src/routes/Community/components/BanUserDialog.css +++ /dev/null @@ -1,164 +0,0 @@ -.dialog { - border: none; - box-shadow: 0 9px 46px 8px rgba(0, 0, 0, 0.14), 0 11px 15px -7px rgba(0, 0, 0, 0.12), 0 24px 38px 3px rgba(0, 0, 0, 0.2); - width: 500px; - top: 50%; - transform: translateY(-50%); - height: 184px; - padding: 20px; - - h2 { - color: black; - font-size: 1.76em; - font-weight: 500; - margin: 0; - } - - h3 { - color: black; - font-size: 1.4em; - font-weight: 500; - margin: 0; - } -} - -.textField { - margin-top: 15px; -} - -.textField label { - font-size: 1.08em; - font-weight: bold; - margin-bottom: 5px; -} - -.textField input { - width: 100%; - display: block; - border: none; - outline: none; - border: 1px solid rgba(0,0,0,.12); - padding: 10px 6px; - box-sizing: border-box; - border-radius: 2px; - margin: 5px auto; -} - -.footer { - margin: 20px auto 10px; - text-align: center; -} - -.footer span { - display: block; - margin-bottom: 5px; -} - -.footer a { - color: #2c69b6; - cursor: pointer; - margin: 0 5px; -} - -.socialConnections { - margin-bottom: 20px; -} - -.signInButton { - margin-top: 10px; -} - -.close { - font-size: 20px; - line-height: 14px; - top: 10px; - right: 10px; - position: absolute; - display: block; - font-weight: bold; - color: #363636; - cursor: pointer; -} - -.close:hover { - color: #6b6b6b; -} - -input.error{ - border: solid 2px #f44336; -} - -.errorMsg, .hint { - color: grey; - font-weight: 600; - padding: 3px 0 16px; -} - -.alert { - padding: 10px; - margin-bottom: 20px; - border-radius: 2px; -} - -.alert--success { - border: solid 1px #1ec00e; - background: #cbf1b8; - color: #006900; -} - -.alert--error { - background: #FFEBEE; - color: #B71C1C; -} - -.userBox a { - color: #2c69b6; - cursor: pointer; - margin: 0px; -} - -.attention { - display: inline-block; - width: 15px; - height: 15px; - background: #B71C1C; - color: #FFEBEE; - font-weight: bolder; - padding: 4px; - vertical-align: middle; - border-radius: 20px; - box-sizing: border-box; - font-size: 9px; - line-height: 7px; - text-align: center; - margin-right: 5px; -} - -.action { - margin-top: 15px; -} - -.passwordRequestSuccess { - border: 1px solid green; - background-color: lightgreen; - padding: 10px; -} - -.passwordRequestFailure { - border: 1px solid orange; - background-color: 1px solid coral; - padding: 10px; -} - -.cancel { - margin-right: 10px; - width: 47%; -} - -.ban { - width: 47%; -} - -.buttons { - margin: 20px 0; -} diff --git a/client/coral-admin/src/routes/Community/components/BanUserDialog.js b/client/coral-admin/src/routes/Community/components/BanUserDialog.js deleted file mode 100644 index 26a885e8b..000000000 --- a/client/coral-admin/src/routes/Community/components/BanUserDialog.js +++ /dev/null @@ -1,51 +0,0 @@ -import React, {PropTypes} from 'react'; -import {Dialog} from 'coral-ui'; -import styles from './BanUserDialog.css'; - -import Button from 'coral-ui/components/Button'; - -import t from 'coral-framework/services/i18n'; - -const BanUserDialog = ({open, handleClose, handleBanUser, user}) => ( - - × -
    -
    -

    {t('community.ban_user')}

    -
    -
    -

    {t('community.are_you_sure', user.username)}

    - {t('community.note')} -
    -
    - - -
    -
    -
    -); - -BanUserDialog.propTypes = { - handleBanUser: PropTypes.func.isRequired, - handleClose: PropTypes.func.isRequired, - user: PropTypes.object.isRequired, -}; - -export default BanUserDialog; diff --git a/client/coral-admin/src/routes/Community/components/Community.js b/client/coral-admin/src/routes/Community/components/Community.js index f6544b0ac..fe7478efb 100644 --- a/client/coral-admin/src/routes/Community/components/Community.js +++ b/client/coral-admin/src/routes/Community/components/Community.js @@ -1,10 +1,9 @@ import React, {Component} from 'react'; import CommunityMenu from './CommunityMenu'; -import BanUserDialog from './BanUserDialog'; -import SuspendUserDialog from './SuspendUserDialog'; import People from './People'; import FlaggedAccounts from './FlaggedAccounts'; +import RejectUsernameDialog from './RejectUsernameDialog'; export default class Community extends Component { @@ -80,19 +79,14 @@ export default class Community extends Component { - - diff --git a/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js b/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js index df6368844..dc2003850 100644 --- a/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js +++ b/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js @@ -9,8 +9,6 @@ const FlaggedAccounts = ({...props}) => { const {commenters} = props; const hasResults = commenters && !!commenters.length; -// if (commenter.status === 'PENDING' && commenter.actions.length > 0) { - return (
    @@ -24,8 +22,8 @@ const FlaggedAccounts = ({...props}) => { modActionButtons={['APPROVE', 'REJECT']} showBanUserDialog={props.showBanUserDialog} showSuspendUserDialog={props.showSuspendUserDialog} + showRejectUsernameDialog={props.showRejectUsernameDialog} approveUser={props.approveUser} - suspendUser={props.suspendUser} />; }) : {t('community.no_flagged_accounts')} diff --git a/client/coral-admin/src/routes/Community/components/SuspendUserDialog.css b/client/coral-admin/src/routes/Community/components/RejectUsernameDialog.css similarity index 100% rename from client/coral-admin/src/routes/Community/components/SuspendUserDialog.css rename to client/coral-admin/src/routes/Community/components/RejectUsernameDialog.css diff --git a/client/coral-admin/src/routes/Community/components/SuspendUserDialog.js b/client/coral-admin/src/routes/Community/components/RejectUsernameDialog.js similarity index 71% rename from client/coral-admin/src/routes/Community/components/SuspendUserDialog.js rename to client/coral-admin/src/routes/Community/components/RejectUsernameDialog.js index 0db31ccc1..9ae039ac5 100644 --- a/client/coral-admin/src/routes/Community/components/SuspendUserDialog.js +++ b/client/coral-admin/src/routes/Community/components/RejectUsernameDialog.js @@ -1,30 +1,30 @@ import React, {Component, PropTypes} from 'react'; import {Dialog, Button} from 'coral-ui'; -import styles from './SuspendUserDialog.css'; +import styles from './RejectUsernameDialog.css'; import t from 'coral-framework/services/i18n'; const stages = [ { - title: 'suspenduser.title_reject', - description: 'suspenduser.description_reject', + title: 'rejectUsername.title_reject', + description: 'rejectUsername.description_reject', options: { - 'j': 'suspenduser.no_cancel', - 'k': 'suspenduser.yes_suspend' + 'j': 'rejectUsername.no_cancel', + 'k': 'rejectUsername.yes_suspend' } }, { - title: 'suspenduser.title_notify', - description: 'suspenduser.description_notify', + title: 'rejectUsername.title_notify', + description: 'rejectUsername.description_notify', options: { 'j': 'bandialog.cancel', - 'k': 'suspenduser.send' + 'k': 'rejectUsername.send' } } ]; -class SuspendUserDialog extends Component { +class RejectUsernameDialog extends Component { state = {email: '', stage: 0} @@ -35,7 +35,7 @@ class SuspendUserDialog extends Component { } componentDidMount() { - this.setState({email: t('suspenduser.email_message_reject'), about: t('suspenduser.username')}); + this.setState({email: t('rejectUsername.email_message_reject'), about: t('rejectUsername.username')}); } /* @@ -72,22 +72,22 @@ class SuspendUserDialog extends Component { return + title={t('rejectUsername.suspend_user')}>
    - {t(stages[stage].title, t('suspenduser.username'))} + {t(stages[stage].title, t('rejectUsername.username'))}
    - {t(stages[stage].description, t('suspenduser.username'))} + {t(stages[stage].description, t('rejectUsername.username'))}
    { stage === 1 &&
    -
    {t('suspenduser.write_message')}
    +
    {t('rejectUsername.write_message')}