diff --git a/client/coral-admin/src/routes/Community/components/People.js b/client/coral-admin/src/routes/Community/components/People.js index 941173773..a5e2aecdd 100644 --- a/client/coral-admin/src/routes/Community/components/People.js +++ b/client/coral-admin/src/routes/Community/components/People.js @@ -30,138 +30,150 @@ const headers = [ } ]; -const getActionMenuLabel = (user) => { +class People extends React.Component { - if (isBanned(user)) { - return 'Banned'; - } else if (isSuspended(user)) { - return 'Suspended'; + getActionMenuLabel = (user) => { + if (isBanned(user)) { + return 'Banned'; + } else if (isSuspended(user)) { + return 'Suspended'; + } + return ''; + }; + + unSuspendUser = (input) => { + this.props.unSuspendUser(input); } - return ''; -}; + unBanUser = (input) => { + this.props.unBanUser(input); + } -const People = (props) => { - const { - onSearchChange, - users = [], - setUserRole, - viewUserDetail, - loadMore, - unSuspendUser, - unBanUser, - showSuspendUserDialog, - showBanUserDialog, - } = props; + showBanUserDialog = (input) => { + this.props.showBanUserDialog(input); + } - const hasResults = !!users.nodes.length; + showSuspendUserDialog = (input) => { + this.props.showSuspendUserDialog(input); + } - return ( -
-
-
- - + render () { + const { + onSearchChange, + users = [], + setUserRole, + viewUserDetail, + loadMore, + } = this.props; + + const hasResults = !!users.nodes.length; + + return ( +
+
+
+ + +
+
+
+ { + hasResults + ?
+
+ + + + {headers.map((header, i) =>( + + ))} + + + + {users.nodes.map((user, i)=> ( + + + + + + + ))} + +
+ {header.title} +
+ + {user.profiles.map(({id}) => id)} + + {moment(new Date(user.created_at)).format('MMMM Do YYYY, h:mm:ss a')} + + + + {isSuspended(user) ? this.unSuspendUser({id: user.id})}> + Remove Suspension + : this.showSuspendUserDialog({ + userId: user.id, + username: user.username, + })}> + Suspend User + } + + {isBanned(user) ? this.unBanUser({id: user.id})}> + Remove Ban + : this.showBanUserDialog({ + userId: user.id, + username: user.username, + })}> + Ban User + } + + + + setUserRole(user.id, role)}> + +
+
+ +
+ : {t('community.no_results')} + }
-
- { - hasResults - ?
-
- - - - {headers.map((header, i) =>( - - ))} - - - - {users.nodes.map((user, i)=> ( - - - - - - - ))} - -
- {header.title} -
- - {user.profiles.map(({id}) => id)} - - {moment(new Date(user.created_at)).format('MMMM Do YYYY, h:mm:ss a')} - - - - - {isSuspended(user) ? unSuspendUser({id: user.id})}> - Remove Suspension - : showSuspendUserDialog({ - userId: user.id, - username: user.username, - })}> - Suspend User - } - - {isBanned(user) ? unBanUser({id: user.id})}> - Remove Ban - : showBanUserDialog({ - userId: user.id, - username: user.username, - })}> - Ban User - } - - - - setUserRole(user.id, role)}> - -
-
- -
- : {t('community.no_results')} - } -
-
- ); -}; + ); + } +} People.propTypes = { users: PropTypes.object.isRequired, diff --git a/client/coral-admin/src/routes/Community/containers/People.js b/client/coral-admin/src/routes/Community/containers/People.js index e262bf28a..81308e773 100644 --- a/client/coral-admin/src/routes/Community/containers/People.js +++ b/client/coral-admin/src/routes/Community/containers/People.js @@ -77,7 +77,7 @@ class PeopleContainer extends React.Component { showSuspendUserDialog={this.props.showSuspendUserDialog} showBanUserDialog={this.props.showBanUserDialog} unBanUser={this.props.unBanUser} - unSuspendUser={this.props.unBanUser} + unSuspendUser={this.props.unSuspendUser} data={this.props.data} root={this.props.root} users={this.props.root.users} @@ -127,8 +127,8 @@ const LOAD_MORE_QUERY = gql` export default compose( connect(null, mapDispatchToProps), withSetUserRole, - withUnBanUser, withUnSuspendUser, + withUnBanUser, withFragments({ root: gql` fragment TalkAdminCommunity_People_root on RootQuery {