Update UserRoleDropdown getters

pull/3112/head
Andrew Watkins 2018-04-02 16:26:25 -07:00
parent 9ad3f50d3b
commit a3153e2003
2 changed files with 8 additions and 8 deletions

View File

@ -6,12 +6,12 @@ import _ from 'lodash'
import MultiSelectDropdown from 'src/shared/components/MultiSelectDropdown'
import {USERS_TABLE} from 'src/admin/constants/tableSizing'
import {User} from 'src/types/influxAdmin'
import {User, UserRole} from 'src/types/influxAdmin'
interface Props {
user: User
allRoles: any[]
onUpdateRoles: (user: User, roles: any[]) => void
onUpdateRoles: (user: User, roles: UserRole[]) => void
}
class UserRoleDropdown extends PureComponent<Props> {
@ -39,18 +39,18 @@ class UserRoleDropdown extends PureComponent<Props> {
onUpdateRoles(user, roles)
}
private get roles() {
const roles = _.get(this.props.user, 'roles', [])
return roles.map(r => ({name: r.name}))
private get roles(): UserRole[] {
const roles = _.get(this.props.user, 'roles', []) as UserRole[]
return roles.map(({name}) => ({name}))
}
private get rolesClass() {
private get rolesClass(): string {
return classnames(`dropdown-${USERS_TABLE.colRoles}`, {
'admin-table--multi-select-empty': !this.roles.length,
})
}
private get rolesLabel() {
private get rolesLabel(): string {
return this.roles.length ? '' : 'Select Roles'
}
}

View File

@ -1,4 +1,4 @@
interface UserRole {
export interface UserRole {
name: string
}