Repository navigation
feat: Role Detail View/Members Tab Management Feature - #294
Conversation
|
Thanks for the pull request, @diana-villalvazo-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 #294 +/- ##
==========================================
+ Coverage 99.07% 99.14% +0.07%
==========================================
Files 90 99 +9
Lines 1615 1748 +133
Branches 530 519 -11
==========================================
+ Hits 1600 1733 +133
Misses 15 15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
e6c34ad to
58147b2
Compare
342cd95 to
5528a7f
Compare
5528a7f to
dd14d77
Compare
rodmgwgu
left a comment
There was a problem hiding this comment.
nit: Please update the PR description to reflect the latest changes and mention that it depends on openedx-authz#653
rodmgwgu
left a comment
There was a problem hiding this comment.
I've been testing this in my local and is looking good, just found some details to address, also, I see that for custom roles we are missing the resource-type indicator and the last updated date, and the edit warning.
Also, are we validating if the user is superuser for hiding or disabling the edit and duplicate functions?
| src={Edit} | ||
| iconAs={Icon} | ||
| size="sm" | ||
| alt={intl.formatMessage(messages['authz.custom.role.edit.name.alt'])} |
There was a problem hiding this comment.
It was decided in ADR 0036 that custom role names won't be editable once created, so we should remove this.
|
@maguilarUXUI I'm seeing that in the design we don't have anywhere to show or edit the role description, should we add that in this view? |
| {!isCustom && <DuplicateRoleButton />} | ||
| <AddRoleButton key="add-role-button" iconBefore={PersonAdd} /> | ||
| </Stack> | ||
| ]} |
There was a problem hiding this comment.
The figma design shows an edit icon button and a warning alert for custom roles, those are missing here, are they going to be part of an upcoming pr?
There was a problem hiding this comment.
Rod ask me to remove the edit button since on an ADR they decided to not allow custom role name to be edited, the alert will be added later.
09a782c to
62aec3d
Compare
shouldn't we do that validation before showing the edit button(for custom roles) on the prev page? or the edit is enabled for everyone and they can see but not do actions if they are not allowed to? |
Yes, everywhere where these superuser-only actions appear should be validated and hidden when the user is not superuser. |
| // Adding 2 actions as a stack since we don't want to have a divider between them | ||
| <Stack direction="horizontal" gap={2} key="role-actions"> | ||
| {!isCustom && <DuplicateRoleButton />} | ||
| <AddRoleButton key="add-role-button" iconBefore={PersonAdd} /> |
There was a problem hiding this comment.
Add role shouldn't be restricted to superusers only, it has it's own canAssignRole check.
Only the DuplicateRoleButton should be guarded behind canManageRoles.
| onClick={handleViewUser} | ||
| alt={formatMessage(messages['authz.role.members.table.action.view.alt'], { username: member.username })} | ||
| /> | ||
| <IconButton |
There was a problem hiding this comment.
The Delete action should be guarded by the following permissions: courses.manage_course_team for course assignments and content_libraries.manage_library_team for library assignments.
See how audit-user page already does it.
There was a problem hiding this comment.
Actually, wouldn’t it be better to reuse the delete action from the user assignments table?
It already uses canManageScope to enable deletion, respects the course-authoring flag, prevents removing your own admin role, and handles Django-managed roles with explanatory tooltips.
I don’t see a different delete workflow in Figma (1-to-1 action), so sharing the action and its confirmation/revocation flow could help keep both tables consistent. It would need some refactoring, but we could reuse the existing behavior instead of implementing it again. What do you think?
No need to include this in this PR, as it’s already quite large, just leaving the idea here for consideration.
| */ | ||
| export const useCanManageRoles = (): boolean => { | ||
| const { authenticatedUser } = useContext(SiteContext); | ||
| return authenticatedUser?.administrator === true; |
There was a problem hiding this comment.
This check doesn't cover all cases that the backend consider as 'superusers'. Currently the backend checks if a user is staff, or if they are superuser. This is only checking if a user is staff.
This seems to be an issue that comes from frontend-base, this is what Kiro had to say:
Is there a claim for superusers?
Yes. The backend already sends one, but frontend-base drops it before it reaches the app.
- openedx-platform adds both flags to the access token. In
/Users/rodrigo.mendez/oexenvs/main/repos/openedx-platform/openedx/core/djangoapps/oauth_dispatch/jwt.py:275-276:'administrator': user.is_staff, 'superuser': user.is_superuser,
- frontend-base copies only
administrator. In@openedx/frontend-base2.0.0-alpha.12,AxiosJwtAuthService.fetchAuthenticatedUserbuildsauthenticatedUserfromemail,userId,username,roles,administratorandname. Thesuperuserclaim never reachesSiteContext.authenticatedUser, andtypes.d.tsdoesn't declare it.
Best solution:
- Add
superusertoauthenticatedUserin frontend-base. It's one field infetchAuthenticatedUserplus the type. ThenuseCanManageRolesbecomesadministrator === true || superuser === true. This needs a frontend-base PR.
There was a problem hiding this comment.
Here is the frontend-base pr openedx/frontend-base#366
| import { EmailCell, NameCell } from '@src/authz-module/team-members/components/TeamMemberCells'; | ||
| import { ScopeSummaryCell } from '@src/authz-module/components/TableCells'; | ||
| import { getCellHeader, getScopeManageActionPermission } from '@src/authz-module/utils'; | ||
| import { useValidateUserPermissionsNonSuspense } from '@src/data/hooks'; |
There was a problem hiding this comment.
Could we use usePermissions from @openedx/frontend-base here? We’re planning to remove useValidateUserPermissionsNonSuspense, so it would be nice to avoid adding new usages.
useAssignableRoleGroups already uses it as an example. The query here would still need to check the manage-team permission for each specific scope.
rodmgwgu
left a comment
There was a problem hiding this comment.
LGTM!, thanks for addressing my comments!

Summary
Implemented role detail page enabling users to view and manage members assigned to standard and custom roles. Users can now navigate to individual role details, search/filter members, assign new members, and manage member lifecycle.
Note:
Same PR as #291 but got closed after comparing base branch was deleted 😅
Changes
New Features
Role Detail Page: Main view showing role metadata with Members and Permissions tabs
Members Table: Display members filtered by role with search and scope filtering
Member Actions: Per-row action buttons
Technical Decisions
Role ID over Name: Uses roleId for filtering instead of URL-encoded roleName to avoid encoding/decoding complexity.
Use Assignments endpoint: We decided to use
/api/authz/v1/assignments/(updated with the display name of scope and organization - PR) due touseTeamMembersAssignmentsdefaults to returning the first 3 assignments per user. A user holding the same role in more than three scopes therefore appears only three times, leaving the remaining scopes undisplayed.Remaining Tasks (Part of other GH issues/epics)
Screenshots
Standard Role
Custom Role
Support Info
Closes openedx/openedx-authz#575
LLM Usage
Built with assistance from Claude.