Skip to content

Commit

Permalink
fix: [M3-7817] - Show correct status of Child Account Enabled column …
Browse files Browse the repository at this point in the history
…for parent users (#10233)

* Add a restricted check and flip the conditional result

* Added changeset: Show correct status of Child Account Enabled column for parent users

* Show accurate Child Account Access status without refresh

* Add bug fix for loading table state
  • Loading branch information
mjac0bs authored Mar 8, 2024
1 parent 433f3fd commit 0a6c1ad
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Upcoming Features
---

Show correct status of Child Account Enabled column for parent users ([#10233](https://github.com/linode/manager/pull/10233))
8 changes: 8 additions & 0 deletions packages/manager/src/features/Users/UserPermissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,14 @@ class UserPermissions extends React.Component<CombinedProps, State> {
variant: 'success',
}
);

// Refresh the data on /account/users/:currentUser:/grants/ so it is accurate.
this.props.queryClient.invalidateQueries([
'account',
'users',
'grants',
currentUsername,
]);
})
.catch((errResponse) => {
this.setState({
Expand Down
4 changes: 3 additions & 1 deletion packages/manager/src/features/Users/UserRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ export const UserRow = ({ onDelete, user }: Props) => {
{showChildAccountAccessCol && (
<Hidden lgDown>
<TableCell>
{grants?.global?.child_account_access ? 'Enabled' : 'Disabled'}
{user.restricted && !grants?.global?.child_account_access
? 'Disabled'
: 'Enabled'}
</TableCell>
</Hidden>
)}
Expand Down
11 changes: 6 additions & 5 deletions packages/manager/src/features/Users/UsersLandingTableBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ interface Props {
export const UsersLandingTableBody = (props: Props) => {
const { error, isLoading, numCols, onDelete, users } = props;

if ((isLoading && !users) || (isLoading && users?.length === 0)) {
return <TableRowEmpty colSpan={numCols} />;
}

if (isLoading) {
return <TableRowLoading columns={numCols} rows={1} />;
}
Expand All @@ -26,13 +30,10 @@ export const UsersLandingTableBody = (props: Props) => {
return <TableRowError colSpan={numCols} message={error[0].reason} />;
}

if (!users || users.length === 0) {
return <TableRowEmpty colSpan={numCols} />;
}

return (
// eslint-disable-next-line react/jsx-no-useless-fragment
<>
{users.map((user) => (
{users?.map((user) => (
<UserRow key={user.username} onDelete={onDelete} user={user} />
))}
</>
Expand Down

0 comments on commit 0a6c1ad

Please sign in to comment.