Skip to content

Commit 173688a

Browse files
feat: [UIE-9934] - IAM: reset to prev page when removing last role (linode#13268)
* feat: [UIE-9934] - IAM: reset to prev page when removing last role * Added changeset: IAM: removing entity/role can cause an empty page
1 parent 64060c2 commit 173688a

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
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: removing entity/role can cause an empty page ([#13268](https://github.com/linode/manager/pull/13268))

packages/manager/src/features/IAM/Shared/AssignedEntitiesTable/AssignedEntitiesTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,11 @@ export const AssignedEntitiesTable = ({ username }: Props) => {
172172

173173
const handleRemoveAssignmentDialogClose = () => {
174174
setIsRemoveAssignmentDialogOpen(false);
175-
// If we just deleted the last one on a page, reset to the first page.
175+
// If we just deleted the last one on a page, reset to the previous page.
176176
const removedLastOnPage =
177177
filteredAndSortedRoles.length % pagination.pageSize === 1;
178178
if (removedLastOnPage) {
179-
pagination.handlePageChange(1);
179+
pagination.handlePageChange(pagination.page - 1);
180180
}
181181
};
182182

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,17 @@ export const AssignedRolesTable = () => {
166166
setSelectedRole(role);
167167
};
168168

169+
const handleRemoveRoleDialogClose = () => {
170+
setIsUnassignRoleDialogOpen(false);
171+
172+
// If we just deleted the last one on a page, reset to the previous page.
173+
const removedLastOnPage =
174+
filteredAndSortedRoles.length % pagination.pageSize === 1;
175+
if (removedLastOnPage) {
176+
pagination.handlePageChange(pagination.page - 1);
177+
}
178+
};
179+
169180
const { data: accountRoles, isLoading: accountPermissionsLoading } =
170181
useAccountRoles();
171182
const { data: entities, isLoading: entitiesLoading } = useAllAccountEntities(
@@ -447,7 +458,7 @@ export const AssignedRolesTable = () => {
447458
role={selectedRole}
448459
/>
449460
<UnassignRoleConfirmationDialog
450-
onClose={() => setIsUnassignRoleDialogOpen(false)}
461+
onClose={() => handleRemoveRoleDialogClose()}
451462
open={isUnassignRoleDialogOpen}
452463
role={selectedRole}
453464
/>

0 commit comments

Comments
 (0)