Adding rejectUsername

This commit is contained in:
okbel
2018-04-04 07:59:13 -03:00
parent de6f325204
commit 7955b28a75
3 changed files with 22 additions and 2 deletions
@@ -110,6 +110,7 @@ class UserDetail extends React.Component {
unbanUser,
unsuspendUser,
modal,
rejectUsername,
} = this.props;
// if totalComments is 0, you're dividing by zero
@@ -122,6 +123,8 @@ class UserDetail extends React.Component {
const banned = isBanned(user);
const suspended = isSuspended(user);
console.log(user);
const slotPassthrough = {
root,
user,
@@ -155,6 +158,10 @@ class UserDetail extends React.Component {
)}
label={this.getActionMenuLabel()}
>
<ActionsMenuItem onClick={() => rejectUsername({ id: user.id })}>
Reject Username
</ActionsMenuItem>
{suspended ? (
<ActionsMenuItem onClick={() => unsuspendUser({ id: user.id })}>
{t('user_detail.remove_suspension')}
@@ -167,7 +174,6 @@ class UserDetail extends React.Component {
{t('user_detail.suspend')}
</ActionsMenuItem>
)}
{banned ? (
<ActionsMenuItem onClick={() => unbanUser({ id: user.id })}>
{t('user_detail.remove_ban')}
@@ -376,6 +382,7 @@ UserDetail.propTypes = {
unbanUser: PropTypes.func.isRequired,
unsuspendUser: PropTypes.func.isRequired,
modal: PropTypes.bool,
rejectUsername: PropTypes.func.isRequired,
};
export default UserDetail;
@@ -26,6 +26,7 @@ import UserDetailComment from './UserDetailComment';
import update from 'immutability-helper';
import { showBanUserDialog } from 'actions/banUserDialog';
import { showSuspendUserDialog } from 'actions/suspendUserDialog';
import { withRejectUsername } from '../../../coral-framework/graphql/mutations';
const commentConnectionFragment = gql`
fragment CoralAdmin_UserDetail_CommentConnection on CommentConnection {
@@ -131,6 +132,7 @@ class UserDetailContainer extends React.Component {
loading={loading}
error={this.props.data && this.props.data.error}
loadMore={this.loadMore}
rejectUsername={this.props.rejectUsername}
{...this.props}
/>
);
@@ -148,6 +150,7 @@ UserDetailContainer.propTypes = {
selectedCommentIds: PropTypes.array,
unbanUser: PropTypes.func.isRequired,
unsuspendUser: PropTypes.func.isRequired,
rejectUsername: PropTypes.func.isRequired,
};
const LOAD_MORE_QUERY = gql`
@@ -281,5 +284,6 @@ export default compose(
withUserDetailQuery,
withSetCommentStatus,
withUnbanUser,
withUnsuspendUser
withUnsuspendUser,
withRejectUsername
)(UserDetailContainer);
+9
View File
@@ -33,3 +33,12 @@ export const isSuspended = user => {
export const isBanned = user => {
return get(user, 'state.status.banned.status');
};
/**
* isUsernameRejected
* retrieves boolean based on the username status
*/
export const isUsernameRejected = user => {
return get(user, 'state.status.username.status');
};