Skip to content

Commit f7e64a6

Browse files
djcarpejrenee42DJ CarpenterChitlangeSahasOfTheDelmer
authored
feat(ecommerce): Multi account/remove self (#3774)
Co-authored-by: Jill R Pelavin <jpelavin@influxdata.com> Co-authored-by: DJ Carpenter <dj@influxdata.com> Co-authored-by: Chitlange Sahas <chitlangesahas@gmail.com> Co-authored-by: Delmer Reed <delmer814+1@gmail.com>
1 parent 3c7f669 commit f7e64a6

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

src/accounts/AccountPage.tsx

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
// Libraries
22
import React, {FC, useContext, useEffect, useState} from 'react'
3+
import {useSelector} from 'react-redux'
4+
35
import {
46
Button,
7+
ButtonShape,
8+
ComponentColor,
59
ComponentSize,
10+
ConfirmationButton,
611
FlexBox,
712
FlexDirection,
813
IconFont,
@@ -12,7 +17,11 @@ import {
1217
Page,
1318
} from '@influxdata/clockface'
1419

20+
import {getMe} from 'src/me/selectors'
21+
import {UsersContext} from 'src/users/context/users'
22+
1523
// Utils
24+
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
1625
import {pageTitleSuffixer} from 'src/shared/utils/pageTitles'
1726
import {
1827
UserAccountContext,
@@ -24,15 +33,24 @@ import AccountHeader from 'src/accounts/AccountHeader'
2433
import {SwitchAccountOverlay} from 'src/accounts/SwitchAccountOverlay'
2534
import CancellationOverlay from './CancellationOverlay'
2635
import CancelServiceProvider from 'src/billing/components/PayAsYouGo/CancelServiceContext'
27-
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
2836

2937
// Styles
3038
import './AccountPageStyles.scss'
39+
import {CLOUD_URL} from 'src/shared/constants'
40+
41+
const leaveBtnStyle = {
42+
width: 'auto',
43+
marginTop: 32,
44+
paddingLeft: '8px',
45+
paddingRight: '8px',
46+
}
3147

3248
const AccountAboutPage: FC = () => {
3349
const {userAccounts, handleRenameActiveAccount} = useContext(
3450
UserAccountContext
3551
)
52+
const {users, handleRemoveUser} = useContext(UsersContext)
53+
3654
const [isSwitchAccountVisible, setSwitchAccountVisible] = useState(false)
3755
const [isDeactivateAccountVisible, setDeactivateAccountVisible] = useState(
3856
false
@@ -69,6 +87,30 @@ const AccountAboutPage: FC = () => {
6987
const closeSwitchAccountDialog = () => {
7088
setSwitchAccountVisible(false)
7189
}
90+
const currentUserId = useSelector(getMe)?.id
91+
92+
const handleRemove = () => {
93+
handleRemoveUser(currentUserId)
94+
window.location.href = CLOUD_URL
95+
}
96+
97+
const allowSelfRemoval =
98+
isFlagEnabled('selfRemovalFromAccount') && users.length > 1
99+
100+
const leaveAcctBtn = (
101+
<ConfirmationButton
102+
confirmationLabel="This action will remove yourself from accessing this organization"
103+
confirmationButtonText="Leave Account"
104+
titleText="Leave Account"
105+
text="Leave Account"
106+
confirmationButtonColor={ComponentColor.Danger}
107+
color={ComponentColor.Default}
108+
shape={ButtonShape.Square}
109+
onConfirm={handleRemove}
110+
testID="delete-user"
111+
style={leaveBtnStyle}
112+
/>
113+
)
72114

73115
const inputStyle = {width: 250}
74116
const labelStyle = {marginBottom: 8, maxWidth: '500px'}
@@ -127,6 +169,7 @@ const AccountAboutPage: FC = () => {
127169
text="Save"
128170
/>
129171
</FlexBox>
172+
{allowSelfRemoval && leaveAcctBtn}
130173
{showDeactivateAccountSection && (
131174
<>
132175
<hr style={dividerStyle} />

0 commit comments

Comments
 (0)