From acdfaeee9f4c5d47391b2b30eb7c85d92c9b76f7 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Fri, 22 Sep 2017 16:58:06 -0300 Subject: [PATCH 1/7] Moving the initial query up --- client/coral-admin/src/AppRouter.js | 4 +- client/coral-admin/src/containers/Layout.js | 74 +++++++++++++++---- .../routes/Community/components/Community.js | 2 +- .../Community/components/CommunityLayout.js | 9 --- .../routes/Community/containers/Community.js | 51 ++++++------- .../coral-admin/src/routes/Community/index.js | 2 - 6 files changed, 84 insertions(+), 58 deletions(-) delete mode 100644 client/coral-admin/src/routes/Community/components/CommunityLayout.js delete mode 100644 client/coral-admin/src/routes/Community/index.js diff --git a/client/coral-admin/src/AppRouter.js b/client/coral-admin/src/AppRouter.js index d50aeb3f6..d8e1b5377 100644 --- a/client/coral-admin/src/AppRouter.js +++ b/client/coral-admin/src/AppRouter.js @@ -6,7 +6,7 @@ import Configure from 'routes/Configure'; import Dashboard from 'routes/Dashboard'; import Install from 'routes/Install'; import Stories from 'routes/Stories'; -import {CommunityLayout, Community} from 'routes/Community'; +import Community from 'routes/Community/containers/Community'; import {ModerationLayout, Moderation} from 'routes/Moderation'; import Layout from 'containers/Layout'; @@ -22,7 +22,7 @@ const routes = ( {/* Community Routes */} - + diff --git a/client/coral-admin/src/containers/Layout.js b/client/coral-admin/src/containers/Layout.js index f2d71c93b..e97f64b8a 100644 --- a/client/coral-admin/src/containers/Layout.js +++ b/client/coral-admin/src/containers/Layout.js @@ -1,4 +1,4 @@ -import React, {Component} from 'react'; +import React, {Component, cloneElement} from 'react'; import {connect} from 'react-redux'; import Layout from '../components/ui/Layout'; import {fetchConfig} from '../actions/config'; @@ -10,6 +10,13 @@ import {toggleModal as toggleShortcutModal} from '../actions/moderation'; import {checkLogin, handleLogin, requestPasswordReset, logout} from '../actions/auth'; import {can} from 'coral-framework/services/perms'; import UserDetail from 'coral-admin/src/containers/UserDetail'; +import PropTypes from 'prop-types'; +import {compose, gql} from 'react-apollo'; + +import withQuery from 'coral-framework/hocs/withQuery'; +import {bindActionCreators} from 'redux'; +import {getDefinitionName} from 'coral-framework/utils'; +import Community from '../routes/Community/containers/Community'; class LayoutContainer extends Component { componentWillMount() { @@ -19,6 +26,7 @@ class LayoutContainer extends Component { fetchConfig(); } render() { + const { user, loggedIn, @@ -29,13 +37,16 @@ class LayoutContainer extends Component { } = this.props.auth; const { - handleLogout, + children, + logout, toggleShortcutModal, - TALK_RECAPTCHA_PUBLIC + TALK_RECAPTCHA_PUBLIC, } = this.props; + if (loadingUser) { return ; } + if (!loggedIn) { return ( ); } + if (can(user, 'ACCESS_ADMIN') && loggedIn) { return ( - {this.props.children} + {cloneElement(children, { + root: this.props.root, + data: this.props.data + })} ); } else if (loggedIn) { @@ -72,19 +87,48 @@ class LayoutContainer extends Component { } } +LayoutContainer.propTypes = { + children: PropTypes.node, + requestPasswordReset: PropTypes.func, + handleLogin: PropTypes.func, + auth: PropTypes.object, + handleLogout: PropTypes.func, + logout: PropTypes.func, + toggleShortcutModal: PropTypes.func, + TALK_RECAPTCHA_PUBLIC: PropTypes.string, + checkLogin: PropTypes.func, + fetchConfig: PropTypes.func, + root: PropTypes.object.isRequired, + data: PropTypes.object.isRequired, +}; + +const withData = withQuery(gql` + query TalkAdmin_initialQuery { + ...${getDefinitionName(Community.fragments.root)} + } + ${Community.fragments.root} + `, { + options: { + fetchPolicy: 'network-only', + }, +}); + const mapStateToProps = (state) => ({ auth: state.auth, TALK_RECAPTCHA_PUBLIC: state.config.data.TALK_RECAPTCHA_PUBLIC, }); -const mapDispatchToProps = (dispatch) => ({ - checkLogin: () => dispatch(checkLogin()), - fetchConfig: () => dispatch(fetchConfig()), - handleLogin: (username, password, recaptchaResponse) => - dispatch(handleLogin(username, password, recaptchaResponse)), - requestPasswordReset: (email) => dispatch(requestPasswordReset(email)), - toggleShortcutModal: (toggle) => dispatch(toggleShortcutModal(toggle)), - handleLogout: () => dispatch(logout()) -}); +const mapDispatchToProps = (dispatch) => + bindActionCreators({ + checkLogin, + fetchConfig, + handleLogin, + requestPasswordReset, + toggleShortcutModal, + logout + }, dispatch); -export default connect(mapStateToProps, mapDispatchToProps)(LayoutContainer); +export default compose( + connect(mapStateToProps, mapDispatchToProps), + withData +)(LayoutContainer); diff --git a/client/coral-admin/src/routes/Community/components/Community.js b/client/coral-admin/src/routes/Community/components/Community.js index bf300a166..41bca2529 100644 --- a/client/coral-admin/src/routes/Community/components/Community.js +++ b/client/coral-admin/src/routes/Community/components/Community.js @@ -94,7 +94,7 @@ export default class Community extends Component { render() { const {searchValue} = this.state; const tab = this.getTabContent(searchValue, this.props); - const {root: {flaggedUsernamesCount}} = this.props; + const {root: {flaggedUsernamesCount = 0}} = this.props; return (
diff --git a/client/coral-admin/src/routes/Community/components/CommunityLayout.js b/client/coral-admin/src/routes/Community/components/CommunityLayout.js deleted file mode 100644 index 0665b967d..000000000 --- a/client/coral-admin/src/routes/Community/components/CommunityLayout.js +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react'; - -const CommunityLayout = (props) => ( -
- {props.children} -
-); - -export default CommunityLayout; diff --git a/client/coral-admin/src/routes/Community/containers/Community.js b/client/coral-admin/src/routes/Community/containers/Community.js index 445b7f413..0356762d4 100644 --- a/client/coral-admin/src/routes/Community/containers/Community.js +++ b/client/coral-admin/src/routes/Community/containers/Community.js @@ -1,16 +1,14 @@ 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 PropTypes from 'prop-types'; - +import {compose, gql} from 'react-apollo'; +import {withFragments} from 'plugin-api/beta/client/hocs'; +import {getDefinitionName} from 'coral-framework/utils'; +import {withSetUserStatus, withRejectUsername} from 'coral-framework/graphql/mutations'; 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, @@ -56,28 +54,6 @@ CommunityContainer.propTypes = { root: PropTypes.object }; -const withData = withQuery(gql` - query TalkAdmin_FlaggedUsernamesCount { - flaggedUsernamesCount: userCount(query: { - action_type: FLAG, - statuses: [PENDING] - }) - ...${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', - }, -}); - const mapDispatchToProps = (dispatch) => bindActionCreators({ fetchAccounts, @@ -90,5 +66,22 @@ export default compose( connect(mapStateToProps, mapDispatchToProps), withSetUserStatus, withRejectUsername, - withData, + withFragments({ + root: gql` + fragment TalkAdmin_Community on RootQuery { + flaggedUsernamesCount: userCount(query: { + action_type: FLAG, + statuses: [PENDING] + }) + ...${getDefinitionName(FlaggedAccounts.fragments.root)} + ...${getDefinitionName(FlaggedUser.fragments.root)} + me { + ...${getDefinitionName(FlaggedUser.fragments.me)} + __typename + } + } + ${FlaggedAccounts.fragments.root} + ${FlaggedUser.fragments.root} + ${FlaggedUser.fragments.me} + `}), )(CommunityContainer); diff --git a/client/coral-admin/src/routes/Community/index.js b/client/coral-admin/src/routes/Community/index.js deleted file mode 100644 index 528fe63cd..000000000 --- a/client/coral-admin/src/routes/Community/index.js +++ /dev/null @@ -1,2 +0,0 @@ -export {default as Community} from './containers/Community'; -export {default as CommunityLayout} from './components/CommunityLayout'; From 3b6bcba05506f4ae1a2a56a155b52f16ed5a9118 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Fri, 22 Sep 2017 17:25:59 -0300 Subject: [PATCH 2/7] Indicator for Community --- client/coral-admin/src/components/ui/Header.js | 8 +++++++- .../src/components/ui/Indicator.css | 10 ++++++++++ .../coral-admin/src/components/ui/Indicator.js | 7 +++++++ client/coral-admin/src/components/ui/Layout.js | 18 ++++++++++++++---- client/coral-admin/src/components/ui/Logo.js | 5 +++++ client/coral-admin/src/containers/Layout.js | 5 +++-- 6 files changed, 46 insertions(+), 7 deletions(-) create mode 100644 client/coral-admin/src/components/ui/Indicator.css create mode 100644 client/coral-admin/src/components/ui/Indicator.js diff --git a/client/coral-admin/src/components/ui/Header.js b/client/coral-admin/src/components/ui/Header.js index 74dc85a17..f6a467677 100644 --- a/client/coral-admin/src/components/ui/Header.js +++ b/client/coral-admin/src/components/ui/Header.js @@ -6,11 +6,13 @@ import styles from './Header.css'; import t from 'coral-framework/services/i18n'; import {Logo} from './Logo'; import {can} from 'coral-framework/services/perms'; +import Indicator from './Indicator'; const CoralHeader = ({ handleLogout, showShortcuts = () => {}, - auth + auth, + root, }) => (
@@ -33,6 +35,7 @@ const CoralHeader = ({ to="/admin/moderate" activeClassName={styles.active}> {t('configure.moderate')} + ) } @@ -43,13 +46,16 @@ const CoralHeader = ({ activeClassName={styles.active}> {t('configure.stories')} + {t('configure.community')} + {root.flaggedUsernamesCount !== 0 && } + { can(auth.user, 'UPDATE_CONFIG') && ( + ; + +export default Indicator; diff --git a/client/coral-admin/src/components/ui/Layout.js b/client/coral-admin/src/components/ui/Layout.js index 3aa056d9e..2e0c69228 100644 --- a/client/coral-admin/src/components/ui/Layout.js +++ b/client/coral-admin/src/components/ui/Layout.js @@ -8,15 +8,22 @@ import styles from './Layout.css'; const Layout = ({ children, handleLogout = () => {}, - toggleShortcutModal, + toggleShortcutModal = () => {}, restricted = false, - ...props}) => ( + root, + auth, +}) => (
- + root={root} + auth={auth} + /> +
{children}
@@ -24,6 +31,9 @@ const Layout = ({ ); Layout.propTypes = { + children: PropTypes.node, + auth: PropTypes.object, + root: PropTypes.object, handleLogout: PropTypes.func, toggleShortcutModal: PropTypes.func, restricted: PropTypes.bool // hide elements from a user that's logged out diff --git a/client/coral-admin/src/components/ui/Logo.js b/client/coral-admin/src/components/ui/Logo.js index 8c57cde11..2538a0716 100644 --- a/client/coral-admin/src/components/ui/Logo.js +++ b/client/coral-admin/src/components/ui/Logo.js @@ -1,6 +1,7 @@ import React from 'react'; import styles from './Logo.css'; import {CoralLogo} from 'coral-ui'; +import PropTypes from 'prop-types'; export const Logo = ({className = ''}) => (
@@ -10,3 +11,7 @@ export const Logo = ({className = ''}) => (
); + +Logo.propTypes = { + className: PropTypes.string +}; diff --git a/client/coral-admin/src/containers/Layout.js b/client/coral-admin/src/containers/Layout.js index e97f64b8a..b1784d0a1 100644 --- a/client/coral-admin/src/containers/Layout.js +++ b/client/coral-admin/src/containers/Layout.js @@ -25,6 +25,7 @@ class LayoutContainer extends Component { checkLogin(); fetchConfig(); } + render() { const { @@ -65,8 +66,8 @@ class LayoutContainer extends Component { + root={this.props.root} + auth={this.props.auth} > From 86687f10d80a638d1dde8a2972f5b5dae34c4d2f Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Fri, 22 Sep 2017 17:38:46 -0300 Subject: [PATCH 3/7] Working indicators --- client/coral-admin/src/components/ui/Header.js | 2 +- client/coral-admin/src/containers/Header.js | 16 ++++++++++++++++ client/coral-admin/src/containers/Layout.js | 3 +++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 client/coral-admin/src/containers/Header.js diff --git a/client/coral-admin/src/components/ui/Header.js b/client/coral-admin/src/components/ui/Header.js index f6a467677..ac67430e5 100644 --- a/client/coral-admin/src/components/ui/Header.js +++ b/client/coral-admin/src/components/ui/Header.js @@ -35,7 +35,7 @@ const CoralHeader = ({ to="/admin/moderate" activeClassName={styles.active}> {t('configure.moderate')} - + {(root.premodCount !== 0 || root.reportedCount !== 0) && } ) } diff --git a/client/coral-admin/src/containers/Header.js b/client/coral-admin/src/containers/Header.js new file mode 100644 index 000000000..1c95923f8 --- /dev/null +++ b/client/coral-admin/src/containers/Header.js @@ -0,0 +1,16 @@ +import {gql} from 'react-apollo'; +import withFragments from 'coral-framework/hocs/withFragments'; +import Header from '../components/ui/Header'; + +export default withFragments({ + root: gql` + fragment TalkAdmin_Header on RootQuery { + premodCount: commentCount(query: {statuses: [PREMOD]}) + reportedCount: commentCount(query: {statuses: [NONE, PREMOD, SYSTEM_WITHHELD], action_type: FLAG}) + flaggedUsernamesCount: userCount(query: { + action_type: FLAG, + statuses: [PENDING] + }) + } + ` +})(Header); diff --git a/client/coral-admin/src/containers/Layout.js b/client/coral-admin/src/containers/Layout.js index b1784d0a1..775e54745 100644 --- a/client/coral-admin/src/containers/Layout.js +++ b/client/coral-admin/src/containers/Layout.js @@ -17,6 +17,7 @@ import withQuery from 'coral-framework/hocs/withQuery'; import {bindActionCreators} from 'redux'; import {getDefinitionName} from 'coral-framework/utils'; import Community from '../routes/Community/containers/Community'; +import Header from '../containers/Header'; class LayoutContainer extends Component { componentWillMount() { @@ -105,8 +106,10 @@ LayoutContainer.propTypes = { const withData = withQuery(gql` query TalkAdmin_initialQuery { + ...${getDefinitionName(Header.fragments.root)} ...${getDefinitionName(Community.fragments.root)} } + ${Header.fragments.root} ${Community.fragments.root} `, { options: { From 19e23479eed5d3ba3567f35528e9dfcc4186265e Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Fri, 22 Sep 2017 17:45:28 -0300 Subject: [PATCH 4/7] Showing the indicators --- client/coral-admin/src/components/ui/Header.js | 4 ++-- .../coral-admin/src/routes/Community/components/Community.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/coral-admin/src/components/ui/Header.js b/client/coral-admin/src/components/ui/Header.js index ac67430e5..40a22b7c0 100644 --- a/client/coral-admin/src/components/ui/Header.js +++ b/client/coral-admin/src/components/ui/Header.js @@ -35,7 +35,7 @@ const CoralHeader = ({ to="/admin/moderate" activeClassName={styles.active}> {t('configure.moderate')} - {(root.premodCount !== 0 || root.reportedCount !== 0) && } + {(root.premodCount || root.reportedCount) && } ) } @@ -53,7 +53,7 @@ const CoralHeader = ({ to="/admin/community" activeClassName={styles.active}> {t('configure.community')} - {root.flaggedUsernamesCount !== 0 && } + {root.flaggedUsernamesCount && } { diff --git a/client/coral-admin/src/routes/Community/components/Community.js b/client/coral-admin/src/routes/Community/components/Community.js index 41bca2529..bf300a166 100644 --- a/client/coral-admin/src/routes/Community/components/Community.js +++ b/client/coral-admin/src/routes/Community/components/Community.js @@ -94,7 +94,7 @@ export default class Community extends Component { render() { const {searchValue} = this.state; const tab = this.getTabContent(searchValue, this.props); - const {root: {flaggedUsernamesCount = 0}} = this.props; + const {root: {flaggedUsernamesCount}} = this.props; return (
From e6f18d85585a3680e0a2e81049e749a3898d133f Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 25 Sep 2017 13:49:26 -0300 Subject: [PATCH 5/7] Updates --- .../coral-admin/src/components/ui/Header.js | 179 +++++++++--------- .../coral-admin/src/components/ui/Layout.js | 5 +- client/coral-admin/src/containers/Header.js | 30 +-- client/coral-admin/src/containers/Layout.js | 42 +--- .../routes/Community/containers/Community.js | 39 ++-- 5 files changed, 136 insertions(+), 159 deletions(-) diff --git a/client/coral-admin/src/components/ui/Header.js b/client/coral-admin/src/components/ui/Header.js index 40a22b7c0..30c5fa7e6 100644 --- a/client/coral-admin/src/components/ui/Header.js +++ b/client/coral-admin/src/components/ui/Header.js @@ -12,101 +12,104 @@ const CoralHeader = ({ handleLogout, showShortcuts = () => {}, auth, - root, -}) => ( -
- -
- { - auth && auth.user && can(auth.user, 'ACCESS_ADMIN') ? - - - {t('configure.dashboard')} - - { - can(auth.user, 'MODERATE_COMMENTS') && ( - - {t('configure.moderate')} - {(root.premodCount || root.reportedCount) && } - - ) - } - - {t('configure.stories')} - + root +}) => { + return ( +
+ +
+ { + auth && auth.user && can(auth.user, 'ACCESS_ADMIN') ? + + + {t('configure.dashboard')} + + { + can(auth.user, 'MODERATE_COMMENTS') && ( + + {t('configure.moderate')} + {(root.premodCount !== 0 || root.reportedCount !== 0) && } + + ) + } + + {t('configure.stories')} + - - {t('configure.community')} - {root.flaggedUsernamesCount && } - + + {t('configure.community')} + {root.flaggedUsernamesCount !== 0 && } + - { - can(auth.user, 'UPDATE_CONFIG') && ( - - {t('configure.configure')} - - ) - } - - : - null - } -
- + { + can(auth.user, 'UPDATE_CONFIG') && ( + + {t('configure.configure')} + + ) + } + + : + null + } +
+ +
-
-
-); +
+ ); +}; CoralHeader.propTypes = { auth: PropTypes.object, showShortcuts: PropTypes.func, - handleLogout: PropTypes.func.isRequired + handleLogout: PropTypes.func.isRequired, + root: PropTypes.object.isRequired }; export default CoralHeader; diff --git a/client/coral-admin/src/components/ui/Layout.js b/client/coral-admin/src/components/ui/Layout.js index 2e0c69228..9ee9fda9f 100644 --- a/client/coral-admin/src/components/ui/Layout.js +++ b/client/coral-admin/src/components/ui/Layout.js @@ -1,7 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import {Layout as LayoutMDL} from 'react-mdl'; -import Header from './Header'; +import Header from '../../containers/Header'; import Drawer from './Drawer'; import styles from './Layout.css'; @@ -10,14 +10,12 @@ const Layout = ({ handleLogout = () => {}, toggleShortcutModal = () => {}, restricted = false, - root, auth, }) => (
- {cloneElement(children, { - root: this.props.root, - data: this.props.data - })} + {children} ); } else if (loggedIn) { @@ -99,24 +89,9 @@ LayoutContainer.propTypes = { toggleShortcutModal: PropTypes.func, TALK_RECAPTCHA_PUBLIC: PropTypes.string, checkLogin: PropTypes.func, - fetchConfig: PropTypes.func, - root: PropTypes.object.isRequired, - data: PropTypes.object.isRequired, + fetchConfig: PropTypes.func }; -const withData = withQuery(gql` - query TalkAdmin_initialQuery { - ...${getDefinitionName(Header.fragments.root)} - ...${getDefinitionName(Community.fragments.root)} - } - ${Header.fragments.root} - ${Community.fragments.root} - `, { - options: { - fetchPolicy: 'network-only', - }, -}); - const mapStateToProps = (state) => ({ auth: state.auth, TALK_RECAPTCHA_PUBLIC: state.config.data.TALK_RECAPTCHA_PUBLIC, @@ -131,8 +106,5 @@ const mapDispatchToProps = (dispatch) => toggleShortcutModal, logout }, dispatch); - -export default compose( - connect(mapStateToProps, mapDispatchToProps), - withData -)(LayoutContainer); + +export default connect(mapStateToProps, mapDispatchToProps)(LayoutContainer); diff --git a/client/coral-admin/src/routes/Community/containers/Community.js b/client/coral-admin/src/routes/Community/containers/Community.js index 0356762d4..ecdac62dd 100644 --- a/client/coral-admin/src/routes/Community/containers/Community.js +++ b/client/coral-admin/src/routes/Community/containers/Community.js @@ -3,7 +3,7 @@ import {connect} from 'react-redux'; import {bindActionCreators} from 'redux'; import PropTypes from 'prop-types'; import {compose, gql} from 'react-apollo'; -import {withFragments} from 'plugin-api/beta/client/hocs'; +import withQuery from 'coral-framework/hocs/withQuery'; import {getDefinitionName} from 'coral-framework/utils'; import {withSetUserStatus, withRejectUsername} from 'coral-framework/graphql/mutations'; import FlaggedAccounts from '../containers/FlaggedAccounts'; @@ -62,26 +62,27 @@ const mapDispatchToProps = (dispatch) => newPage, }, dispatch); +const withData = withQuery(gql` + query TalkAdmin_FlaggedUsernamesCount { + flaggedUsernamesCount: userCount(query: { + action_type: FLAG, + statuses: [PENDING] + }) + ...${getDefinitionName(FlaggedAccounts.fragments.root)} + ...${getDefinitionName(FlaggedUser.fragments.root)} + me { + ...${getDefinitionName(FlaggedUser.fragments.me)} + __typename + } + } + ${FlaggedAccounts.fragments.root} + ${FlaggedUser.fragments.root} + ${FlaggedUser.fragments.me} +`); + export default compose( connect(mapStateToProps, mapDispatchToProps), withSetUserStatus, withRejectUsername, - withFragments({ - root: gql` - fragment TalkAdmin_Community on RootQuery { - flaggedUsernamesCount: userCount(query: { - action_type: FLAG, - statuses: [PENDING] - }) - ...${getDefinitionName(FlaggedAccounts.fragments.root)} - ...${getDefinitionName(FlaggedUser.fragments.root)} - me { - ...${getDefinitionName(FlaggedUser.fragments.me)} - __typename - } - } - ${FlaggedAccounts.fragments.root} - ${FlaggedUser.fragments.root} - ${FlaggedUser.fragments.me} - `}), + withData )(CommunityContainer); From 3db406bf261b9ada9c2efa92b2882ed5aba56816 Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Tue, 26 Sep 2017 03:31:04 +0700 Subject: [PATCH 6/7] Rename Community Query --- client/coral-admin/src/graphql/index.js | 4 ++-- .../coral-admin/src/routes/Community/containers/Community.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/coral-admin/src/graphql/index.js b/client/coral-admin/src/graphql/index.js index 8fedf6ebe..6b8aa7456 100644 --- a/client/coral-admin/src/graphql/index.js +++ b/client/coral-admin/src/graphql/index.js @@ -4,7 +4,7 @@ export default { mutations: { SetUserStatus: ({variables: {status, userId}}) => ({ updateQueries: { - TalkAdmin_FlaggedAccounts: (prev) => { + TalkAdmin_Community: (prev) => { if (status !== 'APPROVED') { return prev; } @@ -19,7 +19,7 @@ export default { }), RejectUsername: ({variables: {input: {id: userId}}}) => ({ updateQueries: { - TalkAdmin_FlaggedAccounts: (prev) => { + TalkAdmin_Community: (prev) => { const updated = update(prev, { users: { nodes: {$apply: (nodes) => nodes.filter((node) => node.id !== userId)}, diff --git a/client/coral-admin/src/routes/Community/containers/Community.js b/client/coral-admin/src/routes/Community/containers/Community.js index ecdac62dd..4e60c64d7 100644 --- a/client/coral-admin/src/routes/Community/containers/Community.js +++ b/client/coral-admin/src/routes/Community/containers/Community.js @@ -25,7 +25,7 @@ class CommunityContainer extends Component { } render() { - return }, dispatch); const withData = withQuery(gql` - query TalkAdmin_FlaggedUsernamesCount { + query TalkAdmin_Community { flaggedUsernamesCount: userCount(query: { action_type: FLAG, statuses: [PENDING] From bea7d75db7f226d8f63f210d0da96d771cc01792 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 26 Sep 2017 12:42:39 -0300 Subject: [PATCH 7/7] Polling to update the Header Indicator --- client/coral-admin/src/containers/Header.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/coral-admin/src/containers/Header.js b/client/coral-admin/src/containers/Header.js index 4ac75f8ba..a5c1f0afc 100644 --- a/client/coral-admin/src/containers/Header.js +++ b/client/coral-admin/src/containers/Header.js @@ -17,4 +17,8 @@ export default withQuery(gql` statuses: [PENDING] }) } -`)(Header); +`, { + options: { + pollInterval: 5000 + } + })(Header);