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-13332-fixed-1769527315688.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Fixed
---

IAM Delegation: The selected user type is not applied after reloading the page ([#13332](https://github.com/linode/manager/pull/13332))
42 changes: 28 additions & 14 deletions packages/manager/src/features/IAM/Users/UsersTable/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const UsersLanding = () => {
const { isIAMDelegationEnabled } = useIsIAMDelegationEnabled();
const { data: profile } = useProfile();

const { query } = useSearch({
const { query, users: usersParam } = useSearch({
from: '/iam',
});
const [isCreateDrawerOpen, setIsCreateDrawerOpen] =
Expand Down Expand Up @@ -72,8 +72,34 @@ export const UsersLanding = () => {
const isChildWithDelegationEnabled =
isIAMDelegationEnabled && Boolean(profile?.user_type === 'child');

const filterableOptions = React.useMemo(
() => [
ALL_USERS_OPTION,
{
label: 'Users',
value: 'users',
},
{
label: 'Delegate Users',
value: 'delegate',
},
],
[]
);

// Initialize userType based on URL parameter
const getInitialUserType = React.useMemo(() => {
if (!usersParam || usersParam === 'all') {
return ALL_USERS_OPTION;
}
return (
filterableOptions.find((option) => option.value === usersParam) ||
ALL_USERS_OPTION
);
}, [usersParam, filterableOptions]);

const [userType, setUserType] = React.useState<null | SelectOption>(
ALL_USERS_OPTION
getInitialUserType
);

const usersFilter: Filter = {
Expand Down Expand Up @@ -101,18 +127,6 @@ export const UsersLanding = () => {
},
});

const filterableOptions = [
ALL_USERS_OPTION,
{
label: 'Users',
value: 'users',
},
{
label: 'Delegate Users',
value: 'delegate',
},
];

const isSmDown = useMediaQuery(theme.breakpoints.down('sm'));
const isLgDown = useMediaQuery(theme.breakpoints.up('lg'));

Expand Down