Skip to content

Commit 9263baf

Browse files
feat: [UIE-9794] - IAM: Enable account_viewer to access users table (#13189)
* feat: [UIE-9794] - IAM: Enable account_viewer to access users table * changesets * fix a tooltip
1 parent 32e9d71 commit 9263baf

File tree

7 files changed

+25
-13
lines changed

7 files changed

+25
-13
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/manager": Changed
3+
---
4+
5+
IAM: Enable account_viewer to access users table ([#13189](https://github.com/linode/manager/pull/13189))

packages/manager/src/features/IAM/Users/UsersTable/UserRow.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ export const UserRow = ({ onDelete, user }: Props) => {
3030
const { data: permissions } = usePermissions('account', [
3131
'delete_user',
3232
'is_account_admin',
33+
'view_account',
3334
]);
3435

3536
const { isIAMDelegationEnabled } = useIsIAMDelegationEnabled();
36-
const canViewUser = permissions.is_account_admin;
37+
const canViewUser = permissions.view_account;
3738

3839
// Determine if the current user is a child account with isIAMDelegationEnabled enabled
3940
// If so, we need to show the 'User type' column in the table

packages/manager/src/features/IAM/Users/UsersTable/Users.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ export const UsersLanding = () => {
199199
disabled={!canCreateUser}
200200
onClick={() => setIsCreateDrawerOpen(true)}
201201
tooltipText={
202-
canCreateUser
203-
? 'You cannot create other users as a restricted user.'
202+
!canCreateUser
203+
? 'You do not have permission to create other users.'
204204
: undefined
205205
}
206206
>

packages/manager/src/features/IAM/Users/UsersTable/UsersActionMenu.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ describe('UsersActionMenu', () => {
4444
permissions={{
4545
is_account_admin: true,
4646
delete_user: true,
47+
view_account: true,
4748
}}
4849
username="test_user"
4950
/>
@@ -99,6 +100,7 @@ describe('UsersActionMenu', () => {
99100
permissions={{
100101
is_account_admin: true,
101102
delete_user: true,
103+
view_account: true,
102104
}}
103105
username="current_user"
104106
/>

packages/manager/src/features/IAM/Users/UsersTable/UsersActionMenu.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type { PickPermissions, UserType } from '@linode/api-v4';
1010
import type { Action } from 'src/components/ActionMenu/ActionMenu';
1111

1212
type UserActionMenuPermissions = PickPermissions<
13-
'delete_user' | 'is_account_admin'
13+
'delete_user' | 'is_account_admin' | 'view_account'
1414
>;
1515

1616
interface Props {
@@ -29,6 +29,7 @@ export const UsersActionMenu = (props: Props) => {
2929
useDelegationRole();
3030

3131
const isAccountAdmin = permissions.is_account_admin;
32+
const isAccountViewer = permissions.view_account;
3233
const canDeleteUser = isAccountAdmin || permissions.delete_user;
3334
const isDelegateUser = userType === 'delegate';
3435

@@ -46,8 +47,8 @@ export const UsersActionMenu = (props: Props) => {
4647
});
4748
},
4849
hidden: shouldHideForChildDelegate,
49-
disabled: !isAccountAdmin,
50-
tooltip: !isAccountAdmin
50+
disabled: !isAccountViewer,
51+
tooltip: !isAccountViewer
5152
? 'You do not have permission to view user details.'
5253
: undefined,
5354
title: 'View User Details',
@@ -59,8 +60,8 @@ export const UsersActionMenu = (props: Props) => {
5960
params: { username },
6061
});
6162
},
62-
disabled: !isAccountAdmin,
63-
tooltip: !isAccountAdmin
63+
disabled: !isAccountViewer,
64+
tooltip: !isAccountViewer
6465
? 'You do not have permission to view assigned roles.'
6566
: undefined,
6667
title: 'View Assigned Roles',
@@ -72,8 +73,8 @@ export const UsersActionMenu = (props: Props) => {
7273
params: { username },
7374
});
7475
},
75-
disabled: !isAccountAdmin,
76-
tooltip: !isAccountAdmin
76+
disabled: !isAccountViewer,
77+
tooltip: !isAccountViewer
7778
? 'You do not have permission to view entity access.'
7879
: undefined,
7980
title: 'View Entity Access',
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@linode/queries": Changed
3+
---
4+
5+
IAM: Enable account_viewer to access users table ([#13189](https://github.com/linode/manager/pull/13189))

packages/queries/src/account/users.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,9 @@ export const useAccountUsers = ({
2929
filters?: Filter;
3030
params?: Params;
3131
}) => {
32-
const { data: profile } = useProfile();
33-
3432
return useQuery<ResourcePage<User>, APIError[]>({
3533
...accountQueries.users._ctx.paginated(params, filters),
36-
enabled: enabled && !profile?.restricted,
34+
enabled,
3735
placeholderData: keepPreviousData,
3836
});
3937
};

0 commit comments

Comments
 (0)