-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
upcoming: [M3-7455] - Add child account access column and disable button when account has child accounts #10012
Changes from 6 commits
3845183
76024d1
bf43651
bb58dbd
d56ce3d
6298f47
6b3b99e
5fed31c
8f293eb
c6016b7
f0ed502
d3eda04
101694e
8d9e5c1
65401eb
a98ec9d
132485f
f53d3ea
62f4892
fc94ec4
d795584
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@linode/manager": Upcoming Features | ||
--- | ||
|
||
Add child account access column and disable delete account button when account has child accounts ([#10012](https://github.com/linode/manager/pull/10012)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,18 +3,36 @@ import * as React from 'react'; | |
|
||
import { Accordion } from 'src/components/Accordion'; | ||
import { Button } from 'src/components/Button/Button'; | ||
import { Notice } from 'src/components/Notice/Notice'; | ||
import { useFlags } from 'src/hooks/useFlags'; | ||
import { useChildAccounts } from 'src/queries/account'; | ||
|
||
import CloseAccountDialog from './CloseAccountDialog'; | ||
|
||
const CloseAccountSetting = () => { | ||
const [dialogOpen, setDialogOpen] = React.useState<boolean>(false); | ||
|
||
const { data: childAccounts } = useChildAccounts({}); | ||
const flags = useFlags(); | ||
const closeAccountDisabled = flags.parentChildAccountAccess | ||
? Boolean(childAccounts?.data?.length) | ||
: false; | ||
|
||
return ( | ||
<> | ||
<Accordion defaultExpanded={true} heading="Close Account"> | ||
<Grid container direction="column"> | ||
<Grid> | ||
<Button buttonType="outlined" onClick={() => setDialogOpen(true)}> | ||
{closeAccountDisabled && ( | ||
<Notice spacingBottom={20} variant="info"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, this is a good call. Exact copy TBD - I know you reached out to Magda; we can be sure to get a response from her or Jan on that, whether it's finalized in this ticket or a follow up for copy changes. |
||
Remove child accounts before closing the account. | ||
</Notice> | ||
)} | ||
<Button | ||
buttonType="outlined" | ||
disabled={closeAccountDisabled} | ||
onClick={() => setDialogOpen(true)} | ||
> | ||
Close Account | ||
</Button> | ||
</Grid> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
import { Stack } from 'src/components/Stack'; | ||
import React from 'react'; | ||
|
||
import { Box } from 'src/components/Box'; | ||
import { Chip } from 'src/components/Chip'; | ||
import { DateTimeDisplay } from 'src/components/DateTimeDisplay'; | ||
import { GravatarByEmail } from 'src/components/GravatarByEmail'; | ||
import { Hidden } from 'src/components/Hidden'; | ||
import { Stack } from 'src/components/Stack'; | ||
import { StatusIcon } from 'src/components/StatusIcon/StatusIcon'; | ||
import { TableCell } from 'src/components/TableCell'; | ||
import { TableRow } from 'src/components/TableRow'; | ||
import { Typography } from 'src/components/Typography'; | ||
import { useFlags } from 'src/hooks/useFlags'; | ||
import { useAccountUserGrants } from 'src/queries/accountUsers'; | ||
import { capitalize } from 'src/utilities/capitalize'; | ||
|
||
import { UsersActionMenu } from './UsersActionMenu'; | ||
|
@@ -22,6 +24,8 @@ interface Props { | |
} | ||
|
||
export const UserRow = ({ onDelete, user }: Props) => { | ||
const flags = useFlags(); | ||
const { data: grants } = useAccountUserGrants(user.username); | ||
return ( | ||
<TableRow ariaLabel={`User ${user.username}`} key={user.username}> | ||
<TableCell> | ||
|
@@ -36,6 +40,11 @@ export const UserRow = ({ onDelete, user }: Props) => { | |
<TableCell>{user.email}</TableCell> | ||
</Hidden> | ||
<TableCell>{user.restricted ? 'Limited' : 'Full'}</TableCell> | ||
{flags.parentChildAccountAccess && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should provide a better check here as opposed to just relying on the feature flag, since that will disappear in the future and this entire column will be conditionally rendered. |
||
<TableCell> | ||
{grants?.global.child_account_access ? 'Enabled' : 'Disabled'} | ||
mjac0bs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</TableCell> | ||
)} | ||
<Hidden lgDown> | ||
<TableCell> | ||
<LastLogin last_login={user.last_login} /> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the current account has child accounts, disable the 'Close Account' button
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to simplify this:
const closeAccountDisabled = flags.parentChildAccountAccess && Boolean(childAccounts?.data?.length);