From 24391de61d9d185ee5003d9c778b8d1e9c164c22 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 18 Sep 2017 11:06:31 -0300 Subject: [PATCH 01/12] userCount --- graph/loaders/users.js | 31 ++++++++++++++++++++++++++++++- graph/resolvers/root_query.js | 9 +++++++++ graph/typeDefs.graphql | 13 +++++++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/graph/loaders/users.js b/graph/loaders/users.js index b943c60ed..aa74aad29 100644 --- a/graph/loaders/users.js +++ b/graph/loaders/users.js @@ -107,6 +107,34 @@ const getUsersByQuery = async ({user, loaders: {Actions}}, {ids, limit, cursor, }; }; + +/** + * Retrieves the count of users based on the passed in query. + * @param {Object} context graph context + * @param {Object} query query to execute against the users collection + * to compute the counts + * @return {Promise} resolves to the counts of the users from the + * query + */ +const getCountByQuery = async ({loaders: {Actions}}, {action_type}) => { + let query = UserModel.find(); + + if (action_type) { + const userIds = await Actions.getByTypes({action_type, item_type: 'USERS'}); + + query = query.find({ + id: { + $in: userIds + } + }); + } + + + return UserModel + .find(query) + .count(); +}; + /** * Creates a set of loaders based on a GraphQL context. * @param {Object} context the context of the GraphQL request @@ -115,6 +143,7 @@ const getUsersByQuery = async ({user, loaders: {Actions}}, {ids, limit, cursor, module.exports = (context) => ({ Users: { getByQuery: (query) => getUsersByQuery(context, query), - getByID: new DataLoader((ids) => genUserByIDs(context, ids)) + getByID: new DataLoader((ids) => genUserByIDs(context, ids)), + getCountByQuery: (query) => getCountByQuery(context, query) } }); diff --git a/graph/resolvers/root_query.js b/graph/resolvers/root_query.js index 13e41a312..c42b7e9c2 100644 --- a/graph/resolvers/root_query.js +++ b/graph/resolvers/root_query.js @@ -50,6 +50,15 @@ const RootQuery = { return Comments.getCountByQuery(query); }, + + async userCount(_, {query}, {user, loaders: {Users}}) { + if (user == null || !user.can(SEARCH_OTHER_USERS)) { + return null; + } + + return Users.getCountByQuery(query); + }, + assetMetrics(_, query, {user, loaders: {Metrics: {Assets}}}) { if (user == null || !user.can(SEARCH_ASSETS)) { return null; diff --git a/graph/typeDefs.graphql b/graph/typeDefs.graphql index 916c0ade5..3191ddf06 100644 --- a/graph/typeDefs.graphql +++ b/graph/typeDefs.graphql @@ -337,6 +337,15 @@ input CommentCountQuery { tags: [String!] } +# UserCountQuery allows the ability to query user counts by specific +# methods. +input UserCountQuery { + + # comments returned will only be ones which have at least one action of this + # type. + action_type: ACTION_TYPE +} + type EditInfo { edited: Boolean! editableUntil: Date @@ -833,6 +842,10 @@ type RootQuery { # expensive as it is not batched. Requires the `ADMIN` role. commentCount(query: CommentCountQuery!): Int + # Return the count of users satisfied by the query. Note that this edge is + # expensive as it is not batched. Requires the `ADMIN` role. + userCount(query: UserCountQuery!): Int + # The currently logged in user based on the request. Requires any logged in # role. me: User From a07d6616551c4bb0f9fd059bb362a97408f6ac0d Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 18 Sep 2017 11:53:52 -0300 Subject: [PATCH 02/12] Adding CountBadge and flaggedUsernamesCount --- .../CountBadge.css} | 2 +- .../CountBadge.js} | 8 ++++---- .../routes/Community/components/Community.js | 5 ++++- .../Community/components/CommunityMenu.js | 6 ++++-- .../routes/Community/containers/Community.js | 17 ++++++++++++++++- .../Moderation/components/ModerationMenu.js | 4 ++-- 6 files changed, 31 insertions(+), 11 deletions(-) rename client/coral-admin/src/{routes/Moderation/components/CommentCount.css => components/CountBadge.css} (93%) rename client/coral-admin/src/{routes/Moderation/components/CommentCount.js => components/CountBadge.js} (81%) diff --git a/client/coral-admin/src/routes/Moderation/components/CommentCount.css b/client/coral-admin/src/components/CountBadge.css similarity index 93% rename from client/coral-admin/src/routes/Moderation/components/CommentCount.css rename to client/coral-admin/src/components/CountBadge.css index 998133d07..343692ecb 100644 --- a/client/coral-admin/src/routes/Moderation/components/CommentCount.css +++ b/client/coral-admin/src/components/CountBadge.css @@ -5,7 +5,7 @@ vertical-align: middle; padding: 1px 5px; border-radius: 2px; - margin-left: 2px; + margin-left: 5px; line-height: 18px; box-sizing: border-box; height: 18px; diff --git a/client/coral-admin/src/routes/Moderation/components/CommentCount.js b/client/coral-admin/src/components/CountBadge.js similarity index 81% rename from client/coral-admin/src/routes/Moderation/components/CommentCount.js rename to client/coral-admin/src/components/CountBadge.js index 53d611ed6..ff47cf9a6 100644 --- a/client/coral-admin/src/routes/Moderation/components/CommentCount.js +++ b/client/coral-admin/src/components/CountBadge.js @@ -1,10 +1,10 @@ import React from 'react'; import PropTypes from 'prop-types'; -import styles from './CommentCount.css'; +import styles from './CountBadge.css'; import t from 'coral-framework/services/i18n'; -const CommentCount = ({count}) => { +const CountBadge = ({count}) => { let number = count; // shorten large counts to abbreviations @@ -21,8 +21,8 @@ const CommentCount = ({count}) => { ); }; -CommentCount.propTypes = { +CountBadge.propTypes = { count: PropTypes.number.isRequired }; -export default CommentCount; +export default CountBadge; diff --git a/client/coral-admin/src/routes/Community/components/Community.js b/client/coral-admin/src/routes/Community/components/Community.js index e59f9b6ca..1b3e4ac72 100644 --- a/client/coral-admin/src/routes/Community/components/Community.js +++ b/client/coral-admin/src/routes/Community/components/Community.js @@ -90,10 +90,13 @@ export default class Community extends Component { render() { const {searchValue} = this.state; const tab = this.getTabContent(searchValue, this.props); + const {root: {flaggedUsernamesCount}} = this.props; return (
- +
{ tab }
diff --git a/client/coral-admin/src/routes/Community/components/CommunityMenu.js b/client/coral-admin/src/routes/Community/components/CommunityMenu.js index 1e226313d..71e01d817 100644 --- a/client/coral-admin/src/routes/Community/components/CommunityMenu.js +++ b/client/coral-admin/src/routes/Community/components/CommunityMenu.js @@ -1,18 +1,20 @@ import React from 'react'; - import styles from './CommunityMenu.css'; import t from 'coral-framework/services/i18n'; import {Link} from 'react-router'; +import CountBadge from '../../../components/CountBadge'; -const CommunityMenu = () => { +const CommunityMenu = ({flaggedUsernamesCount = 0}) => { const flaggedPath = '/admin/community/flagged'; const peoplePath = '/admin/community/people'; + return (
{t('community.flaggedaccounts')} + {t('community.people')} diff --git a/client/coral-admin/src/routes/Community/containers/Community.js b/client/coral-admin/src/routes/Community/containers/Community.js index a41c257d6..cc4b3b343 100644 --- a/client/coral-admin/src/routes/Community/containers/Community.js +++ b/client/coral-admin/src/routes/Community/containers/Community.js @@ -1,7 +1,8 @@ import React, {Component} from 'react'; import {connect} from 'react-redux'; import {bindActionCreators} from 'redux'; -import {compose} from 'react-apollo'; +import {compose, gql} from 'react-apollo'; +import withQuery from 'coral-framework/hocs/withQuery'; import {withSetUserStatus, withRejectUsername} from 'coral-framework/graphql/mutations'; import { @@ -29,6 +30,19 @@ const mapStateToProps = (state) => ({ community: state.community, }); + +const withFlaggedUsernamesCount = withQuery(gql` + query TalkAdmin_FlaggedUsernamesCount { + flaggedUsernamesCount: userCount(query: { + action_type: FLAG + }) + } + `, { + options: { + fetchPolicy: 'network-only', + }, +}); + const mapDispatchToProps = (dispatch) => bindActionCreators({ fetchAccounts, @@ -41,4 +55,5 @@ export default compose( connect(mapStateToProps, mapDispatchToProps), withSetUserStatus, withRejectUsername, + withFlaggedUsernamesCount, )(CommunityContainer); diff --git a/client/coral-admin/src/routes/Moderation/components/ModerationMenu.js b/client/coral-admin/src/routes/Moderation/components/ModerationMenu.js index 25b90cf64..27b8409c6 100644 --- a/client/coral-admin/src/routes/Moderation/components/ModerationMenu.js +++ b/client/coral-admin/src/routes/Moderation/components/ModerationMenu.js @@ -1,6 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import CommentCount from './CommentCount'; +import CountBadge from '../../../components/CountBadge'; import styles from './styles.css'; import {SelectField, Option} from 'react-mdl-selectfield'; import {Icon} from 'coral-ui'; @@ -28,7 +28,7 @@ const ModerationMenu = ({ to={getModPath(queue.key, asset.id)} className={cn('mdl-tabs__tab', styles.tab, {[styles.active]: activeTab === queue.key})} activeClassName={styles.active}> - {queue.name} + {queue.name} )}
From ab2e036047a8321185fa18dab0824f2c6c0f864b Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 18 Sep 2017 15:49:23 -0300 Subject: [PATCH 03/12] withFragments and parent withQuery added --- .../routes/Community/components/Community.js | 12 ++--- .../Community/components/FlaggedAccounts.js | 2 + .../routes/Community/containers/Community.js | 22 +++++++-- .../Community/containers/FlaggedAccounts.js | 48 ++++++++----------- 4 files changed, 45 insertions(+), 39 deletions(-) diff --git a/client/coral-admin/src/routes/Community/components/Community.js b/client/coral-admin/src/routes/Community/components/Community.js index 1b3e4ac72..94f064ff6 100644 --- a/client/coral-admin/src/routes/Community/components/Community.js +++ b/client/coral-admin/src/routes/Community/components/Community.js @@ -74,9 +74,11 @@ export default class Community extends Component { ); } + // console.log('Community Container', this.props); + return (
- + - -
- { tab } -
+ +
{tab}
); } diff --git a/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js b/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js index 1d78c015a..578dc2d82 100644 --- a/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js +++ b/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js @@ -19,6 +19,8 @@ class FlaggedAccounts extends React.Component { me, viewUserDetail, } = this.props; + + console.log('Flagged Accounts ROOT', this.props.root); const hasResults = users.nodes && !!users.nodes.length; diff --git a/client/coral-admin/src/routes/Community/containers/Community.js b/client/coral-admin/src/routes/Community/containers/Community.js index cc4b3b343..46ae43a40 100644 --- a/client/coral-admin/src/routes/Community/containers/Community.js +++ b/client/coral-admin/src/routes/Community/containers/Community.js @@ -4,7 +4,12 @@ import {bindActionCreators} from 'redux'; import {compose, gql} from 'react-apollo'; import withQuery from 'coral-framework/hocs/withQuery'; +import FlaggedAccounts from '../containers/FlaggedAccounts'; +import FlaggedUser from '../containers/FlaggedUser'; + import {withSetUserStatus, withRejectUsername} from 'coral-framework/graphql/mutations'; +import {getDefinitionName} from 'coral-framework/utils'; + import { fetchAccounts, updateSorting, @@ -21,9 +26,7 @@ class CommunityContainer extends Component { } render() { - return ( - - ); + return } } const mapStateToProps = (state) => ({ @@ -31,12 +34,21 @@ const mapStateToProps = (state) => ({ }); -const withFlaggedUsernamesCount = withQuery(gql` +const withData = withQuery(gql` query TalkAdmin_FlaggedUsernamesCount { flaggedUsernamesCount: userCount(query: { action_type: FLAG }) + ...${getDefinitionName(FlaggedAccounts.fragments.root)} + ...${getDefinitionName(FlaggedUser.fragments.root)} + me { + ...${getDefinitionName(FlaggedUser.fragments.me)} + __typename + } } + ${FlaggedAccounts.fragments.root} + ${FlaggedUser.fragments.root} + ${FlaggedUser.fragments.me} `, { options: { fetchPolicy: 'network-only', @@ -55,5 +67,5 @@ export default compose( connect(mapStateToProps, mapDispatchToProps), withSetUserStatus, withRejectUsername, - withFlaggedUsernamesCount, + withData, )(CommunityContainer); diff --git a/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js b/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js index 00c6fdf33..ad824b4af 100644 --- a/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js +++ b/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js @@ -2,7 +2,7 @@ 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 {withFragments} from 'plugin-api/beta/client/hocs'; import {Spinner} from 'coral-ui'; import {withSetUserStatus} from 'coral-framework/graphql/mutations'; @@ -50,6 +50,8 @@ class FlaggedAccountsContainer extends Component { }; render() { + console.log('Flagged AccountsContainer', this.props); + if (this.props.data.error) { return
{this.props.data.error.message}
; } @@ -88,31 +90,6 @@ const LOAD_MORE_QUERY = gql` ${FlaggedUser.fragments.user} `; -export const withFlaggedAccountsyQuery = withQuery(gql` - query TalkAdmin_FlaggedAccounts { - ...${getDefinitionName(FlaggedUser.fragments.root)} - users(query:{action_type: FLAG, statuses: [PENDING], 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} -`, { - options: { - fetchPolicy: 'network-only', - }, -}); - const mapDispatchToProps = (dispatch) => bindActionCreators({ showBanUserDialog, @@ -123,6 +100,23 @@ const mapDispatchToProps = (dispatch) => export default compose( connect(null, mapDispatchToProps), - withFlaggedAccountsyQuery, withSetUserStatus, + withFragments({ + root: gql` + fragment TalkAdminCommunity_FlaggedAccounts_root on RootQuery { + users(query:{action_type: FLAG, statuses: [PENDING], limit: 10}){ + hasNextPage + endCursor + nodes { + __typename + ...${getDefinitionName(FlaggedUser.fragments.user)} + } + } + me { + id + } + } + ${FlaggedUser.fragments.user} + `, + }), )(FlaggedAccountsContainer); From f1f98680284fa2591606d3d6c9ddcb4040e20189 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 19 Sep 2017 11:13:06 -0300 Subject: [PATCH 04/12] Cleaning console.logs --- .../src/routes/Community/components/FlaggedAccounts.js | 2 -- .../coral-admin/src/routes/Community/containers/Community.js | 3 +-- .../src/routes/Community/containers/FlaggedAccounts.js | 2 -- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js b/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js index 578dc2d82..1d78c015a 100644 --- a/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js +++ b/client/coral-admin/src/routes/Community/components/FlaggedAccounts.js @@ -19,8 +19,6 @@ class FlaggedAccounts extends React.Component { me, viewUserDetail, } = this.props; - - console.log('Flagged Accounts ROOT', this.props.root); const hasResults = users.nodes && !!users.nodes.length; diff --git a/client/coral-admin/src/routes/Community/containers/Community.js b/client/coral-admin/src/routes/Community/containers/Community.js index 46ae43a40..a74128188 100644 --- a/client/coral-admin/src/routes/Community/containers/Community.js +++ b/client/coral-admin/src/routes/Community/containers/Community.js @@ -26,14 +26,13 @@ class CommunityContainer extends Component { } render() { - return + return ; } } const mapStateToProps = (state) => ({ community: state.community, }); - const withData = withQuery(gql` query TalkAdmin_FlaggedUsernamesCount { flaggedUsernamesCount: userCount(query: { diff --git a/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js b/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js index ad824b4af..ee3ec979f 100644 --- a/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js +++ b/client/coral-admin/src/routes/Community/containers/FlaggedAccounts.js @@ -50,8 +50,6 @@ class FlaggedAccountsContainer extends Component { }; render() { - console.log('Flagged AccountsContainer', this.props); - if (this.props.data.error) { return
{this.props.data.error.message}
; } From 818ad07eac35dbb467b88bc33246ea35235d4eae Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 19 Sep 2017 11:43:10 -0300 Subject: [PATCH 05/12] lint fixes --- graph/loaders/users.js | 6 ++---- graph/resolvers/root_query.js | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/graph/loaders/users.js b/graph/loaders/users.js index aa74aad29..269512c60 100644 --- a/graph/loaders/users.js +++ b/graph/loaders/users.js @@ -107,7 +107,6 @@ const getUsersByQuery = async ({user, loaders: {Actions}}, {ids, limit, cursor, }; }; - /** * Retrieves the count of users based on the passed in query. * @param {Object} context graph context @@ -129,10 +128,9 @@ const getCountByQuery = async ({loaders: {Actions}}, {action_type}) => { }); } - return UserModel - .find(query) - .count(); + .find(query) + .count(); }; /** diff --git a/graph/resolvers/root_query.js b/graph/resolvers/root_query.js index c42b7e9c2..e4701c901 100644 --- a/graph/resolvers/root_query.js +++ b/graph/resolvers/root_query.js @@ -50,7 +50,6 @@ const RootQuery = { return Comments.getCountByQuery(query); }, - async userCount(_, {query}, {user, loaders: {Users}}) { if (user == null || !user.can(SEARCH_OTHER_USERS)) { return null; From a96d8c2b3cc7c4aefabf51beb3e922359501b65d Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 19 Sep 2017 12:45:47 -0300 Subject: [PATCH 06/12] Copy, removing log, and adding PropTypes --- .../coral-admin/src/routes/Community/components/Community.js | 2 -- .../src/routes/Community/components/CommunityMenu.js | 5 +++++ graph/typeDefs.graphql | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/client/coral-admin/src/routes/Community/components/Community.js b/client/coral-admin/src/routes/Community/components/Community.js index 94f064ff6..ed0ab728d 100644 --- a/client/coral-admin/src/routes/Community/components/Community.js +++ b/client/coral-admin/src/routes/Community/components/Community.js @@ -74,8 +74,6 @@ export default class Community extends Component { ); } - // console.log('Community Container', this.props); - return (
diff --git a/client/coral-admin/src/routes/Community/components/CommunityMenu.js b/client/coral-admin/src/routes/Community/components/CommunityMenu.js index 71e01d817..3e13617fe 100644 --- a/client/coral-admin/src/routes/Community/components/CommunityMenu.js +++ b/client/coral-admin/src/routes/Community/components/CommunityMenu.js @@ -2,6 +2,7 @@ import React from 'react'; import styles from './CommunityMenu.css'; import t from 'coral-framework/services/i18n'; import {Link} from 'react-router'; +import PropTypes from 'prop-types'; import CountBadge from '../../../components/CountBadge'; const CommunityMenu = ({flaggedUsernamesCount = 0}) => { @@ -25,4 +26,8 @@ const CommunityMenu = ({flaggedUsernamesCount = 0}) => { ); }; +CommunityMenu.propTypes = { + flaggedUsernamesCount: PropTypes.number, +}; + export default CommunityMenu; diff --git a/graph/typeDefs.graphql b/graph/typeDefs.graphql index e9d850bd3..5b5ab8190 100644 --- a/graph/typeDefs.graphql +++ b/graph/typeDefs.graphql @@ -848,7 +848,7 @@ type RootQuery { commentCount(query: CommentCountQuery!): Int # Return the count of users satisfied by the query. Note that this edge is - # expensive as it is not batched. Requires the `ADMIN` role. + # expensive as it is not batched. This field is restricted. userCount(query: UserCountQuery!): Int # The currently logged in user based on the request. Requires any logged in From b3cb99925d2e506702c19eac836918c2eb6ba094 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 19 Sep 2017 13:10:14 -0300 Subject: [PATCH 07/12] Adding PropTypes --- .../routes/Community/containers/Community.js | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/client/coral-admin/src/routes/Community/containers/Community.js b/client/coral-admin/src/routes/Community/containers/Community.js index a74128188..2b9dbbe74 100644 --- a/client/coral-admin/src/routes/Community/containers/Community.js +++ b/client/coral-admin/src/routes/Community/containers/Community.js @@ -3,6 +3,7 @@ import {connect} from 'react-redux'; import {bindActionCreators} from 'redux'; import {compose, gql} from 'react-apollo'; import withQuery from 'coral-framework/hocs/withQuery'; +import PropTypes from 'prop-types'; import FlaggedAccounts from '../containers/FlaggedAccounts'; import FlaggedUser from '../containers/FlaggedUser'; @@ -26,13 +27,34 @@ class CommunityContainer extends Component { } render() { - return ; + return ; } } const mapStateToProps = (state) => ({ community: state.community, }); +CommunityContainer.propTypes = { + community: PropTypes.object, + fetchAccounts: PropTypes.func, + hideRejectUsernameDialog: PropTypes.func, + updateSorting: PropTypes.func, + newPage: PropTypes.func, + route: PropTypes.object, + rejectUsername: PropTypes.func, + data: PropTypes.object, + root: PropTypes.object +}; + const withData = withQuery(gql` query TalkAdmin_FlaggedUsernamesCount { flaggedUsernamesCount: userCount(query: { From bccad5585ef32650b12fac8567a0642e22215f08 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 19 Sep 2017 13:10:35 -0300 Subject: [PATCH 08/12] Adding statuses --- graph/loaders/users.js | 10 +++++++++- graph/typeDefs.graphql | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/graph/loaders/users.js b/graph/loaders/users.js index 269512c60..dc58fffad 100644 --- a/graph/loaders/users.js +++ b/graph/loaders/users.js @@ -115,7 +115,7 @@ const getUsersByQuery = async ({user, loaders: {Actions}}, {ids, limit, cursor, * @return {Promise} resolves to the counts of the users from the * query */ -const getCountByQuery = async ({loaders: {Actions}}, {action_type}) => { +const getCountByQuery = async ({loaders: {Actions}}, {action_type, statuses}) => { let query = UserModel.find(); if (action_type) { @@ -128,6 +128,14 @@ const getCountByQuery = async ({loaders: {Actions}}, {action_type}) => { }); } + if (statuses) { + query = query.where({ + status: { + $in: statuses + } + }); + } + return UserModel .find(query) .count(); diff --git a/graph/typeDefs.graphql b/graph/typeDefs.graphql index 5b5ab8190..db296e45d 100644 --- a/graph/typeDefs.graphql +++ b/graph/typeDefs.graphql @@ -348,6 +348,9 @@ input UserCountQuery { # comments returned will only be ones which have at least one action of this # type. action_type: ACTION_TYPE + + # Current status of a user. + statuses: [USER_STATUS] } type EditInfo { From a211f94a91a09ee49d7994673f18e935a5ab05b8 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 19 Sep 2017 13:11:23 -0300 Subject: [PATCH 09/12] Adding status to the FE Query --- .../coral-admin/src/routes/Community/containers/Community.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/coral-admin/src/routes/Community/containers/Community.js b/client/coral-admin/src/routes/Community/containers/Community.js index 2b9dbbe74..783611e6d 100644 --- a/client/coral-admin/src/routes/Community/containers/Community.js +++ b/client/coral-admin/src/routes/Community/containers/Community.js @@ -58,7 +58,8 @@ CommunityContainer.propTypes = { const withData = withQuery(gql` query TalkAdmin_FlaggedUsernamesCount { flaggedUsernamesCount: userCount(query: { - action_type: FLAG + action_type: FLAG, + statuses: [PENDING] }) ...${getDefinitionName(FlaggedAccounts.fragments.root)} ...${getDefinitionName(FlaggedUser.fragments.root)} From a5350c44aea6eeeb9c091756b1ad96efc477a1d9 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 19 Sep 2017 13:14:20 -0300 Subject: [PATCH 10/12] Adding PropTypes --- .../src/routes/Community/components/Community.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/client/coral-admin/src/routes/Community/components/Community.js b/client/coral-admin/src/routes/Community/components/Community.js index ed0ab728d..4ec881bdf 100644 --- a/client/coral-admin/src/routes/Community/components/Community.js +++ b/client/coral-admin/src/routes/Community/components/Community.js @@ -4,6 +4,7 @@ import CommunityMenu from './CommunityMenu'; import People from './People'; import FlaggedAccounts from '../containers/FlaggedAccounts'; import RejectUsernameDialog from './RejectUsernameDialog'; +import PropTypes from 'prop-types'; export default class Community extends Component { @@ -101,3 +102,14 @@ export default class Community extends Component { } } +Community.propTypes = { + community: PropTypes.object, + fetchAccounts: PropTypes.func, + hideRejectUsernameDialog: PropTypes.func, + updateSorting: PropTypes.func, + newPage: PropTypes.func, + route: PropTypes.object, + rejectUsername: PropTypes.func, + data: PropTypes.object, + root: PropTypes.object +}; From b9086244e2070540fb24b2b9e0245c0e029a0fca Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 19 Sep 2017 13:24:36 -0300 Subject: [PATCH 11/12] More proptypes --- .../src/routes/Community/components/Community.js | 5 ++++- .../Community/containers/FlaggedAccounts.js | 16 +++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/client/coral-admin/src/routes/Community/components/Community.js b/client/coral-admin/src/routes/Community/components/Community.js index 4ec881bdf..bf300a166 100644 --- a/client/coral-admin/src/routes/Community/components/Community.js +++ b/client/coral-admin/src/routes/Community/components/Community.js @@ -77,7 +77,10 @@ export default class Community extends Component { return (
- + { - return this.props.setUserStatus({userId, status: 'APPROVED'}); + return this.props.setUserStatus({ + userId, + status: 'APPROVED' + }); } loadMore = () => { @@ -74,6 +78,16 @@ class FlaggedAccountsContainer extends Component { } } +FlaggedAccountsContainer.propTypes = { + showBanUserDialog: PropTypes.func, + showSuspendUserDialog: PropTypes.func, + showRejectUsernameDialog: PropTypes.func, + viewUserDetail: PropTypes.func, + setUserStatus: PropTypes.func, + data: PropTypes.object, + root: PropTypes.object +}; + const LOAD_MORE_QUERY = gql` query TalkAdmin_LoadMoreFlaggedAccounts($limit: Int, $cursor: Cursor) { users(query:{action_type: FLAG, statuses: [PENDING], limit: $limit, cursor: $cursor}){ From 7a74d5ee836c5e109b08a1d2851821d00405e8ab Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 19 Sep 2017 13:26:04 -0300 Subject: [PATCH 12/12] missing prop --- client/coral-admin/src/routes/Community/containers/Community.js | 1 + 1 file changed, 1 insertion(+) diff --git a/client/coral-admin/src/routes/Community/containers/Community.js b/client/coral-admin/src/routes/Community/containers/Community.js index 783611e6d..445b7f413 100644 --- a/client/coral-admin/src/routes/Community/containers/Community.js +++ b/client/coral-admin/src/routes/Community/containers/Community.js @@ -28,6 +28,7 @@ class CommunityContainer extends Component { render() { return