Repository navigation
feat: delete custom roles from the detail page and the roles table - #304
jacobo-dominguez-wgu wants to merge 1 commit into
Conversation
|
Thanks for the pull request, @jacobo-dominguez-wgu! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources: When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #304 +/- ##
==========================================
+ Coverage 99.14% 99.17% +0.03%
==========================================
Files 99 101 +2
Lines 1748 1816 +68
Branches 556 577 +21
==========================================
+ Hits 1733 1801 +68
Misses 15 15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
9af651f to
401c9c4
Compare
401c9c4 to
a26b8f3
Compare
rodmgwgu
left a comment
There was a problem hiding this comment.
Thanks for this, tested in my local and is working correctly, just adding some findings for improvement.
| await waitFor(() => expect(screen.getByRole('checkbox')).not.toBeChecked()); | ||
| }); | ||
|
|
||
| it('offers no reassign action', () => { |
| expect(onDeleted).not.toHaveBeenCalled(); | ||
| }); | ||
|
|
||
| it('stays open and offers a retry toast on other errors', async () => { |
There was a problem hiding this comment.
Wouldn't the retry toast appear behind the modal shadow?
| {isCustom && canManageRoles && ( | ||
| <DeleteRoleModal | ||
| isOpen={isDeleteRoleOpen} | ||
| role={role} |
There was a problem hiding this comment.
On this page role.userCount comes from the complete catalog, and assigning or revoking members only invalidates the roles table (invalidateCatalogRoles), so the count here can stay stale for up to 30 minutes. For example, if a role has 2 members and I assign 3 more from this page, the modal still says "02 members", and "Delete anyway" sends assignments=revoke, which removes all 5 with no 409.
Can we load the live count when the modal opens, e.g. with GET /api/authz/v1/roles/<role_id>/? The JSDoc in deleteRole and DeleteRoleModal should also say the 409 only covers a role sent without assignments=revoke.
|
|
||
| await waitFor(() => expect(mockRemoveRole).toHaveBeenCalled()); | ||
| expect(close).not.toHaveBeenCalled(); | ||
| expect(onDeleted).not.toHaveBeenCalled(); |
There was a problem hiding this comment.
If I change the catch to always call showErrorToast, all the tests still pass, so nothing checks that a 409 doesn't show the retry toast. Can we assert that "Retry" isn't shown here?
Description
Adding delete feature to custom roles from the detailed role view and the roles table actions.
Closes openedx/openedx-authz#585
Design figma
Approach
DeleteRoleModal, opened from two places:console.logstub;useCanManageRoles). This matches the permission the endpoint checks. Standard roles never reach the flow.DELETE /api/authz/v1/roles/<role>/.?assignments=revoke.deleteRoleindata/api.tsanduseDeleteRoleindata/hooks.ts.Out of scope: reassigning members before deleting (step 2 of the original design). That feature was dropped in openedx/openedx-authz#585 (comment), so the modal has no "Reassign members" action. The confirmation checkbox is an addition to the Figma design.
Testing
1. Delete a role with no members (roles table)
Delete "Role A"?. The body says the role isn't assigned to anyone. There is no checkbox, and the button reads Delete.The role "Role A" was deleted., and Role A disappears from the table.2. Delete a role with members (detail page)
Dependencies
DELETE /api/authz/v1/roles/<role_id>/. It is not merged yet and is stacked on #649.Demo
Screen.Recording.2026-12-01.at.3.11.12.PM.mov
LLM Usage
Kiro helped with the implementation and tests A human guided the decisions and reviewed the result.