diff --git a/bin/cli-settings b/bin/cli-settings
index 7854942c0..ba4305ce3 100755
--- a/bin/cli-settings
+++ b/bin/cli-settings
@@ -23,7 +23,7 @@ program
.description('initilizes the talk settings')
.action(() => {
const defaults = {
- moderation: 'PRE',
+ moderation: 'POST',
wordlist: {
banned: [],
suspect: []
diff --git a/client/coral-admin/src/actions/auth.js b/client/coral-admin/src/actions/auth.js
index c3f9b1be1..8bc0d4e4c 100644
--- a/client/coral-admin/src/actions/auth.js
+++ b/client/coral-admin/src/actions/auth.js
@@ -14,7 +14,10 @@ export const checkLogin = () => dispatch => {
const isAdmin = !!result.user.roles.filter(i => i === 'ADMIN').length;
dispatch(checkLoginSuccess(result.user, isAdmin));
})
- .catch(error => dispatch(checkLoginFailure(error)));
+ .catch(error => {
+ console.error(error);
+ dispatch(checkLoginFailure(`${error.message}`));
+ });
};
// LogOut Actions
diff --git a/client/coral-admin/src/actions/comments.js b/client/coral-admin/src/actions/comments.js
index fe4895ed3..df68b72c4 100644
--- a/client/coral-admin/src/actions/comments.js
+++ b/client/coral-admin/src/actions/comments.js
@@ -15,17 +15,18 @@ export const fetchModerationQueueComments = () => {
return Promise.all([
coralApi('/queue/comments/pending'),
+ coralApi('/queue/users/pending'),
coralApi('/queue/comments/rejected'),
coralApi('/queue/comments/flagged')
])
- .then(([pending, rejected, flagged]) => {
+ .then(([pendingComments, pendingUsers, rejected, flagged]) => {
/* Combine seperate calls into a single object */
flagged.comments.forEach(comment => comment.flagged = true);
return {
- comments: [...pending.comments, ...rejected.comments, ...flagged.comments],
- users: [...pending.users, ...rejected.users, ...flagged.users],
- actions: [...pending.actions, ...rejected.actions, ...flagged.actions]
+ comments: [...pendingComments.comments, ...rejected.comments, ...flagged.comments],
+ users: [...pendingComments.users, ...pendingUsers.users, ...rejected.users, ...flagged.users],
+ actions: [...pendingComments.actions, ...pendingUsers.actions, ...rejected.actions, ...flagged.actions]
};
})
.then(addUsersCommentsActions.bind(this, dispatch));
@@ -41,6 +42,15 @@ export const fetchPendingQueue = () => {
};
};
+export const fetchPendingUsersQueue = () => {
+ return dispatch => {
+ dispatch({type: commentTypes.COMMENTS_MODERATION_QUEUE_FETCH_REQUEST});
+
+ return coralApi('/queue/users/pending')
+ .then(addUsersCommentsActions.bind(this, dispatch));
+ };
+};
+
export const fetchRejectedQueue = () => {
return dispatch => {
dispatch({type: commentTypes.COMMENTS_MODERATION_QUEUE_FETCH_REQUEST});
diff --git a/client/coral-admin/src/actions/users.js b/client/coral-admin/src/actions/users.js
index 30d9cd34b..44f0325d9 100644
--- a/client/coral-admin/src/actions/users.js
+++ b/client/coral-admin/src/actions/users.js
@@ -1,5 +1,5 @@
import coralApi from '../../../coral-framework/helpers/response';
-import * as actions from '../constants/user';
+import * as userTypes from '../constants/users';
/**
* Action disptacher related to users
@@ -7,9 +7,17 @@ import * as actions from '../constants/user';
// change status of a user
export const userStatusUpdate = (status, userId, commentId) => {
return (dispatch) => {
- dispatch({type: actions.UPDATE_STATUS_REQUEST});
+ dispatch({type: userTypes.UPDATE_STATUS_REQUEST});
return coralApi(`/users/${userId}/status`, {method: 'POST', body: {status: status, comment_id: commentId}})
- .then(res => dispatch({type: actions.UPDATE_STATUS_SUCCESS, res}))
- .catch(error => dispatch({type: actions.UPDATE_STATUS_FAILURE, error}));
+ .then(res => dispatch({type: userTypes.UPDATE_STATUS_SUCCESS, res}))
+ .catch(error => dispatch({type: userTypes.UPDATE_STATUS_FAILURE, error}));
+ };
+};
+
+// change status of a user
+export const sendNotificationEmail = (userId, subject, body) => {
+ return (dispatch) => {
+ return coralApi(`/users/${userId}/email`, {method: 'POST', body: {subject, body}})
+ .catch(error => dispatch({type: userTypes.USER_EMAIL_FAILURE, error}));
};
};
diff --git a/client/coral-admin/src/components/ActionButton.js b/client/coral-admin/src/components/ActionButton.js
new file mode 100644
index 000000000..61de1c669
--- /dev/null
+++ b/client/coral-admin/src/components/ActionButton.js
@@ -0,0 +1,48 @@
+import React from 'react';
+import styles from './ModerationList.css';
+import I18n from 'coral-framework/modules/i18n/i18n';
+import translations from '../translations.json';
+import {FabButton, Button, Icon} from 'coral-ui';
+
+const ActionButton = ({option, type, comment = {}, user, menuOptionsMap, onClickAction, onClickShowBanDialog}) =>
+{
+ const banned = user.status === 'BANNED';
+
+ if (option === 'flag' && (type === 'USERS' || comment.status || comment.flagged === true)) {
+ return null;
+ }
+ if (option === 'ban') {
+ return (
+
+
+
+ );
+ }
+ const menuOption = menuOptionsMap[option];
+ const action = {
+ item_type: type,
+ item_id: type === 'COMMENTS' ? comment.id : user.id
+ };
+ return (
+ onClickAction(menuOption.status, type === 'COMMENTS' ? comment : user, action)}
+ />
+ );
+};
+
+export default ActionButton;
+
+const lang = new I18n(translations);
diff --git a/client/coral-admin/src/components/BanUserDialog.js b/client/coral-admin/src/components/BanUserDialog.js
index c393df21d..0ad149fbe 100644
--- a/client/coral-admin/src/components/BanUserDialog.js
+++ b/client/coral-admin/src/components/BanUserDialog.js
@@ -35,7 +35,7 @@ const BanUserDialog = ({open, handleClose, onClickBanUser, user = {}}) => (
-