Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 28, 2025

Implement cascading deletion of user roles and edits with project visibility

Backend Changes

  • UserController: Enhanced DeleteUser to cascade delete all associated UserRole and UserEdit records. Added validation to prevent admin user deletion (returns 403).
  • New endpoint: GetUserProjects returns project info and roles for deletion confirmation.
  • UserProjectInfo DTO: Simple model containing projectId, projectName, and role.
// Cascade deletion implementation
foreach (var (projectId, userEditId) in user.WorkedProjects)
    await _userEditRepo.Delete(projectId, userEditId);
foreach (var (projectId, userRoleId) in user.ProjectRoles)
    await _userRoleRepo.Delete(projectId, userRoleId);

Tests

Added 5 test cases covering:

  • Cascading deletion of roles and edits
  • Admin user deletion prevention
  • Project listing endpoint (happy path, auth, not found)

Frontend Changes

  • ConfirmDeletion dialog: Fetches and displays user's project memberships with roles before deletion. Shows error state with red text and disables Delete button if project info fails to load.
  • backend/index.ts: Added getUserProjects() function.

Screenshots

User without projects

User with lots of projects, some archived

Roles translated for UI language


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.


This change is Reviewable

Copilot AI changed the title [WIP] Update user deletion process with role and edit management Implement cascading deletion of user roles and edits with project visibility Oct 28, 2025
Copilot AI requested a review from imnasnainaec October 28, 2025 19:11
Copilot finished work on behalf of imnasnainaec October 28, 2025 19:11
@github-actions
Copy link

github-actions bot commented Oct 28, 2025

⚠️ Commit Message Format Issues ⚠️
commit c84025e3c1:
1: T1 Title exceeds max length (74>72): "Add frontend support for displaying user projects in deletion confirmation"

@codecov
Copy link

codecov bot commented Oct 28, 2025

Codecov Report

❌ Patch coverage is 77.27273% with 15 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.66%. Comparing base (ede2527) to head (e60818e).
⚠️ Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
...ts/SiteSettings/UserManagement/ConfirmDeletion.tsx 0.00% 14 Missing ⚠️
Backend/Controllers/UserController.cs 97.91% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3971      +/-   ##
==========================================
+ Coverage   74.58%   74.66%   +0.07%     
==========================================
  Files         293      293              
  Lines       10817    10890      +73     
  Branches     1353     1364      +11     
==========================================
+ Hits         8068     8131      +63     
- Misses       2354     2362       +8     
- Partials      395      397       +2     
Flag Coverage Δ
backend 85.66% <98.07%> (+0.20%) ⬆️
frontend 66.11% <0.00%> (-0.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.

@imnasnainaec imnasnainaec added the 🟩Low Low-priority PR label Oct 29, 2025
@github-actions github-actions bot added the goal label Nov 20, 2025
Copy link
Collaborator

@imnasnainaec imnasnainaec left a comment

Choose a reason for hiding this comment

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

@imnasnainaec reviewed all commit messages.
Reviewable status: 0 of 15 files reviewed, all discussions resolved (waiting on @copilot)

@imnasnainaec imnasnainaec marked this pull request as ready for review November 20, 2025 16:00
Copy link
Contributor

@jasonleenaylor jasonleenaylor left a comment

Choose a reason for hiding this comment

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

Failing to get user info should fail the contents.

@jasonleenaylor reviewed 2 of 5 files at r2, 12 of 13 files at r3, all commit messages.
Reviewable status: 14 of 15 files reviewed, all discussions resolved (waiting on @copilot and @imnasnainaec)

Copy link
Contributor Author

Copilot AI commented Nov 20, 2025

Failing to get user info should fail the contents.

@jasonleenaylor reviewed 2 of 5 files at r2, 12 of 13 files at r3, all commit messages....

Fixed in e7d9591. When getUserProjects fails, the dialog now:

  • Sets a loadFailed state flag
  • Displays an error message in red ("Failed to load user projects...")
  • Keeps the Delete button disabled
  • Shows an error toast instead of a warning

Previously, the catch block only logged and showed a warning toast, leaving projInfo as undefined which caused the UI to show "Loading..." indefinitely while the button remained disabled without clear indication of the error state.

Copilot AI requested a review from jasonleenaylor November 20, 2025 19:57
Copilot finished work on behalf of jasonleenaylor November 20, 2025 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants