Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-13282-fixed-1768483343450.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Fixed
---

IAM Delegation: User selector not working in Assign Role/Roles drawer ([#13282](https://github.com/linode/manager/pull/13282))
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe('AccountDelegations', () => {
});

await waitFor(() => {
const emptyElement = screen.getByText(/No users added/);
const emptyElement = screen.getByText(/No items to display/);
expect(emptyElement).toBeInTheDocument();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { TableRowError } from 'src/components/TableRowError/TableRowError';
import { TableRowLoading } from 'src/components/TableRowLoading/TableRowLoading';
import { TableSortCell } from 'src/components/TableSortCell';

import { NO_DELEGATIONS_TEXT } from '../Shared/constants';
import { NO_ITEMS_TO_DISPLAY_TEXT } from '../Shared/constants';
import { AccountDelegationsTableRow } from './AccountDelegationsTableRow';

import type {
Expand Down Expand Up @@ -70,7 +70,7 @@ export const AccountDelegationsTable = ({
<TableRowError colSpan={numCols} message={error[0]?.reason} />
)}
{!isLoading && !error && (!delegations || delegations.length === 0) && (
<TableRowEmpty colSpan={numCols} message={NO_DELEGATIONS_TEXT} />
<TableRowEmpty colSpan={numCols} message={NO_ITEMS_TO_DISPLAY_TEXT} />
)}
{!isLoading &&
!error &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { Link } from 'src/components/Link';
import { StyledLinkButtonBox } from 'src/components/SelectFirewallPanel/SelectFirewallPanel';
import { AssignSingleSelectedRole } from 'src/features/IAM/Roles/RolesTable/AssignSingleSelectedRole';

import { usePermissions } from '../../hooks/usePermissions';
import { INTERNAL_ERROR_NO_CHANGES_SAVED } from '../../Shared/constants';
import { mergeAssignedRolesIntoExistingRoles } from '../../Shared/utilities';

Expand Down Expand Up @@ -75,17 +76,22 @@ export const AssignSelectedRolesDrawer = ({
}
: undefined;

const { data: permissions } = usePermissions('account', ['view_user']);

const {
data: accountUsers,
fetchNextPage,
hasNextPage,
isFetching: isFetchingAccountUsers,
isLoading: isLoadingAccountUsers,
} = useAccountUsersInfiniteQuery({
...userSearchFilter,
'+order': 'asc',
'+order_by': 'username',
});
} = useAccountUsersInfiniteQuery(
{
...userSearchFilter,
'+order': 'asc',
'+order_by': 'username',
},
permissions?.view_user
);

const getUserOptions = useCallback(() => {
const users = accountUsers?.pages.flatMap((page) => page.data);
Expand Down
3 changes: 2 additions & 1 deletion packages/manager/src/features/IAM/Shared/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ export const ERROR_STATE_TEXT =
'An unexpected error occurred. Refresh the page or try again later.';

// Delegation error messages
export const NO_DELEGATIONS_TEXT = 'No users added.';
export const NO_ITEMS_TO_DISPLAY_TEXT = 'No items to display.';
export const NO_DELEGATED_USERS_TEXT = 'No users added.';
export const DELEGATION_VALIDATION_ERROR =
'At least one user must be selected as a delegate.';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { TableRow } from 'src/components/TableRow';
import { TableRowEmpty } from 'src/components/TableRowEmpty/TableRowEmpty';
import { TableSortCell } from 'src/components/TableSortCell';
import { useIsIAMDelegationEnabled } from 'src/features/IAM/hooks/useIsIAMEnabled';
import { NO_DELEGATED_USERS_TEXT } from 'src/features/IAM/Shared/constants';
import { useOrderV2 } from 'src/hooks/useOrderV2';
import { usePaginationV2 } from 'src/hooks/usePaginationV2';

Expand Down Expand Up @@ -139,7 +140,10 @@ export const UserDelegations = () => {
}) => (
<>
{paginatedData?.length === 0 && (
<TableRowEmpty colSpan={1} message="No accounts found" />
<TableRowEmpty
colSpan={1}
message={NO_DELEGATED_USERS_TEXT}
/>
)}
{paginatedData?.map((childAccount) => (
<TableRow key={childAccount.euuid}>
Expand Down
4 changes: 1 addition & 3 deletions packages/queries/src/account/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ export const useAccountUsersInfiniteQuery = (
filter: Filter = {},
enabled = true,
) => {
const { data: profile } = useProfile();

return useInfiniteQuery<ResourcePage<User>, APIError[]>({
getNextPageParam: ({ page, pages }) => {
if (page === pages) {
Expand All @@ -51,7 +49,7 @@ export const useAccountUsersInfiniteQuery = (
},
initialPageParam: 1,
...accountQueries.users._ctx.infinite(filter),
enabled: enabled && !profile?.restricted,
enabled,
placeholderData: keepPreviousData,
});
};
Expand Down