From 31112b3a201b55a136d27be73dfd6621fba227cf Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 31 Jul 2017 12:36:58 -0300 Subject: [PATCH] Passing to the container --- client/coral-admin/src/AppRouter.js | 6 ++-- .../Moderation/components/Moderation.js | 29 ++----------------- .../Moderation/containers/Moderation.js | 17 +++++++++-- 3 files changed, 22 insertions(+), 30 deletions(-) diff --git a/client/coral-admin/src/AppRouter.js b/client/coral-admin/src/AppRouter.js index 2cb4efcb6..de98a9722 100644 --- a/client/coral-admin/src/AppRouter.js +++ b/client/coral-admin/src/AppRouter.js @@ -35,8 +35,7 @@ const routes = ( {/* Moderation Routes */} - - + @@ -56,6 +55,9 @@ const routes = ( + + + diff --git a/client/coral-admin/src/routes/Moderation/components/Moderation.js b/client/coral-admin/src/routes/Moderation/components/Moderation.js index 7c0c20f2c..851dc51de 100644 --- a/client/coral-admin/src/routes/Moderation/components/Moderation.js +++ b/client/coral-admin/src/routes/Moderation/components/Moderation.js @@ -20,17 +20,6 @@ export default class Moderation extends Component { } componentWillMount() { - const {router, root: {settings, reportedCount}} = this.props; - - // Will update the URL to premod or new based on the moderation of All Streams - // If there is a reported comments, reported queue has priority! - if (!router.params.id) { - const queue = isPremod(settings.moderation) ? 'premod' : 'new'; - router.push( - getModPath(reportedCount ? 'reported' : queue) - ); - } - const {toggleModal, singleView} = this.props; key('s', () => singleView()); @@ -42,19 +31,6 @@ export default class Moderation extends Component { key('d', this.moderate(true)); } - componentWillUpdate() { - const {router, route, root: {asset, reportedCount}} = this.props; - - // Will update the URL to premod or new based on the moderation of the *asset* - // If there is a reported comments, reported queue has priority! - if (route.path === ':id') { - const queue = isPremod(asset.settings.moderation) ? 'premod' : 'new'; - router.push( - getModPath(reportedCount ? 'reported' : queue, asset.id) - ); - } - } - onClose = () => { this.props.toggleModal(false); } @@ -83,7 +59,7 @@ export default class Moderation extends Component { } getComments = () => { - const {activeTab} = this.props; + const {root, activeTab} = this.props; return root[activeTab].nodes; } @@ -128,8 +104,9 @@ export default class Moderation extends Component { const {root, moderation, settings, viewUserDetail, hideUserDetail, activeTab, getModPath, ...props} = this.props; const assetId = this.props.params.id; const {asset} = root; - + console.log(activeTab) const comments = root[activeTab]; + let activeTabCount; switch(activeTab) { case 'all': diff --git a/client/coral-admin/src/routes/Moderation/containers/Moderation.js b/client/coral-admin/src/routes/Moderation/containers/Moderation.js index eb453f69c..c475e5037 100644 --- a/client/coral-admin/src/routes/Moderation/containers/Moderation.js +++ b/client/coral-admin/src/routes/Moderation/containers/Moderation.js @@ -9,6 +9,7 @@ import update from 'immutability-helper'; import truncate from 'lodash/truncate'; import NotFoundAsset from '../components/NotFoundAsset'; import {isPremod, getModPath} from '../../../utils'; +import {withRouter} from 'react-router'; import {withSetCommentStatus} from 'coral-framework/graphql/mutations'; import {handleCommentChange} from '../../../graphql/utils'; @@ -46,8 +47,8 @@ class ModerationContainer extends Component { const premod = !router.params.id ? settings.moderation : asset.settings.moderation; const queue = isPremod(premod) ? 'premod' : 'new'; - const activeTab = router.params.id ? queue : route.path; - + const activeTab = route.path && route.path !== ':id' ? route.path : queue; + return activeTab; } @@ -144,6 +145,17 @@ class ModerationContainer extends Component { if(this.props.data.variables.asset_id !== nextProps.data.variables.asset_id) { this.resubscribe(nextProps.data.variables); } + + // const {router, route, root: {asset, reportedCount}} = this.props; + + // // Will update the URL to premod or new based on the moderation of the *asset* + // // If there is a reported comments, reported queue has priority! + // if (route.path === ':id') { + // const queue = isPremod(asset.settings.moderation) ? 'premod' : 'new'; + // router.push( + // getModPath(reportedCount ? 'reported' : queue, asset.id) + // ); + // } } acceptComment = ({commentId}) => { @@ -467,6 +479,7 @@ const mapDispatchToProps = (dispatch) => ({ }); export default compose( + withRouter, connect(mapStateToProps, mapDispatchToProps), withSetCommentStatus, withQueueCountPolling,