Skip to content

Commit 26f4109

Browse files
fix: [UIE-10011] - IAM Parent/Child selected roles drawer fix (#13282)
* fix: [UIE-10011] - Parent/Child selected roles drawer fix * Added changeset: IAM Delegation: User selector not working in Assign Role/Roles drawer * fix: [UIE-10017] - Account Delegations text fix
1 parent 904a1b8 commit 26f4109

File tree

7 files changed

+27
-13
lines changed

7 files changed

+27
-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": Fixed
3+
---
4+
5+
IAM Delegation: User selector not working in Assign Role/Roles drawer ([#13282](https://github.com/linode/manager/pull/13282))

packages/manager/src/features/IAM/Delegations/AccountDelegations.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ describe('AccountDelegations', () => {
8282
});
8383

8484
await waitFor(() => {
85-
const emptyElement = screen.getByText(/No users added/);
85+
const emptyElement = screen.getByText(/No items to display/);
8686
expect(emptyElement).toBeInTheDocument();
8787
});
8888
});

packages/manager/src/features/IAM/Delegations/AccountDelegationsTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { TableRowError } from 'src/components/TableRowError/TableRowError';
1010
import { TableRowLoading } from 'src/components/TableRowLoading/TableRowLoading';
1111
import { TableSortCell } from 'src/components/TableSortCell';
1212

13-
import { NO_DELEGATIONS_TEXT } from '../Shared/constants';
13+
import { NO_ITEMS_TO_DISPLAY_TEXT } from '../Shared/constants';
1414
import { AccountDelegationsTableRow } from './AccountDelegationsTableRow';
1515

1616
import type {
@@ -70,7 +70,7 @@ export const AccountDelegationsTable = ({
7070
<TableRowError colSpan={numCols} message={error[0]?.reason} />
7171
)}
7272
{!isLoading && !error && (!delegations || delegations.length === 0) && (
73-
<TableRowEmpty colSpan={numCols} message={NO_DELEGATIONS_TEXT} />
73+
<TableRowEmpty colSpan={numCols} message={NO_ITEMS_TO_DISPLAY_TEXT} />
7474
)}
7575
{!isLoading &&
7676
!error &&

packages/manager/src/features/IAM/Roles/RolesTable/AssignSelectedRolesDrawer.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import { Link } from 'src/components/Link';
2323
import { StyledLinkButtonBox } from 'src/components/SelectFirewallPanel/SelectFirewallPanel';
2424
import { AssignSingleSelectedRole } from 'src/features/IAM/Roles/RolesTable/AssignSingleSelectedRole';
2525

26+
import { usePermissions } from '../../hooks/usePermissions';
2627
import { INTERNAL_ERROR_NO_CHANGES_SAVED } from '../../Shared/constants';
2728
import { mergeAssignedRolesIntoExistingRoles } from '../../Shared/utilities';
2829

@@ -75,17 +76,22 @@ export const AssignSelectedRolesDrawer = ({
7576
}
7677
: undefined;
7778

79+
const { data: permissions } = usePermissions('account', ['view_user']);
80+
7881
const {
7982
data: accountUsers,
8083
fetchNextPage,
8184
hasNextPage,
8285
isFetching: isFetchingAccountUsers,
8386
isLoading: isLoadingAccountUsers,
84-
} = useAccountUsersInfiniteQuery({
85-
...userSearchFilter,
86-
'+order': 'asc',
87-
'+order_by': 'username',
88-
});
87+
} = useAccountUsersInfiniteQuery(
88+
{
89+
...userSearchFilter,
90+
'+order': 'asc',
91+
'+order_by': 'username',
92+
},
93+
permissions?.view_user
94+
);
8995

9096
const getUserOptions = useCallback(() => {
9197
const users = accountUsers?.pages.flatMap((page) => page.data);

packages/manager/src/features/IAM/Shared/constants.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export const ERROR_STATE_TEXT =
2020
'An unexpected error occurred. Refresh the page or try again later.';
2121

2222
// Delegation error messages
23-
export const NO_DELEGATIONS_TEXT = 'No users added.';
23+
export const NO_ITEMS_TO_DISPLAY_TEXT = 'No items to display.';
24+
export const NO_DELEGATED_USERS_TEXT = 'No users added.';
2425
export const DELEGATION_VALIDATION_ERROR =
2526
'At least one user must be selected as a delegate.';
2627

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { TableRow } from 'src/components/TableRow';
2020
import { TableRowEmpty } from 'src/components/TableRowEmpty/TableRowEmpty';
2121
import { TableSortCell } from 'src/components/TableSortCell';
2222
import { useIsIAMDelegationEnabled } from 'src/features/IAM/hooks/useIsIAMEnabled';
23+
import { NO_DELEGATED_USERS_TEXT } from 'src/features/IAM/Shared/constants';
2324
import { useOrderV2 } from 'src/hooks/useOrderV2';
2425
import { usePaginationV2 } from 'src/hooks/usePaginationV2';
2526

@@ -139,7 +140,10 @@ export const UserDelegations = () => {
139140
}) => (
140141
<>
141142
{paginatedData?.length === 0 && (
142-
<TableRowEmpty colSpan={1} message="No accounts found" />
143+
<TableRowEmpty
144+
colSpan={1}
145+
message={NO_DELEGATED_USERS_TEXT}
146+
/>
143147
)}
144148
{paginatedData?.map((childAccount) => (
145149
<TableRow key={childAccount.euuid}>

packages/queries/src/account/users.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ export const useAccountUsersInfiniteQuery = (
4040
filter: Filter = {},
4141
enabled = true,
4242
) => {
43-
const { data: profile } = useProfile();
44-
4543
return useInfiniteQuery<ResourcePage<User>, APIError[]>({
4644
getNextPageParam: ({ page, pages }) => {
4745
if (page === pages) {
@@ -51,7 +49,7 @@ export const useAccountUsersInfiniteQuery = (
5149
},
5250
initialPageParam: 1,
5351
...accountQueries.users._ctx.infinite(filter),
54-
enabled: enabled && !profile?.restricted,
52+
enabled,
5553
placeholderData: keepPreviousData,
5654
});
5755
};

0 commit comments

Comments
 (0)