Revert "Add 'Join' button to the left of Organizations where a SuperAdmin has no role"

This reverts commit dffde0e5371ce82d2a3f2c785bdcdf43cf6a2c3b.
pull/10616/head
Jared Scheib 2017-12-15 11:42:18 -08:00
parent 34301cb371
commit 92c7dabf59
4 changed files with 12 additions and 98 deletions

View File

@ -29,12 +29,7 @@ const AdminTabs = ({
{
requiredRole: SUPERADMIN_ROLE,
type: ORGANIZATIONS_TAB_NAME,
component: (
<OrganizationsPage
currentOrganization={organization}
onCreateUser={onCreateUser} // allows a SuperAdmin to join organizations where they don't currently have a role
/>
),
component: <OrganizationsPage currentOrganization={organization} />,
},
{
requiredRole: ADMIN_ROLE,

View File

@ -45,7 +45,6 @@ class OrganizationsTable extends Component {
authConfig: {superAdminNewUsers},
onChangeAuthConfig,
me,
onCreateUser,
} = this.props
const {isCreatingOrganization} = this.state
@ -94,9 +93,7 @@ class OrganizationsTable extends Component {
onRename={onRenameOrg}
onChooseDefaultRole={onChooseDefaultRole}
currentOrganization={currentOrganization}
userHasRoleInOrg={!!me.organizations.find(o => org.id === o.id)}
me={me}
onCreateUser={onCreateUser}
userHasRole={!!me.organizations.find(o => org.id === o.id)}
/>
)}
<Authorized requiredRole={SUPERADMIN_ROLE}>
@ -150,16 +147,6 @@ OrganizationsTable.propTypes = {
superAdminNewUsers: bool,
}),
me: shape({
id: string.isRequired,
name: string.isRequired,
roles: arrayOf(
shape({
name: string.isRequired,
organization: string.isRequired,
})
),
provider: string.isRequired,
scheme: string.isRequired,
organizations: arrayOf(
shape({
id: string.isRequired,
@ -168,6 +155,5 @@ OrganizationsTable.propTypes = {
})
),
}),
onCreateUser: func.isRequired,
}
export default OrganizationsTable

View File

@ -11,26 +11,6 @@ import {meChangeOrganizationAsync} from 'shared/actions/auth'
import {DEFAULT_ORG_ID} from 'src/admin/constants/chronografAdmin'
import {USER_ROLES} from 'src/admin/constants/chronografAdmin'
import {ADMIN_ROLE} from 'src/auth/Authorized'
const AccessOrganizationButton = ({
userHasRoleInOrg,
handleChangeCurrentOrganization,
handleJoinOrganizationAsAdmin,
}) =>
userHasRoleInOrg
? <button
className="btn btn-sm btn-default"
onClick={handleChangeCurrentOrganization}
>
<span className="icon shuffle" /> Switch to
</button>
: <button
className="btn btn-sm btn-default"
onClick={handleJoinOrganizationAsAdmin}
>
<span className="icon user" /> Join
</button>
const OrganizationsTableRowDeleteButton = ({organization, onClickDelete}) =>
organization.id === DEFAULT_ORG_ID
@ -65,15 +45,6 @@ class OrganizationsTableRow extends Component {
router.push('')
}
handleJoinOrganizationAsAdmin = async () => {
const {me, organization, onCreateUser} = this.props
onCreateUser({
...me,
roles: [...me.roles, {name: ADMIN_ROLE, organization: organization.id}],
})
}
handleNameClick = () => {
this.setState({isEditing: true})
}
@ -147,7 +118,7 @@ class OrganizationsTableRow extends Component {
render() {
const {workingName, isEditing, isDeleting} = this.state
const {organization, currentOrganization, userHasRoleInOrg, me} = this.props
const {organization, currentOrganization, userHasRole} = this.props
const dropdownRolesItems = USER_ROLES.map(role => ({
...role,
@ -165,17 +136,13 @@ class OrganizationsTableRow extends Component {
? <button className="btn btn-sm btn-success">
<span className="icon checkmark" /> Current
</button>
: <AccessOrganizationButton
userHasRoleInOrg={userHasRoleInOrg}
me={me}
organization={organization}
handleChangeCurrentOrganization={
this.handleChangeCurrentOrganization
}
handleJoinOrganizationAsAdmin={
this.handleJoinOrganizationAsAdmin
}
/>}
: <button
className="btn btn-sm btn-default"
onClick={this.handleChangeCurrentOrganization}
disabled={!userHasRole}
>
<span className="icon shuffle" /> Switch to
</button>}
</div>
{isEditing
? <input
@ -259,27 +226,7 @@ OrganizationsTableRow.propTypes = {
}),
}),
meChangeOrganization: func.isRequired,
userHasRoleInOrg: bool.isRequired,
onCreateUser: func.isRequired,
me: shape({
id: string.isRequired,
name: string.isRequired,
roles: arrayOf(
shape({
name: string.isRequired,
organization: string.isRequired,
})
),
provider: string.isRequired,
scheme: string.isRequired,
organizations: arrayOf(
shape({
id: string.isRequired,
name: string.isRequired,
defaultRole: string.isRequired,
})
),
}),
userHasRole: bool.isRequired,
}
OrganizationsTableRowDeleteButton.propTypes = {
@ -291,12 +238,6 @@ OrganizationsTableRowDeleteButton.propTypes = {
onClickDelete: func.isRequired,
}
AccessOrganizationButton.propTypes = {
userHasRoleInOrg: bool.isRequired,
handleChangeCurrentOrganization: func.isRequired,
handleJoinOrganizationAsAdmin: func.isRequired,
}
const mapDispatchToProps = dispatch => ({
meChangeOrganization: bindActionCreators(meChangeOrganizationAsync, dispatch),
})

View File

@ -71,13 +71,7 @@ class OrganizationsPage extends Component {
}
render() {
const {
organizations,
currentOrganization,
authConfig,
me,
onCreateUser,
} = this.props
const {organizations, currentOrganization, authConfig, me} = this.props
return (
<OrganizationsTable
@ -91,7 +85,6 @@ class OrganizationsPage extends Component {
authConfig={authConfig}
onChangeAuthConfig={this.handleUpdateAuthConfig}
me={me}
onCreateUser={onCreateUser}
/>
)
}
@ -141,7 +134,6 @@ OrganizationsPage.propTypes = {
})
),
}),
onCreateUser: func.isRequired,
}
const mapStateToProps = ({