Fix organization default role being stale on chrono users page
The 'currentOrganization' namespaced in the auth reducer does not get updated when chronograf organizations reducer gets updated. This results in temporary stale state until `/me` is hit and the 'me auth' state trickles through the application.pull/10616/head
parent
ac51c96c7f
commit
f7ef728a3b
|
@ -1,8 +1,11 @@
|
|||
import React, {Component, PropTypes} from 'react'
|
||||
import {connect} from 'react-redux'
|
||||
import {bindActionCreators} from 'redux'
|
||||
|
||||
import uuid from 'node-uuid'
|
||||
|
||||
import Authorized, {SUPERADMIN_ROLE} from 'src/auth/Authorized'
|
||||
import {getMeAsync} from 'shared/actions/auth'
|
||||
|
||||
import UsersTableHeader from 'src/admin/components/chronograf/UsersTableHeader'
|
||||
import UsersTableRowNew from 'src/admin/components/chronograf/UsersTableRowNew'
|
||||
|
@ -19,6 +22,12 @@ class UsersTable extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
// TODO: update the {me: currentOrganization} and {organizations: []} at the same time
|
||||
// updates the current organization.
|
||||
this.props.getMe({shouldResetMe: false})
|
||||
}
|
||||
|
||||
handleChangeUserRole = (user, currentRole) => newRole => {
|
||||
this.props.onUpdateUserRole(user, currentRole, newRole)
|
||||
}
|
||||
|
@ -134,5 +143,11 @@ UsersTable.propTypes = {
|
|||
onDeleteUser: func.isRequired,
|
||||
meID: string.isRequired,
|
||||
notify: func.isRequired,
|
||||
getMe: func.isRequired,
|
||||
}
|
||||
export default UsersTable
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
getMe: bindActionCreators(getMeAsync, dispatch),
|
||||
})
|
||||
|
||||
export default connect(null, mapDispatchToProps)(UsersTable)
|
||||
|
|
|
@ -7,7 +7,6 @@ import SlideToggle from 'shared/components/SlideToggle'
|
|||
|
||||
import {USERS_TABLE} from 'src/admin/constants/chronografTableSizing'
|
||||
import {USER_ROLES} from 'src/admin/constants/chronografAdmin'
|
||||
import {MEMBER_ROLE} from 'src/auth/Authorized'
|
||||
|
||||
class UsersTableRowNew extends Component {
|
||||
constructor(props) {
|
||||
|
@ -17,7 +16,7 @@ class UsersTableRowNew extends Component {
|
|||
name: '',
|
||||
provider: '',
|
||||
scheme: 'oauth2',
|
||||
role: MEMBER_ROLE,
|
||||
role: this.props.organization.defaultRole,
|
||||
superAdmin: false,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue