Add permissions to redux store

pull/990/head
Andrew Watkins 2017-03-10 08:35:51 -08:00
parent db019f1395
commit 9a322d7b78
2 changed files with 26 additions and 1 deletions

View File

@ -5,6 +5,7 @@ import {
createUserSuccess,
editUser,
loadRoles,
loadPermissions,
deleteRole,
deleteUser,
filterRoles,
@ -12,10 +13,13 @@ import {
} from 'src/admin/actions'
let state = undefined
// Roles
const r1 = {name: 'role1'}
const r2 = {name: 'role2'}
const roles = [r1, r2]
// Users
const u1 = {
name: 'acidburn',
roles: [],
@ -29,7 +33,6 @@ const u2 = {
links: {self: '/chronograf/v1/sources/1/users/zerocool'},
}
const users = [u1, u2]
const newDefaultUser = {
name: '',
password: '',
@ -39,6 +42,11 @@ const newDefaultUser = {
isNew: true,
}
// Permissions
const global = {scope: 'all', allowed: ['p1', 'p2']}
const scoped = {scope: 'db1', allowed: ['p1', 'p3']}
const permissions = [global, scoped]
describe('Admin.Reducers', () => {
it('it can add a user', () => {
state = {
@ -165,4 +173,14 @@ describe('Admin.Reducers', () => {
expect(actual.users).to.deep.equal(expected.users)
})
// Permissions
it('it can load the permissions', () => {
const actual = reducer(state, loadPermissions({permissions}))
const expected = {
permissions,
}
expect(actual.permissions).to.deep.equal(expected.permissions)
})
})

View File

@ -26,6 +26,13 @@ export const loadRoles = ({roles}) => ({
},
})
export const loadPermissions = ({permissions}) => ({
type: 'LOAD_PERMISSIONS',
payload: {
permissions,
},
})
export const addUser = () => ({
type: 'ADD_USER',
})