Routes taking :id

This commit is contained in:
Belen Curcio
2017-07-31 10:45:18 -03:00
parent dbc8f87683
commit 84391d9d69
3 changed files with 15 additions and 12 deletions
+3 -1
View File
@@ -35,7 +35,9 @@ const routes = (
{/* Moderation Routes */}
<Route path='moderate' component={ModerationLayout}>
<IndexRoute component={Moderation} />
<Route path=':id' components={Moderation} />
<IndexRedirect to=':id' />
<Route path='all' components={Moderation}>
<Route path=':id' components={Moderation} />
</Route>
@@ -83,14 +83,7 @@ export default class Moderation extends Component {
}
getComments = () => {
const {root, root: {asset, settings}, router, route} = this.props;
// Grab premod from asset or from settings
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} = this.props;
return root[activeTab].nodes;
}
@@ -8,7 +8,7 @@ import t from 'coral-framework/services/i18n';
import update from 'immutability-helper';
import truncate from 'lodash/truncate';
import NotFoundAsset from '../components/NotFoundAsset';
import {getModPath} from '../../../utils';
import {isPremod, getModPath} from '../../../utils';
import {withSetCommentStatus} from 'coral-framework/graphql/mutations';
import {handleCommentChange} from '../../../graphql/utils';
@@ -39,8 +39,16 @@ class ModerationContainer extends Component {
subscriptions = [];
get activeTab() {
const {route} = this.props;
return route.path === ':id' ? 'new' : route.path;
const {root: {asset, settings}, router, route} = this.props;
// Grab premod from asset or from settings
const premod = !router.params.id ? settings.moderation : asset.settings.moderation;
const queue = isPremod(premod) ? 'premod' : 'new';
const activeTab = router.params.id ? queue : route.path;
return activeTab;
}
subscribeToUpdates(variables = this.props.data.variables) {