Passing to the container

This commit is contained in:
Belen Curcio
2017-07-31 12:36:58 -03:00
parent 84391d9d69
commit 31112b3a20
3 changed files with 22 additions and 30 deletions
+4 -2
View File
@@ -35,8 +35,7 @@ const routes = (
{/* Moderation Routes */}
<Route path='moderate' component={ModerationLayout}>
<Route path=':id' components={Moderation} />
<IndexRedirect to=':id' />
<IndexRoute components={Moderation} />
<Route path='all' components={Moderation}>
<Route path=':id' components={Moderation} />
@@ -56,6 +55,9 @@ const routes = (
<Route path='reported' components={Moderation}>
<Route path=':id' components={Moderation} />
</Route>
<Route path=':id' components={Moderation} />
</Route>
</Route>
</div>
@@ -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':
@@ -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,