diff --git a/client/coral-admin/src/containers/SuspendUserDialog.js b/client/coral-admin/src/containers/SuspendUserDialog.js
index f60014832..1616acfcf 100644
--- a/client/coral-admin/src/containers/SuspendUserDialog.js
+++ b/client/coral-admin/src/containers/SuspendUserDialog.js
@@ -54,8 +54,9 @@ class SuspendUserDialogContainer extends Component {
const withOrganizationName = withQuery(gql`
query CoralAdmin_SuspendUserDialog {
+ __typename
settings {
- organizationName
+ organizationName
}
}
`);
diff --git a/client/coral-admin/src/routes/Community/components/Community.js b/client/coral-admin/src/routes/Community/components/Community.js
index f7e91c590..e59f9b6ca 100644
--- a/client/coral-admin/src/routes/Community/components/Community.js
+++ b/client/coral-admin/src/routes/Community/components/Community.js
@@ -2,7 +2,7 @@ import React, {Component} from 'react';
import CommunityMenu from './CommunityMenu';
import People from './People';
-import FlaggedAccounts from './FlaggedAccounts';
+import FlaggedAccounts from '../containers/FlaggedAccounts';
import RejectUsernameDialog from './RejectUsernameDialog';
export default class Community extends Component {
@@ -54,7 +54,7 @@ export default class Community extends Component {
}
getTabContent(searchValue, props) {
- const {community, root: {users}, viewUserDetail} = props;
+ const {community} = props;
const activeTab = props.route.path === ':id' ? 'flagged' : props.route.path;
if (activeTab === 'people') {
@@ -76,16 +76,7 @@ export default class Community extends Component {
return (
-
+
{
- const {commenters} = props;
- const hasResults = commenters && !!commenters.length;
+ const {
+ users,
+ loadMore,
+ showBanUserDialog,
+ showSuspendUserDialog,
+ showRejectUsernameDialog,
+ approveUser,
+ me,
+ viewUserDetail,
+ } = props;
+
+ const hasResults = users.nodes && !!users.nodes.length;
return (
{
hasResults
- ? commenters.map((commenter, index) => {
- return {
+ return ;
})
: {t('community.no_flagged_accounts')}
}
+
);
diff --git a/client/coral-admin/src/routes/Community/components/User.js b/client/coral-admin/src/routes/Community/components/FlaggedUser.js
similarity index 98%
rename from client/coral-admin/src/routes/Community/components/User.js
rename to client/coral-admin/src/routes/Community/components/FlaggedUser.js
index 2d921a1c7..736e3a992 100644
--- a/client/coral-admin/src/routes/Community/components/User.js
+++ b/client/coral-admin/src/routes/Community/components/FlaggedUser.js
@@ -39,7 +39,7 @@ const User = (props) => {
- {props.currentUser.id !== user.id &&
+ {props.me.id !== user.id &&
{
- return this.props.setUserStatus({userId, status: 'APPROVED'});
- }
-
- banUser = ({userId}) => {
- return this.props.setUserStatus({userId, status: 'BANNED'});
- }
-
render() {
- if (this.props.data.error) {
- return {this.props.data.error.message}
;
- }
-
- if (!('users' in this.props.root)) {
- return
;
- }
return (
-
+
);
}
}
-
-export const withCommunityQuery = withQuery(gql`
- query CoralAdmin_Community($action_type: ACTION_TYPE) {
- users(query:{action_type: $action_type}){
- hasNextPage
- endCursor
- nodes {
- id
- username
- status
- roles
- actions{
- id
- created_at
- ... on FlagAction {
- reason
- message
- user {
- id
- username
- }
- }
- }
- action_summaries {
- count
- ... on FlagActionSummary {
- reason
- }
- }
- }
- }
- }
-`, {
- options: ({params: {action_type = 'FLAG'}}) => {
- return {
- variables: {
- action_type: action_type
- }
- };
- }
-});
-
const mapStateToProps = (state) => ({
community: state.community,
- currentUser: state.auth.user,
});
const mapDispatchToProps = (dispatch) =>
bindActionCreators({
fetchAccounts,
- showBanUserDialog,
- showSuspendUserDialog,
- showRejectUsernameDialog,
hideRejectUsernameDialog,
updateSorting,
newPage,
- viewUserDetail,
}, dispatch);
export default compose(
connect(mapStateToProps, mapDispatchToProps),
- withCommunityQuery,
withSetUserStatus,
withRejectUsername,
)(CommunityContainer);
diff --git a/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js b/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js
new file mode 100644
index 000000000..29439e362
--- /dev/null
+++ b/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js
@@ -0,0 +1,120 @@
+import React, {Component} from 'react';
+import {connect} from 'react-redux';
+import {bindActionCreators} from 'redux';
+import {compose, gql} from 'react-apollo';
+import withQuery from 'coral-framework/hocs/withQuery';
+import {Spinner} from 'coral-ui';
+
+import {withSetUserStatus} from 'coral-framework/graphql/mutations';
+import {showBanUserDialog} from 'actions/banUserDialog';
+import {showSuspendUserDialog} from 'actions/suspendUserDialog';
+import {showRejectUsernameDialog} from '../../../actions/community';
+import {viewUserDetail} from '../../../actions/userDetail';
+import {getDefinitionName} from 'coral-framework/utils';
+import {appendNewNodes} from 'plugin-api/beta/client/utils';
+import update from 'immutability-helper';
+
+import FlaggedAccounts from '../components/FlaggedAccounts';
+import FlaggedUser from '../containers/FlaggedUser';
+
+class FlaggedAccountsContainer extends Component {
+
+ approveUser = ({userId}) => {
+ return this.props.setUserStatus({userId, status: 'APPROVED'});
+ }
+
+ loadMore = () => {
+ return this.props.data.fetchMore({
+ query: LOAD_MORE_QUERY,
+ variables: {
+ limit: 5,
+ cursor: this.props.root.users.endCursor,
+ },
+ updateQuery: (previous, {fetchMoreResult:{users}}) => {
+ const updated = update(previous, {
+ users: {
+ nodes: {
+ $apply: (nodes) => appendNewNodes(nodes, users.nodes),
+ },
+ hasNextPage: {$set: users.hasNextPage},
+ endCursor: {$set: users.endCursor},
+ },
+ });
+ return updated;
+ },
+ });
+ };
+
+ render() {
+ if (this.props.data.error) {
+ return {this.props.data.error.message}
;
+ }
+
+ if (this.props.data.loading) {
+ return
;
+ }
+ return (
+
+ );
+ }
+}
+
+const LOAD_MORE_QUERY = gql`
+ query TalkAdmin_LoadMoreFlaggedAccounts($limit: Int, $cursor: Cursor) {
+ users(query:{action_type: FLAG, limit: $limit, cursor: $cursor}){
+ hasNextPage
+ endCursor
+ nodes {
+ __typename
+ ...${getDefinitionName(FlaggedUser.fragments.user)}
+ }
+ }
+ }
+ ${FlaggedUser.fragments.user}
+`;
+
+export const withFlaggedAccountsyQuery = withQuery(gql`
+ query TalkAdmin_FlaggedAccounts {
+ ...${getDefinitionName(FlaggedUser.fragments.root)}
+ users(query:{action_type: FLAG, limit: 10}){
+ hasNextPage
+ endCursor
+ nodes {
+ __typename
+ ...${getDefinitionName(FlaggedUser.fragments.user)}
+ }
+ }
+ me {
+ __typename
+ ...${getDefinitionName(FlaggedUser.fragments.me)}
+ }
+ }
+ ${FlaggedUser.fragments.root}
+ ${FlaggedUser.fragments.user}
+ ${FlaggedUser.fragments.me}
+`);
+
+const mapDispatchToProps = (dispatch) =>
+ bindActionCreators({
+ showBanUserDialog,
+ showSuspendUserDialog,
+ showRejectUsernameDialog,
+ viewUserDetail,
+ }, dispatch);
+
+export default compose(
+ connect(null, mapDispatchToProps),
+ withFlaggedAccountsyQuery,
+ withSetUserStatus,
+)(FlaggedAccountsContainer);
diff --git a/client/coral-admin/src/routes/Community/containers/FlaggedUser.js b/client/coral-admin/src/routes/Community/containers/FlaggedUser.js
new file mode 100644
index 000000000..f92c93c1c
--- /dev/null
+++ b/client/coral-admin/src/routes/Community/containers/FlaggedUser.js
@@ -0,0 +1,42 @@
+import {gql} from 'react-apollo';
+import FlaggedUser from '../components/FlaggedUser';
+import {withFragments} from 'plugin-api/beta/client/hocs';
+
+export default withFragments({
+ root: gql`
+ fragment TalkAdminCommunity_FlaggedUser_root on RootQuery {
+ __typename
+ }
+ `,
+ me: gql`
+ fragment TalkAdminCommunity_FlaggedUser_me on User {
+ id
+ }
+ `,
+ user: gql`
+ fragment TalkAdminCommunity_FlaggedUser_user on User {
+ id
+ username
+ status
+ roles
+ actions{
+ id
+ created_at
+ ... on FlagAction {
+ reason
+ message
+ user {
+ id
+ username
+ }
+ }
+ }
+ action_summaries {
+ count
+ ... on FlagActionSummary {
+ reason
+ }
+ }
+ }
+ `
+})(FlaggedUser);