Perms and excludeIf

This commit is contained in:
Belen Curcio
2017-09-13 13:42:32 -03:00
parent 838a3bad2e
commit 0ae2919def
3 changed files with 14 additions and 2 deletions
+3
View File
@@ -10,13 +10,16 @@ module.exports = (user, perm) => {
case types.EDIT_COMMENT:
return true;
case types.ADD_COMMENT_TAG:
return check(user, ['ADMIN', 'MODERATOR', 'STAFF']);
case types.REMOVE_COMMENT_TAG:
return check(user, ['ADMIN', 'MODERATOR', 'STAFF']);
case types.UPDATE_USER_ROLES:
case types.REJECT_USERNAME:
case types.SET_USER_STATUS:
return check(user, ['ADMIN', 'MODERATOR']);
case types.SUSPEND_USER:
case types.SET_COMMENT_STATUS:
return check(user, ['ADMIN', 'MODERATOR']);
case types.UPDATE_CONFIG:
case types.UPDATE_SETTINGS:
case types.UPDATE_WORDLIST:
@@ -4,7 +4,7 @@ import {bindActionCreators} from 'redux';
import {getErrorMessages} from 'plugin-api/beta/client/utils';
import {notify} from 'plugin-api/beta/client/actions/notification';
import BanUserAction from '../components/BanUserAction';
import {connect, withSetCommentStatus, withSetUserStatus} from 'plugin-api/beta/client/hocs';
import {connect, withSetCommentStatus, withSetUserStatus, excludeIf} from 'plugin-api/beta/client/hocs';
class BanUserActionContainer extends React.Component {
@@ -53,7 +53,8 @@ const mapDispatchToProps = (dispatch) =>
const enhance = compose(
connect(null, mapDispatchToProps),
withSetCommentStatus,
withSetUserStatus
withSetUserStatus,
excludeIf(({root: {me}, comment}) => !me || me.id === comment.user.id),
);
export default enhance(BanUserActionContainer);
@@ -42,6 +42,7 @@ class ModerationActionsContainer extends React.Component {
}
render() {
console.log(this.props.root, this.props.comment)
return <ModerationActions
data={this.props.data}
root={this.props.root}
@@ -68,6 +69,13 @@ const mapDispatchToProps = (dispatch) =>
const enhance = compose(
connect(mapStateToProps, mapDispatchToProps),
withFragments({
root: gql`
fragment TalkModerationActions_root on RootQuery {
me {
id
}
}`
,
asset: gql`
fragment TalkModerationActions_asset on Asset {
id