Repository navigation
feat: Role Detail View/Members Tab Management Feature - #291
diana-villalvazo-wgu wants to merge 15 commits into
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. |
7623e2c to
90b8d05
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## jacobo/assign-role-row #291 +/- ##
==========================================================
+ Coverage 99.07% 99.10% +0.03%
==========================================================
Files 90 96 +6
Lines 1615 1682 +67
Branches 529 539 +10
==========================================================
+ Hits 1600 1667 +67
Misses 15 15 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
3953014 to
8e74526
Compare
8e74526 to
d58069d
Compare
| onClick={handleViewUser} | ||
| alt={formatMessage(messages['authz.role.members.table.action.view.alt'])} | ||
| /> | ||
| <IconButton |
There was a problem hiding this comment.
To keep in mind for the following PR:
The delete action should validate the course authz flag, see https://github.com/openedx/frontend-app-admin-console/blob/master/src/authz-module/components/TableCells.tsx#L195
The view action does not need to validate the flag.
| * hand `DataTable` a new `data` array on every render, and react-table resets its | ||
| * expanded-row state whenever `data` changes identity. | ||
| */ | ||
| export const EMPTY_ASSIGNMENTS: GetTeamMembersAssignmentsResponse = { |
There was a problem hiding this comment.
Can we move this to @src/authz-module/constants.ts please.
| navigate(buildAuditUserPath(member.username)); | ||
| }; | ||
|
|
||
| return ( |
There was a problem hiding this comment.
Can we please pass the username in the alt, that will help screen readers to differentiate each row.
| import { useTeamMembersAssignments } from '@src/authz-module/data/hooks'; | ||
| import { useQuerySettings } from '@src/authz-module/hooks/useQuerySettings'; | ||
| import { EMPTY_ASSIGNMENTS } from '@src/types'; | ||
| import { EmailCell, NameCell } from '@src/authz-module/team-members/components/TeamMemberCells'; |
There was a problem hiding this comment.
[Note - no blocking ] this is a strong candidate to live in the role-assignments feature proposed here #247
| isLoading: true, | ||
| }); | ||
| renderMembersTable(); | ||
| // Component should render, possibly with loading indicator |
There was a problem hiding this comment.
There is not assertions here:
| // Component should render, possibly with loading indicator | |
| // Component should render, possibly with loading indicator | |
| expect(screen.getByRole('status')).toBeInTheDocument(); | |
| expect(screen.getByPlaceholderText(/Search/i)).toBeInTheDocument(); |
| const { | ||
| data: { results: members = [], count = 0 } = EMPTY_ASSIGNMENTS, | ||
| isLoading | ||
| } = useTeamMembersAssignments(querySettings, true); |
There was a problem hiding this comment.
The idea here is showing each asignation per role?
useTeamMembersAssignments defaults 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.
Passing assignmentsLimit lets us request a larger preview:
if (querySettings.assignmentsLimit !== undefined) {
url.searchParams.set('assignments_limit', querySettings.assignmentsLimit.toString());
}However, the API caps this value at 10, so this is a partial fix. Users with more than ten matching scopes still have truncated information.
In addition, the count is inconsistent. When a user holds the same role in multiple scopes, the number of displayed rows differs from the API’s user count. Since each row represents an assignment, “Showing N assignments of M” would be more accurate.
C.C @rodmgwgu , @BryanttV could not be better to use /api/authz/v1/assignments/ (updated with the display name of scope and organization) for this or we are going to deprecate the endpoint?
There was a problem hiding this comment.
No plans to deprecate that endpoint, it can be used.
There was a problem hiding this comment.
raised an Issue on authz to add those attributes and implement this openedx/openedx-authz#652
| original: mockMember, | ||
| }; | ||
|
|
||
| const renderActionCell = (props = {}) => render( |
There was a problem hiding this comment.
Please use the test utilities functions, for example, renderWrapper
| beforeEach(() => { | ||
| mockAuthzCatalog(); | ||
| mockUseAuthzCatalog.mockReturnValue({ | ||
| getRole: jest.fn((id) => (id === 'custom-role-123' ? mockRole : null)), | ||
| isLoading: false, | ||
| }); |
There was a problem hiding this comment.
| beforeEach(() => { | |
| mockAuthzCatalog(); | |
| mockUseAuthzCatalog.mockReturnValue({ | |
| getRole: jest.fn((id) => (id === 'custom-role-123' ? mockRole : null)), | |
| isLoading: false, | |
| }); | |
| beforeEach(() => { | |
| mockAuthzCatalog({ catalog: { ...authzCatalog, roles: [...authzCatalog.roles, customRole] } }); |
| id: 'scope', | ||
| Header: getCellHeader('scope', intl.formatMessage(messages['authz.custom.role.members.table.column.header.scope']), columnsWithFiltersApplied), | ||
| accessor: 'scope', | ||
| Cell: ScopeNameCell, |
There was a problem hiding this comment.
ScopeNameCell displays only the scope name, so an Organization column must follow it to distinguish organization-level aggregate scopes.
However, according to the design, this table should use the same format as the Assigned Roles column in the TeamMembers table:
WE should extract this code in a sharable component and reuse it here:
| pageCount={pageCount} | ||
| pageSize={TABLE_DEFAULT_PAGE_SIZE} | ||
| > | ||
| <TableControlBar onFilterChange={setColumnsWithFiltersApplied} countLabel={showingLabel} /> |
There was a problem hiding this comment.
| ); | ||
| }; | ||
|
|
||
| const MembersTable = ({ onDelete }: MembersTableProps) => { |
There was a problem hiding this comment.
I suggest to rename to RoleMembersTable or something similar to avoid confusion with existing TeamMembersTable
| @@ -0,0 +1,110 @@ | |||
| import { useMemo } from 'react'; | |||
There was a problem hiding this comment.
nit: according to this proposal index is only the public interface. In the proposal it re-exports things (export { authzRoutes }, export { TeamAssignmentsTable, … }) and holds no component code. It quotes the ADR: "A feature should have a public interface exposed via an index.js file."
| additionalColumns={additionalColumns} | ||
| columns={columns} | ||
| data={flattenedMembers} | ||
| fetchData={handleTableFetch} |
There was a problem hiding this comment.
Could you debounce fetchData here? DataTable calls it on every state change, so typing in the username search sends one request per keystroke. TeamMembersTable already handles this (TeamMembersTable.tsx:95-97), so we can copy that:
const fetchData = useMemo(() => debounce(handleTableFetch, 500), [handleTableFetch]);
useEffect(() => () => fetchData.cancel(), [fetchData]);There was a problem hiding this comment.
I have a couple of concerns that may be worth addressing in this PR:
1 - Scope filter options
The scope filter lists every scope the user can see, but this table only shows members of one role. Roles have a single scope type today (ADR 0028, "Query by scope type"), so on a course role, choosing a library always empties the table.
Could we pass role.scopeTypes down to ScopesFilter and use it as the scopeType of useScopes? That way the filter only offers scopes of the role's resource type. If the prop is optional, the team members table stays unchanged. This isn't in the acceptance criteria or the ADRs, so I'm fine with a follow-up if you prefer.
2 - Unknown role id
Opening /admin-console/authz/role/<unknown-id> shows an empty role page instead of the Not Found page. The title and breadcrumb are blank, the header shows the built-in role actions (Duplicate role and Assign role), and the members table says "No users assigned to this role".
I think this falls under the "Empty/loading/error states" acceptance criterion, and users will reach these URLs:
The page is keyed by an id in the URL, so users can bookmark or share it.
Custom roles can be deleted (ADR 0016), which leaves old links pointing at roles that no longer exist.
getRole also returns undefined when the user can't view the role's scope type, because the catalog only loads the scope types the user can view. Not Found avoids revealing that the role exists.
The module's ErrorBoundary already handles this, as the * route does. After the loading check:
if (!role) { throw new Error(CustomErrors.NOT_FOUND); }A test that checks an unknown id shows the Not Found page would cover it.
3 - Members request errors
MembersTable doesn't read error from useTeamMembersAssignments, so a failed request also shows "No users assigned to this role". TeamMembersTable already shows an error toast with a retry action for this case (showErrorToast(error, refetch)). Could we do the same here?
a823da8 to
9ed7740
Compare
9913bf7 to
3ed1033
Compare
3ed1033 to
511d807
Compare
| * this organization") is left to the breakdown, and the organization line is dropped | ||
| * since the scope line already says it. | ||
| */ | ||
| const ScopeSummary = ({ |
There was a problem hiding this comment.
Non-blocking: The scope summary relies on icons and visual layout to distinguish the scope type, organization, and reach. Screen readers may miss that context. We could add a localized accessible label describing the complete scope, reuse existing shared messages where appropriate, and prevent the visible content from being announced twice.
Suggest:
- Reuse existing labels and helpers when possible: “All courses,” “All libraries,” and the platform-wide labels already exist.
getScopeTypeandgetAggregateScopeTypecan identify the resource type and scope reach consistently. - Keep wording consistent: We try to align the wizard and the tables wording, in this case it should be:
- For specific Scope:
'{scopeType, select, lib {Library} other {Course}} {scopeName} in the {organization} organization.', e.g “Course Science Fundamentals in organization Demo”. - For specific Aggregated Organization Scope:
'{scopeLabel} in the {organization} organization.', e.g., "Al courses in Demo organization" - For platform-wide scope:
'{scopeLabel} on the platfom'. e.g., "Al courses on the platform"
- For specific Scope:
- Prevent duplicate announcements: Give the scope container one accessible name using
role="group"andaria-label. Mark its duplicate visual text and decorative iconsaria-hidden="true".
9ed7740 to
4538e4a
Compare

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.
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
Data Flattening Strategy: Transforms nested TeamMember.assignments into flat rows so each assignment is a table row with direct access to scope/org/scopeDisplayName metadata needed by ScopeNameCell.
Query Settings Merge: Merges roleId into querySettings via useMemo instead of useState to ensure single API call with correct role filter (avoiding double-call issue).
Role ID over Name: Uses roleId for filtering instead of URL-encoded roleName to avoid encoding/decoding complexity.
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.