Skip to content

Commit 677db9c

Browse files
fix: [UIE-9840] - IAM: Remove Role filter (already assigned roles) in ChangeRoleDrawer (#13212)
* remove role filtering in change role drawer * Added changeset: IAM: Remove Role filter (already assigned roles) in ChangeRoleDrawer * fix test
1 parent fdf6af4 commit 677db9c

File tree

3 files changed

+8
-38
lines changed

3 files changed

+8
-38
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: Remove Role filter (already assigned roles) in ChangeRoleDrawer ([#13212](https://github.com/linode/manager/pull/13212))

packages/manager/src/features/IAM/Shared/AssignedRolesTable/ChangeRoleDrawer.test.tsx

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -196,32 +196,4 @@ describe('ChangeRoleDrawer', () => {
196196
mockAccountAccessRole.name
197197
);
198198
});
199-
200-
it('should not list roles that the user already has', async () => {
201-
queryMocks.useUserRoles.mockReturnValue({
202-
data: {
203-
account_access: ['account_linode_admin', 'account_viewer'],
204-
entity_access: [],
205-
},
206-
});
207-
208-
queryMocks.useAccountRoles.mockReturnValue({
209-
data: accountRolesFactory.build(),
210-
});
211-
212-
renderWithTheme(<ChangeRoleDrawer {...props} mode="change-role" />);
213-
214-
const autocomplete = screen.getByRole('combobox');
215-
216-
await userEvent.click(autocomplete);
217-
218-
// expect select not to have the current role as one of the options
219-
const options = screen.getAllByRole('option');
220-
expect(options.map((option) => option.textContent)).not.toContain(
221-
'account_linode_admin'
222-
);
223-
expect(options.map((option) => option.textContent)).not.toContain(
224-
'account_viewer'
225-
);
226-
});
227199
});

packages/manager/src/features/IAM/Shared/AssignedRolesTable/ChangeRoleDrawer.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,22 +92,15 @@ export const ChangeRoleDrawer = ({ mode, onClose, open, role }: Props) => {
9292
el.value !== role?.name;
9393
// Exclude account roles already assigned to the user
9494
if (isAccountRole(el)) {
95-
return (
96-
!assignedRoles?.account_access.includes(el.value) &&
97-
matchesRoleContext
98-
);
95+
return matchesRoleContext;
9996
}
10097
// Exclude entity roles already assigned to the user
10198
if (isEntityRole(el)) {
102-
return (
103-
!assignedRoles?.entity_access.some((entity) =>
104-
entity.roles.includes(el.value)
105-
) && matchesRoleContext
106-
);
99+
return matchesRoleContext;
107100
}
108101
return true;
109102
});
110-
}, [accountRoles, assignedRoles, role]);
103+
}, [accountRoles, role]);
111104

112105
const {
113106
control,

0 commit comments

Comments
 (0)