refactor: global namespace + admin pages UI
This commit is contained in:
53
server/graph/resolvers/right.js
Normal file
53
server/graph/resolvers/right.js
Normal file
@@ -0,0 +1,53 @@
|
||||
|
||||
/* global WIKI */
|
||||
|
||||
const gql = require('graphql')
|
||||
|
||||
module.exports = {
|
||||
Query: {
|
||||
rights(obj, args, context, info) {
|
||||
return WIKI.db.Right.findAll({ where: args })
|
||||
}
|
||||
},
|
||||
Mutation: {
|
||||
addRightToGroup(obj, args) {
|
||||
return WIKI.db.Group.findById(args.groupId).then(grp => {
|
||||
if (!grp) {
|
||||
throw new gql.GraphQLError('Invalid Group ID')
|
||||
}
|
||||
return WIKI.db.Right.create({
|
||||
path: args.path,
|
||||
role: args.role,
|
||||
exact: args.exact,
|
||||
allow: args.allow,
|
||||
group: grp
|
||||
})
|
||||
})
|
||||
},
|
||||
removeRightFromGroup(obj, args) {
|
||||
return WIKI.db.Right.destroy({
|
||||
where: {
|
||||
id: args.rightId
|
||||
},
|
||||
limit: 1
|
||||
})
|
||||
},
|
||||
modifyRight(obj, args) {
|
||||
return WIKI.db.Right.update({
|
||||
path: args.path,
|
||||
role: args.role,
|
||||
exact: args.exact,
|
||||
allow: args.allow
|
||||
}, {
|
||||
where: {
|
||||
id: args.id
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
Right: {
|
||||
group(rt) {
|
||||
return rt.getGroup()
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user