diff --git a/ui/src/admin/components/chronograf/UsersTable.js b/ui/src/admin/components/chronograf/UsersTable.js
index 9da6c5d8ea..10656c0415 100644
--- a/ui/src/admin/components/chronograf/UsersTable.js
+++ b/ui/src/admin/components/chronograf/UsersTable.js
@@ -2,8 +2,6 @@ import React, {Component, PropTypes} from 'react'
import uuid from 'node-uuid'
-import Authorized, {SUPERADMIN_ROLE} from 'src/auth/Authorized'
-
import UsersTableHeader from 'src/admin/components/chronograf/UsersTableHeader'
import UsersTableRowNew from 'src/admin/components/chronograf/UsersTableRowNew'
import UsersTableRow from 'src/admin/components/chronograf/UsersTableRow'
@@ -23,10 +21,6 @@ class UsersTable extends Component {
this.props.onUpdateUserRole(user, currentRole, newRole)
}
- handleChangeSuperAdmin = user => newStatus => {
- this.props.onUpdateUserSuperAdmin(user, newStatus)
- }
-
handleDeleteUser = user => {
this.props.onDeleteUser(user)
}
@@ -43,13 +37,7 @@ class UsersTable extends Component {
const {organization, users, onCreateUser, meID, notify} = this.props
const {isCreatingUser} = this.state
- const {
- colRole,
- colSuperAdmin,
- colProvider,
- colScheme,
- colActions,
- } = USERS_TABLE
+ const {colRole, colProvider, colScheme, colActions} = USERS_TABLE
return (
@@ -67,11 +55,6 @@ class UsersTable extends Component {
Role
|
-
-
- SuperAdmin
- |
-
Provider |
Scheme |
|
@@ -93,24 +76,14 @@ class UsersTable extends Component {
key={uuid.v4()}
organization={organization}
onChangeUserRole={this.handleChangeUserRole}
- onChangeSuperAdmin={this.handleChangeSuperAdmin}
onDelete={this.handleDeleteUser}
meID={meID}
/>
)
:
-
- No Users to display
-
- }
- >
-
- No Users to display
- |
-
+
+ No Users to display
+ |
}
@@ -120,7 +93,7 @@ class UsersTable extends Component {
}
}
-const {arrayOf, bool, func, shape, string} = PropTypes
+const {arrayOf, func, shape, string} = PropTypes
UsersTable.propTypes = {
users: arrayOf(
@@ -138,7 +111,6 @@ UsersTable.propTypes = {
})
),
scheme: string.isRequired,
- superAdmin: bool,
})
).isRequired,
organization: shape({
@@ -147,7 +119,6 @@ UsersTable.propTypes = {
}),
onCreateUser: func.isRequired,
onUpdateUserRole: func.isRequired,
- onUpdateUserSuperAdmin: func.isRequired,
onDeleteUser: func.isRequired,
meID: string.isRequired,
notify: func.isRequired,
diff --git a/ui/src/admin/components/chronograf/UsersTableRow.js b/ui/src/admin/components/chronograf/UsersTableRow.js
index 561ca99684..ca02b56d60 100644
--- a/ui/src/admin/components/chronograf/UsersTableRow.js
+++ b/ui/src/admin/components/chronograf/UsersTableRow.js
@@ -1,9 +1,6 @@
import React, {PropTypes} from 'react'
-import Authorized, {SUPERADMIN_ROLE} from 'src/auth/Authorized'
-
import Dropdown from 'shared/components/Dropdown'
-import SlideToggle from 'shared/components/SlideToggle'
import DeleteConfirmTableCell from 'shared/components/DeleteConfirmTableCell'
import {USER_ROLES} from 'src/admin/constants/chronografAdmin'
@@ -13,11 +10,10 @@ const UsersTableRow = ({
user,
organization,
onChangeUserRole,
- onChangeSuperAdmin,
onDelete,
meID,
}) => {
- const {colRole, colSuperAdmin, colProvider, colScheme} = USERS_TABLE
+ const {colRole, colProvider, colScheme} = USERS_TABLE
const dropdownRolesItems = USER_ROLES.map(r => ({
...r,
@@ -53,16 +49,6 @@ const UsersTableRow = ({
/>
-
-
-
- |
-
{user.provider}
|
@@ -89,7 +75,6 @@ UsersTableRow.propTypes = {
id: string.isRequired,
}),
onChangeUserRole: func.isRequired,
- onChangeSuperAdmin: func.isRequired,
onDelete: func.isRequired,
meID: string.isRequired,
}
diff --git a/ui/src/admin/components/chronograf/UsersTableRowNew.js b/ui/src/admin/components/chronograf/UsersTableRowNew.js
index 7b63c3e46c..4af835e089 100644
--- a/ui/src/admin/components/chronograf/UsersTableRowNew.js
+++ b/ui/src/admin/components/chronograf/UsersTableRowNew.js
@@ -1,7 +1,5 @@
import React, {Component, PropTypes} from 'react'
-import Authorized, {SUPERADMIN_ROLE} from 'src/auth/Authorized'
-
import Dropdown from 'shared/components/Dropdown'
import {USERS_TABLE} from 'src/admin/constants/chronografTableSizing'
@@ -25,13 +23,12 @@ class UsersTableRowNew extends Component {
handleConfirmCreateUser = () => {
const {onBlur, onCreateUser, organization} = this.props
- const {name, provider, scheme, role, superAdmin} = this.state
+ const {name, provider, scheme, role} = this.state
const newUser = {
name,
provider,
scheme,
- superAdmin,
roles: [
{
name: role,
@@ -72,13 +69,7 @@ class UsersTableRowNew extends Component {
}
render() {
- const {
- colRole,
- colProvider,
- colScheme,
- colSuperAdmin,
- colActions,
- } = USERS_TABLE
+ const {colRole, colProvider, colScheme, colActions} = USERS_TABLE
const {onBlur} = this.props
const {name, provider, scheme, role} = this.state
@@ -108,11 +99,6 @@ class UsersTableRowNew extends Component {
className="dropdown-stretch"
/>
-
-
- —
- |
-
{
+ const {links, actions: {createUserAsync}} = this.props
+ createUserAsync(links.users, user)
+ }
+
+ handleUpdateUserRole = (user, currentRole, {name}) => {
+ const {actions: {updateUserAsync}} = this.props
+ const updatedRole = {...currentRole, name}
+ const newRoles = user.roles.map(
+ r => (r.organization === currentRole.organization ? updatedRole : r)
+ )
+ updateUserAsync(user, {...user, roles: newRoles})
+ }
+
+ handleUpdateUserSuperAdmin = (user, superAdmin) => {
+ const {actions: {updateUserAsync}} = this.props
+ const updatedUser = {...user, superAdmin}
+ updateUserAsync(user, updatedUser)
+ }
+
+ handleDeleteUser = user => {
+ const {actions: {deleteUserAsync}} = this.props
+ deleteUserAsync(user)
+ }
+
+ async componentWillMount() {
+ const {
+ links,
+ actions: {loadOrganizationsAsync, loadUsersAsync},
+ } = this.props
+
+ this.setState({isLoading: true})
+
+ await Promise.all([
+ loadOrganizationsAsync(links.organizations),
+ loadUsersAsync(links.users),
+ ])
+
+ this.setState({isLoading: false})
+ }
+
+ render() {
+ const {
+ meCurrentOrganization,
+ organizations,
+ meID,
+ users,
+ notify,
+ } = this.props
+ const {isLoading} = this.state
+
+ if (isLoading) {
+ return
+ }
+
+ const organization = organizations.find(
+ o => o.id === meCurrentOrganization.id
+ )
+
+ return (
+
+ )
+ }
+}
+
+const {arrayOf, func, shape, string} = PropTypes
+
+AllUsersPage.propTypes = {
+ links: shape({
+ users: string.isRequired,
+ }),
+ meID: string.isRequired,
+ meCurrentOrganization: shape({
+ id: string.isRequired,
+ name: string.isRequired,
+ }).isRequired,
+ users: arrayOf(shape),
+ organizations: arrayOf(shape),
+ actions: shape({
+ loadUsersAsync: func.isRequired,
+ loadOrganizationsAsync: func.isRequired,
+ createUserAsync: func.isRequired,
+ updateUserAsync: func.isRequired,
+ deleteUserAsync: func.isRequired,
+ }),
+ notify: func.isRequired,
+}
+
+const mapStateToProps = ({links, adminChronograf: {organizations, users}}) => ({
+ links,
+ organizations,
+ users,
+})
+
+const mapDispatchToProps = dispatch => ({
+ actions: bindActionCreators(adminChronografActionCreators, dispatch),
+ notify: bindActionCreators(publishAutoDismissingNotification, dispatch),
+})
+
+export default connect(mapStateToProps, mapDispatchToProps)(AllUsersPage)
diff --git a/ui/src/admin/containers/chronograf/UsersPage.js b/ui/src/admin/containers/chronograf/UsersPage.js
index a8d21a051c..2da41d7a07 100644
--- a/ui/src/admin/containers/chronograf/UsersPage.js
+++ b/ui/src/admin/containers/chronograf/UsersPage.js
@@ -31,12 +31,6 @@ class UsersPage extends Component {
updateUserAsync(user, {...user, roles: newRoles})
}
- handleUpdateUserSuperAdmin = (user, superAdmin) => {
- const {actions: {updateUserAsync}} = this.props
- const updatedUser = {...user, superAdmin}
- updateUserAsync(user, updatedUser)
- }
-
handleDeleteUser = user => {
const {actions: {deleteUserAsync}} = this.props
deleteUserAsync(user)
@@ -83,7 +77,6 @@ class UsersPage extends Component {
organization={organization}
onCreateUser={this.handleCreateUser}
onUpdateUserRole={this.handleUpdateUserRole}
- onUpdateUserSuperAdmin={this.handleUpdateUserSuperAdmin}
onDeleteUser={this.handleDeleteUser}
notify={notify}
/>
|