diff --git a/client/coral-admin/src/containers/BanUserDialog.js b/client/coral-admin/src/containers/BanUserDialog.js
index 0b2ccc0a7..818a43d7a 100644
--- a/client/coral-admin/src/containers/BanUserDialog.js
+++ b/client/coral-admin/src/containers/BanUserDialog.js
@@ -4,7 +4,7 @@ import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import BanUserDialog from '../components/BanUserDialog';
import {hideBanUserDialog} from '../actions/banUserDialog';
-import {withSetUserBanStatus, withSetCommentStatus} from 'coral-framework/graphql/mutations';
+import {withBanUser, withSetCommentStatus} from 'coral-framework/graphql/mutations';
import {compose} from 'react-apollo';
import t from 'coral-framework/services/i18n';
import {getErrorMessages} from 'coral-framework/utils';
@@ -13,9 +13,9 @@ import {notify} from 'coral-framework/actions/notification';
class BanUserDialogContainer extends Component {
banUser = async () => {
- const {userId, commentId, commentStatus, setUserBanStatus, setCommentStatus, hideBanUserDialog, notify} = this.props;
+ const {userId, commentId, commentStatus, banUser, setCommentStatus, hideBanUserDialog, notify} = this.props;
try {
- await setUserBanStatus({id: userId, status: true});
+ await banUser({id: userId, status: true});
hideBanUserDialog();
if (commentId && commentStatus && commentStatus !== 'REJECTED') {
await setCommentStatus({commentId, status: 'REJECTED'});
@@ -48,7 +48,7 @@ class BanUserDialogContainer extends Component {
}
BanUserDialogContainer.propTypes = {
- setUserBanStatus: PropTypes.func.isRequired,
+ banUser: PropTypes.func.isRequired,
hideBanUserDialog: PropTypes.func,
open: PropTypes.bool,
username: PropTypes.string,
@@ -71,7 +71,7 @@ const mapDispatchToProps = (dispatch) => ({
});
export default compose(
- withSetUserBanStatus,
+ withBanUser,
withSetCommentStatus,
connect(
mapStateToProps,
diff --git a/client/coral-admin/src/routes/Community/components/People.js b/client/coral-admin/src/routes/Community/components/People.js
index 4057eaf67..f46415e13 100644
--- a/client/coral-admin/src/routes/Community/components/People.js
+++ b/client/coral-admin/src/routes/Community/components/People.js
@@ -18,7 +18,8 @@ const People = (props) => {
totalPages,
page,
setRole,
- setUserBanStatus,
+ banUser,
+ unBanUser,
viewUserDetail,
} = props;
@@ -46,7 +47,8 @@ const People = (props) => {
users={users}
setRole={setRole}
viewUserDetail={viewUserDetail}
- setUserBanStatus={setUserBanStatus}
+ banUser={banUser}
+ unBanUser={unBanUser}
onHeaderClickHandler={onHeaderClickHandler}
pageCount={totalPages}
onPageChange={onPageChange}
@@ -67,7 +69,8 @@ People.propTypes = {
onSearchChange: PropTypes.func,
totalPages: PropTypes.number,
onPageChange: PropTypes.func,
- setUserBanStatus: PropTypes.func.isRequired,
+ banUser: PropTypes.func.isRequired,
+ unBanUser: PropTypes.func.isRequired,
setRole: PropTypes.func.isRequired,
viewUserDetail: PropTypes.func.isRequired,
};
diff --git a/client/coral-admin/src/routes/Community/components/Table.js b/client/coral-admin/src/routes/Community/components/Table.js
index bcf7cb10c..9f949cc59 100644
--- a/client/coral-admin/src/routes/Community/components/Table.js
+++ b/client/coral-admin/src/routes/Community/components/Table.js
@@ -24,75 +24,83 @@ const headers = [
}
];
-const getStatus = (status) => {
- return status.banned.status ? 'BANNED' : 'ACTIVE';
-};
+const Table = ({users, setRole, onHeaderClickHandler, banUser, unBanUser, viewUserDetail, pageCount, page, onPageChange}) => {
-const Table = ({users, setRole, onHeaderClickHandler, setUserBanStatus, viewUserDetail, pageCount, page, onPageChange}) => (
-
-
-
-
- {headers.map((header, i) =>(
- | onHeaderClickHandler({field: header.field})}>
- {header.title}
- |
- ))}
-
-
-
- {users.map((row, i)=> (
-
- |
-
- {row.profiles.map(({id}) => id)}
- |
-
- {row.created_at}
- |
-
- setUserBanStatus({id: row.id, status: status === 'BANNED'})}>
-
-
-
- |
-
- setRole(row.id, role)}>
-
-
-
-
-
- |
+ const getStatus = (status) => {
+ return status.banned.status ? 'BANNED' : 'ACTIVE';
+ };
+
+ const setUserBanStatus = (id, bannedStatus) => {
+ return bannedStatus ? unBanUser(id) : banUser(id);
+ };
+
+ return (
+
+
+
+
+ {headers.map((header, i) =>(
+ | onHeaderClickHandler({field: header.field})}>
+ {header.title}
+ |
+ ))}
- ))}
-
-
-
-
-);
+
+
+ {users.map((row, i)=> (
+
+ |
+
+ {row.profiles.map(({id}) => id)}
+ |
+
+ {row.created_at}
+ |
+
+ setUserBanStatus(row.id, status === 'BANNED')}>
+
+
+
+ |
+
+ setRole(row.id, role)}>
+
+
+
+
+
+ |
+
+ ))}
+
+
+
+
+ );
+};
Table.propTypes = {
users: PropTypes.array,
onHeaderClickHandler: PropTypes.func.isRequired,
setRole: PropTypes.func.isRequired,
- setUserBanStatus: PropTypes.func.isRequired,
+ banUser: PropTypes.func.isRequired,
+ unBanUser: PropTypes.func.isRequired,
viewUserDetail: PropTypes.func.isRequired,
pageCount: PropTypes.number.isRequired,
page: PropTypes.number.isRequired,
diff --git a/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js b/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js
index 4ac8a8630..35b2175bf 100644
--- a/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js
+++ b/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js
@@ -6,7 +6,7 @@ import {withFragments} from 'plugin-api/beta/client/hocs';
import {Spinner} from 'coral-ui';
import PropTypes from 'prop-types';
-import {withSetUserBanStatus} from 'coral-framework/graphql/mutations';
+import {withUnBanUser} from 'coral-framework/graphql/mutations';
import {showBanUserDialog} from 'actions/banUserDialog';
import {showSuspendUserDialog} from 'actions/suspendUserDialog';
import {showRejectUsernameDialog} from '../../../actions/community';
@@ -25,7 +25,7 @@ class FlaggedAccountsContainer extends Component {
}
approveUser = ({userId}) => {
- return this.props.setUserBanStatus({
+ return this.props.unBanUser({
id: userId,
status: false
});
@@ -83,7 +83,7 @@ FlaggedAccountsContainer.propTypes = {
showSuspendUserDialog: PropTypes.func,
showRejectUsernameDialog: PropTypes.func,
viewUserDetail: PropTypes.func,
- setUserBanStatus: PropTypes.func,
+ unBanUser: PropTypes.func,
data: PropTypes.object,
root: PropTypes.object
};
@@ -121,7 +121,7 @@ const mapDispatchToProps = (dispatch) =>
export default compose(
connect(null, mapDispatchToProps),
- withSetUserBanStatus,
+ withUnBanUser,
withFragments({
root: gql`
fragment TalkAdminCommunity_FlaggedAccounts_root on RootQuery {
diff --git a/client/coral-framework/graphql/mutations.js b/client/coral-framework/graphql/mutations.js
index a0e29220e..25ad3205c 100644
--- a/client/coral-framework/graphql/mutations.js
+++ b/client/coral-framework/graphql/mutations.js
@@ -216,16 +216,35 @@ export const withChangeUsername = withMutation(
})
});
-export const withSetUserBanStatus = withMutation(
+export const withBanUser = withMutation(
gql`
- mutation SetUserBanStatus($input: SetUserBanStatusInput!) {
- setUserBanStatus(input: $input) {
- ...SetUserBanStatusResponse
+ mutation BanUser($input: BanUserInput!) {
+ banUser(input: $input) {
+ ...BanUsersResponse
}
}
`, {
props: ({mutate}) => ({
- setUserBanStatus: (input) => {
+ banUser: (input) => {
+ return mutate({
+ variables: {
+ input,
+ },
+ });
+ }
+ }),
+ });
+
+export const withUnBanUser = withMutation(
+ gql`
+ mutation UnBanUser($input: UnBanUserInput!) {
+ unBanUser(input: $input) {
+ ...UnBanUserResponse
+ }
+ }
+ `, {
+ props: ({mutate}) => ({
+ unBanUser: (input) => {
return mutate({
variables: {
input,