Skip to content

feat: Role Detail View/Members Tab Management Feature - #291

Closed
diana-villalvazo-wgu wants to merge 15 commits into
openedx:jacobo/assign-role-rowfrom
WGU-Open-edX:diana/members-tab
Closed

diana-villalvazo-wgu wants to merge 15 commits into
openedx:jacobo/assign-role-rowfrom
WGU-Open-edX:diana/members-tab

Conversation

@diana-villalvazo-wgu

@diana-villalvazo-wgu diana-villalvazo-wgu commented Nov 20, 2026 •

Copy link
Copy Markdown

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

    • Duplicate Button (Standard Roles)
    • Edit button for role name editing (Custom Roles)
    • MoreVert dropdown menu with Duplicate and Delete actions (Custom Roles)
    • PersonAdd button to open member assignment wizard
  • Members Table: Display members filtered by role with search and scope filtering

    • Username search
    • Scope-based filtering
    • Pagination with configurable page size
    • Proper data flattening for nested assignments
  • Member Actions: Per-row action buttons

    • View: Navigate to member audit page (eye icon)
    • Delete: Remove member from role (trash icon)

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)

  • Delete member action: IconButton (needs implementation)
  • Duplicate role action: Menu item and Button (needs implementation)
  • Delete role action: Menu item (needs implementation)
  • Edit role name: Button (needs modal/inline edit)
  • Permissions tab: Empty placeholder (needs implementation)
  • Modify Wizard to take current role instead of allowing to chose others (needs implementation)

Screenshots

Standard Role

Screenshot 2026-11-20 at 9 28 37 a m

Custom Role

Screenshot 2026-11-20 at 9 29 40 a m

Support Info

Closes openedx/openedx-authz#575

LLM Usage

Built with assistance from Claude.

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Nov 20, 2026
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @diana-villalvazo-wgu!

This repository is currently maintained by @openedx/committers-frontend.

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 approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To 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:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where 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:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Nov 20, 2026
@diana-villalvazo-wgu
diana-villalvazo-wgu force-pushed the diana/members-tab branch 3 times, most recently from 7623e2c to 90b8d05 Compare November 20, 2026 16:31
@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.10%. Comparing base (9ed7740) to head (c9f7574).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@diana-villalvazo-wgu
diana-villalvazo-wgu force-pushed the diana/members-tab branch 2 times, most recently from 3953014 to 8e74526 Compare November 20, 2026 17:45
@diana-villalvazo-wgu diana-villalvazo-wgu moved this from Needs Triage to Ready for Review in Contributions Nov 20, 2026
onClick={handleViewUser}
alt={formatMessage(messages['authz.role.members.table.action.view.alt'])}
/>
<IconButton

@dcoa dcoa Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/types.ts Outdated
* 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 = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this to @src/authz-module/constants.ts please.

navigate(buildAuditUserPath(member.username));
};

return (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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';

@dcoa dcoa Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is not assertions here:

Suggested change
// 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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Screenshot from 2026-11-23 13-57-29

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?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No plans to deprecate that endpoint, it can be used.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raised an Issue on authz to add those attributes and implement this openedx/openedx-authz#652

original: mockMember,
};

const renderActionCell = (props = {}) => render(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the test utilities functions, for example, renderWrapper

Comment on lines +107 to +112
beforeEach(() => {
mockAuthzCatalog();
mockUseAuthzCatalog.mockReturnValue({
getRole: jest.fn((id) => (id === 'custom-role-123' ? mockRole : null)),
isLoading: false,
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

image

WE should extract this code in a sharable component and reuse it here:

scope: (
<div className="authz-scope-cell ml-3">
<span className="d-flex align-items-center">
<Icon src={scopeIcon} className="mr-2 flex-shrink-0 text-primary" size="xs" />
<span className="text-truncate text-gray-700 authz-scope-cell__name" title={scopeText}>{scopeText}</span>
</span>
{!aggregateType && (
<span className="d-flex align-items-center small text-gray-500 authz-scope-cell__org ml-4">
<Icon src={RESOURCE_ICONS.ORGANIZATION} className="mr-2 flex-shrink-0" size="xs" />
<span className="text-truncate" title={orgText}>{orgText}</span>
</span>
)}
</div>

pageCount={pageCount}
pageSize={TABLE_DEFAULT_PAGE_SIZE}
>
<TableControlBar onFilterChange={setColumnsWithFiltersApplied} countLabel={showingLabel} />

@dcoa dcoa Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The search box's placeholder comes from the columns that use Filter === TextFilter. Here only username does. Because of that the placeholder is displayed as:

image

We can update the placeholder or add (Filter === TextFilter to all the searchable columns (username, email)

);
};

const MembersTable = ({ onDelete }: MembersTableProps) => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to rename to RoleMembersTable or something similar to avoid confusion with existing TeamMembersTable

@@ -0,0 +1,110 @@
import { useMemo } from 'react';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]);

@jacobo-dominguez-wgu jacobo-dominguez-wgu left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

* this organization") is left to the breakdown, and the organization line is dropped
* since the scope line already says it.
*/
const ScopeSummary = ({

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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. getScopeType and getAggregateScopeType can 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"
  • Prevent duplicate announcements: Give the scope container one accessible name using role="group" and aria-label. Mark its duplicate visual text and decorative icons aria-hidden="true".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants