Skip to content

Add tenant member management UI#29

Open
Tianhao-Gu wants to merge 3 commits intomainfrom
feature/tenant-member-management
Open

Add tenant member management UI#29
Tianhao-Gu wants to merge 3 commits intomainfrom
feature/tenant-member-management

Conversation

@Tianhao-Gu
Copy link
Copy Markdown

@Tianhao-Gu Tianhao-Gu commented Mar 26, 2026

Screenshot 2026-03-25 at 11 25 36 PM Screenshot 2026-03-25 at 11 25 49 PM

Summary

  • Full-stack tenant member management: stewards can view, add, and remove members from a new "Manage Members" tab on tenant nodes in the sidebar tree
  • "Manage Members" only visible to stewards/admins — uses a new visible predicate on IMenuItem, gated by is_steward flag from the /tenants endpoint
  • Backend adds REST endpoints for tenant members (CRUD), user names listing, and tenant summaries, with real berdl_notebook_utils integration and automatic mock fallback
  • Frontend AddMemberForm uses a <datalist>-based searchable dropdown populated from the user names API, filtering out existing members
  • managementApi.ts reuses shared serverGet/serverPost/serverDelete from api.ts — no duplicated HTTP boilerplate
  • Path parameter validation rejects encoded slashes and traversal sequences
  • Accessibility: aria-label on remove button and username input
  • Mock mode: add/remove mutate in-memory store so refetch reflects changes

New endpoints

Method Path Description
GET /api/tenant-data-browser/users/names List all usernames (for Add Member dropdown)
GET /api/tenant-data-browser/tenants List tenants with steward/member flags
GET /api/tenant-data-browser/tenants/{name}/members List members of a tenant
POST /api/tenant-data-browser/tenants/{name}/members/{user} Add member with permission
DELETE /api/tenant-data-browser/tenants/{name}/members/{user} Remove member

Test plan

  • Build extension wheel and install in spark_notebook Docker stack
  • Verify "Manage Members" button appears only on steward tenant nodes
  • Verify "Manage Members" button hidden for non-steward tenants
  • Open Manage Members tab — confirm member list loads with real data
  • Add a member via the searchable dropdown — confirm they appear in the list
  • Remove a member — confirm removal after confirmation dialog
  • Verify mock fallback works when berdl_notebook_utils is not installed
  • Verify members tab restores correctly on page reload

Add full-stack tenant member management: stewards can view members,
add new members (with searchable username dropdown), set permissions,
and remove members — all from a new "Manage Members" tab accessible
via tenant nodes in the sidebar tree.

Backend:
- New REST endpoints: GET/POST/DELETE for tenant members, GET for
  user names listing, GET for tenant summaries
- Real implementation proxies to berdl_notebook_utils with automatic
  mock fallback for development
- Input validation (permission values, JSON body parsing)

Frontend:
- TenantMembersTab with member table, access badges, steward icons
- AddMemberForm with datalist-based searchable username dropdown
  that filters out existing members
- managementApi client reuses shared serverGet/serverPost/serverDelete
  from api.ts (no duplicated boilerplate)
- Members tabs tracked with WidgetTracker for layout restore
@github-actions
Copy link
Copy Markdown

Prerelease: pr-29

Wheel will be attached once the build completes. Updated on each push.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds end-to-end tenant member management (view/add/remove) to the Tenant Data Browser extension by introducing new server endpoints and a new “Manage Members” tab reachable from tenant nodes in the sidebar tree.

Changes:

  • Added Python server REST endpoints for listing users, listing tenants, and tenant member CRUD with BERDL integration + mock fallback.
  • Added a new JupyterLab main-area “Members” tab and a “Manage Members” action on tenant nodes.
  • Added a small frontend management API client plus shared HTTP helpers for GET/POST/DELETE.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tenant_data_browser/mock_definitions.py Adds mock implementations for user listing and tenant membership operations.
tenant_data_browser/mock_data.py Introduces mock user list, tenant summaries, and tenant member fixtures.
tenant_data_browser/handlers.py Adds authenticated REST handlers + routes for usernames, tenants, and tenant members CRUD.
tenant_data_browser/cdm_methods.py Adds BERDL import wrappers for tenant management and user listing with mock fallback.
src/providers/berdlProvider.tsx Adds “Manage Members” menu/button on tenant nodes to open the members tab.
src/membersTab.ts Defines the command ID and target type for opening members tabs.
src/managementApi.ts Implements client calls for usernames and tenant member CRUD using shared server helpers.
src/index.ts Registers the members tab command and integrates layout restoration/tracking for the new tab type.
src/api.ts Exposes serverGet and adds shared serverPost/serverDelete + improved error parsing.
src/TenantMembersTab.tsx Implements the members management UI (list members, add via datalist, remove with confirmation).
Comments suppressed due to low confidence (1)

tenant_data_browser/mock_definitions.py:220

  • remove_tenant_member in mock mode does not actually remove the user from MOCK_TENANT_MEMBERS. Since the UI refetches after deletion, the removed member will reappear under mocks. Consider updating the mock store to delete the matching entry (and possibly raising a 404-like error when the user isn’t present).
def remove_tenant_member(tenant_name, username):
    """
    Mock function that simulates removing a member from a tenant.
    Mimics berdl_notebook_utils.minio_governance.tenant_management.remove_tenant_member().

    Args:
        tenant_name (str): Name of the tenant.
        username (str): Username to remove.
    """
    time.sleep(MOCK_DELAY)


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Add aria-label to remove-member button and username input (#1, #4)
- Add Content-Type: application/json header to serverPost (#3)
- Validate decoded path params in tenant handlers to reject encoded
  slashes and path traversal sequences (#5)
- Mutate in-memory mock store on add/remove so refetch reflects
  changes in mock mode (#2)
Add `visible` predicate to IMenuItem so menu items can be
conditionally shown per node. Use it to gate "Manage Members"
behind steward status — fetched from the /tenants endpoint
during tree initialization (best-effort, fails silently).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants