Skip to content

Commit 3269fb7

Browse files
author
Randy Coulman
authored
feat(operator): eliminate the Remove User button (#5238)
**CLOUD ONLY** The Remove User button on the operator Accounts page actually removes the user from an organization, not an account. When there was a 1:1 mapping between accounts and orgs, this was fine, but we are now moving into a multi-org world where this no longer makes sense. We need to do more significant work to the operator UI to support multi-org, and this work will happen in a later phase of the project. For now, given that there is a feature in the main part of the UI where users can remove themselves or other users from an organzation, we've decided to remove the `Remove User` button. This is the only client of `ResourcesTableRow` that passed additional `children`, and I believe that ability was added as a bit of hack to support this one use case. Therefore, I also removed the `children` prop from `ResourcesTableRow` as dead code. Should we need it again in the future, it should be relatively easy to add back.
1 parent 3792e93 commit 3269fb7

File tree

4 files changed

+3
-64
lines changed

4 files changed

+3
-64
lines changed

src/operator/ResourcesTableRow.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ interface Props {
1111
const resolvePath = (object, path, defaultValue) =>
1212
path.split('.').reduce((o, p) => (o ? o[p] : defaultValue), object)
1313

14-
const ResourcesTableRow: FC<Props> = ({children, resource, infos}) => {
14+
const ResourcesTableRow: FC<Props> = ({resource, infos}) => {
1515
const returnValue = (path, defaultValue, renderValue) => {
1616
const value = resolvePath(resource, path, defaultValue)
1717
return renderValue ? renderValue(value) : value
@@ -24,7 +24,6 @@ const ResourcesTableRow: FC<Props> = ({children, resource, infos}) => {
2424
{returnValue(path, defaultValue, renderValue)}
2525
</Table.Cell>
2626
))}
27-
{children}
2827
</Table.Row>
2928
)
3029
}

src/operator/account/AssociatedUsersTable.tsx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,15 @@ import {
1010

1111
// Components
1212
import ResourcesTableRow from 'src/operator/ResourcesTableRow'
13-
import RemoveFromAccount from 'src/operator/account/RemoveFromAccount'
1413

1514
// Constants
1615
import {acctUserColumnInfo, accountUserHeaderInfo} from 'src/operator/constants'
1716

1817
// Contexts
1918
import {AccountContext} from 'src/operator/context/account'
20-
import {OperatorContext} from 'src/operator/context/operator'
2119

2220
const AssociatedTableUsers: FC = () => {
23-
const {account, handleRemoveUserFromAccount} = useContext(AccountContext)
24-
const hasMultipleUsers = account?.users?.length > 1
25-
const {hasWritePermissions} = useContext(OperatorContext)
21+
const {account} = useContext(AccountContext)
2622

2723
return (
2824
<FlexBox direction={FlexDirection.Column} margin={ComponentSize.Large}>
@@ -41,15 +37,7 @@ const AssociatedTableUsers: FC = () => {
4137
key={resource.id}
4238
resource={resource}
4339
infos={acctUserColumnInfo}
44-
>
45-
{hasWritePermissions && hasMultipleUsers && (
46-
<RemoveFromAccount
47-
removeUser={async () => {
48-
await handleRemoveUserFromAccount(resource.id)
49-
}}
50-
/>
51-
)}
52-
</ResourcesTableRow>
40+
/>
5341
))}
5442
</Table.Body>
5543
<Table.Footer />

src/operator/account/RemoveFromAccount.tsx

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/operator/context/account.tsx

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
patchOperatorAccountsConvert,
99
deleteOperatorAccount,
1010
getOperatorAccount,
11-
deleteOperatorAccountsUser,
1211
} from 'src/client/unityRoutes'
1312
import {notify} from 'src/shared/actions/notifications'
1413
import {
@@ -32,7 +31,6 @@ export interface AccountContextType {
3231
handleConvertAccountToContract: (contractStartDate: string) => void
3332
handleDeleteAccount: () => void
3433
handleGetAccount: () => void
35-
handleRemoveUserFromAccount: (id: string) => void
3634
organizations: OperatorOrg[]
3735
setConvertToContractOverlayVisible: (vis: boolean) => void
3836
convertToContractOverlayVisible: boolean
@@ -48,7 +46,6 @@ export const DEFAULT_CONTEXT: AccountContextType = {
4846
handleConvertAccountToContract: () => {},
4947
handleDeleteAccount: () => {},
5048
handleGetAccount: () => {},
51-
handleRemoveUserFromAccount: (_: string) => {},
5249
organizations: null,
5350
setConvertToContractOverlayVisible: (_: boolean) => {},
5451
convertToContractOverlayVisible: false,
@@ -139,28 +136,6 @@ export const AccountProvider: FC<Props> = React.memo(({children}) => {
139136
}
140137
}, [dispatch, history, accountID])
141138

142-
const handleRemoveUserFromAccount = useCallback(
143-
async (userID: string) => {
144-
try {
145-
setDeleteStatus(RemoteDataState.Loading)
146-
const resp = await deleteOperatorAccountsUser({
147-
accountId: accountID,
148-
userId: userID,
149-
})
150-
if (resp.status !== 204) {
151-
throw new Error(resp.data.message)
152-
}
153-
setDeleteStatus(RemoteDataState.Done)
154-
} catch (error) {
155-
console.error({error})
156-
dispatch(notify(deleteAccountError(accountID)))
157-
} finally {
158-
await handleGetAccount()
159-
}
160-
},
161-
[dispatch, handleGetAccount, accountID]
162-
)
163-
164139
return (
165140
<AccountContext.Provider
166141
value={{
@@ -171,7 +146,6 @@ export const AccountProvider: FC<Props> = React.memo(({children}) => {
171146
handleConvertAccountToContract,
172147
handleDeleteAccount,
173148
handleGetAccount,
174-
handleRemoveUserFromAccount,
175149
organizations,
176150
setConvertToContractOverlayVisible,
177151
convertToContractOverlayVisible,

0 commit comments

Comments
 (0)