diff --git a/ui/src/store/configureStore.js b/ui/src/store/configureStore.js index 6c9bda148..bf7f72abe 100644 --- a/ui/src/store/configureStore.js +++ b/ui/src/store/configureStore.js @@ -5,16 +5,16 @@ import makeQueryExecuter from 'src/shared/middleware/queryExecuter'; import resizeLayout from 'src/shared/middleware/resizeLayout'; import * as dataExplorerReducers from 'src/data_explorer/reducers'; import * as sharedReducers from 'src/shared/reducers'; +import adminReducer from 'src/users/reducers/admin'; import rulesReducer from 'src/kapacitor/reducers/rules'; import dashboardUI from 'src/dashboards/reducers/ui'; -import usersReducer from 'src/users/reducers/users'; import persistStateEnhancer from './persistStateEnhancer'; const rootReducer = combineReducers({ ...sharedReducers, ...dataExplorerReducers, + admin: adminReducer, rules: rulesReducer, - users: usersReducer, dashboardUI, }); diff --git a/ui/src/users/actions/index.js b/ui/src/users/actions/index.js index 43061298e..fbc391c8f 100644 --- a/ui/src/users/actions/index.js +++ b/ui/src/users/actions/index.js @@ -1,6 +1,6 @@ import {getUsers} from 'src/users/apis' -export const loadUsers = (users) => ({ +export const loadUsers = ({users}) => ({ type: 'LOAD_USERS', payload: { users, @@ -8,6 +8,6 @@ export const loadUsers = (users) => ({ }) export const loadUsersAsync = (url) => async (dispatch) => { - const users = await getUsers(url) - dispatch(loadUsers(users)) + const {data} = await getUsers(url) + dispatch(loadUsers(data)) } diff --git a/ui/src/users/components/UsersTable.js b/ui/src/users/components/UsersTable.js new file mode 100644 index 000000000..123b2c722 --- /dev/null +++ b/ui/src/users/components/UsersTable.js @@ -0,0 +1,42 @@ +import React, {PropTypes} from 'react' + +const UsersTable = ({users}) => ( +
+
+

Database Users

+
+
+ + + + + + + + { + users.map((u) => { + return
{u.name}
; + }) + } + +
User Name
+
+
+) + +const { + arrayOf, + shape, + string, +} = PropTypes + +UsersTable.propTypes = { + users: arrayOf(shape({ + name: string.isRequired, + roles: arrayOf(shape({ + name: string, + })), + })), +} + +export default UsersTable diff --git a/ui/src/users/containers/UsersPage.js b/ui/src/users/containers/UsersPage.js index 3d1a870a6..81f3264d5 100644 --- a/ui/src/users/containers/UsersPage.js +++ b/ui/src/users/containers/UsersPage.js @@ -2,6 +2,7 @@ import React, {Component, PropTypes} from 'react' import {connect} from 'react-redux'; import {bindActionCreators} from 'redux'; import {loadUsersAsync} from 'src/users/actions' +import UsersTable from 'src/users/components/UsersTable' class UsersPage extends Component { constructor(props) { @@ -14,13 +15,16 @@ class UsersPage extends Component { } render() { + const {users} = this.props + return ( -
Hello Users
+ ) } } const { + arrayOf, func, shape, string, @@ -33,12 +37,12 @@ UsersPage.propTypes = { users: string.isRequired, }), }).isRequired, - users: shape(), + users: arrayOf(shape()), loadUsers: func, } -const mapStateToProps = ({users}) => ({ - users, +const mapStateToProps = ({admin}) => ({ + users: admin.users, }) const mapDispatchToProps = (dispatch) => ({ diff --git a/ui/src/users/reducers/users.js b/ui/src/users/reducers/admin.js similarity index 54% rename from ui/src/users/reducers/users.js rename to ui/src/users/reducers/admin.js index 77bf7c16e..92d81121b 100644 --- a/ui/src/users/reducers/users.js +++ b/ui/src/users/reducers/admin.js @@ -1,4 +1,8 @@ -export default function users(state = {}, action) { +const initialState = { + users: [], +} + +export default function admin(state = initialState, action) { switch (action.type) { case 'LOAD_USERS': { return {...state, ...action.payload}