Skip to content

Commit 82bd3ab

Browse files
fix: [UIE-10097] - IAM: User type not applied after page refresh (linode#13332)
* fix: [UIE-10097] - users type fix * Added changeset: IAM Delegation: The selected user type is not applied after reloading the page * review fix
1 parent 5cb70bd commit 82bd3ab

File tree

2 files changed

+33
-14
lines changed

2 files changed

+33
-14
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: The selected user type is not applied after reloading the page ([#13332](https://github.com/linode/manager/pull/13332))

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

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const UsersLanding = () => {
3333
const { isIAMDelegationEnabled } = useIsIAMDelegationEnabled();
3434
const { data: profile } = useProfile();
3535

36-
const { query } = useSearch({
36+
const { query, users: usersParam } = useSearch({
3737
from: '/iam',
3838
});
3939
const [isCreateDrawerOpen, setIsCreateDrawerOpen] =
@@ -72,8 +72,34 @@ export const UsersLanding = () => {
7272
const isChildWithDelegationEnabled =
7373
isIAMDelegationEnabled && Boolean(profile?.user_type === 'child');
7474

75+
const filterableOptions = React.useMemo(
76+
() => [
77+
ALL_USERS_OPTION,
78+
{
79+
label: 'Users',
80+
value: 'users',
81+
},
82+
{
83+
label: 'Delegate Users',
84+
value: 'delegate',
85+
},
86+
],
87+
[]
88+
);
89+
90+
// Initialize userType based on URL parameter
91+
const getInitialUserType = React.useMemo(() => {
92+
if (!usersParam || usersParam === 'all') {
93+
return ALL_USERS_OPTION;
94+
}
95+
return (
96+
filterableOptions.find((option) => option.value === usersParam) ||
97+
ALL_USERS_OPTION
98+
);
99+
}, [usersParam, filterableOptions]);
100+
75101
const [userType, setUserType] = React.useState<null | SelectOption>(
76-
ALL_USERS_OPTION
102+
getInitialUserType
77103
);
78104

79105
const usersFilter: Filter = {
@@ -101,18 +127,6 @@ export const UsersLanding = () => {
101127
},
102128
});
103129

104-
const filterableOptions = [
105-
ALL_USERS_OPTION,
106-
{
107-
label: 'Users',
108-
value: 'users',
109-
},
110-
{
111-
label: 'Delegate Users',
112-
value: 'delegate',
113-
},
114-
];
115-
116130
const isSmDown = useMediaQuery(theme.breakpoints.down('sm'));
117131
const isLgDown = useMediaQuery(theme.breakpoints.up('lg'));
118132

0 commit comments

Comments
 (0)