Skip to content

[5424] Remove delete user, updates to enable/disable users#4894

Open
jvega190 wants to merge 9 commits into
craftercms:developfrom
jvega190:feature/5424
Open

[5424] Remove delete user, updates to enable/disable users#4894
jvega190 wants to merge 9 commits into
craftercms:developfrom
jvega190:feature/5424

Conversation

@jvega190

@jvega190 jvega190 commented Jun 16, 2026

Copy link
Copy Markdown
Member

craftercms/craftercms#5424

Summary by CodeRabbit

  • New Features
    • Added a “show disabled users” toggle to user management, with a per-user saved preference and automatic list refresh (including pagination reset).
    • User grid now includes an email column and shows a “Disabled” indicator for disabled accounts.
  • Improvements
    • Removed delete-user functionality from the edit user dialog; the workflow now supports password reset instead.
    • Deleted-user related backend support was removed from services, and stored disabled-user preference cleanup was added.
  • Documentation
    • Updated changelog formatting and added new 5.0.0 release-note entries.

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3b889952-871d-4873-bde5-6f9dba265a44

📥 Commits

Reviewing files that changed from the base of the PR and between e43b2f8 and e3025b5.

📒 Files selected for processing (3)
  • ui/app/src/CHANGELOG.md
  • ui/app/src/components/UserManagement/UserManagement.tsx
  • ui/app/src/utils/state.ts
💤 Files with no reviewable changes (1)
  • ui/app/src/components/UserManagement/UserManagement.tsx
✅ Files skipped from review due to trivial changes (1)
  • ui/app/src/CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • ui/app/src/utils/state.ts

Walkthrough

Adds persisted show-disabled-user filtering to the user management grid, removes delete-user handling from the edit dialog, and adds two 5.0.0 changelog bullets for those removals.

Changes

User Management Changes

Layer / File(s) Summary
Preference storage and fetchAll option
ui/app/src/utils/state.ts, ui/app/src/services/users.ts
New localStorage helpers store, read, and remove the per-user showDisabledUsers preference. fetchAll accepts showDisabled?: boolean in its options type.
UserManagement state and preference cleanup
ui/app/src/components/UserManagement/UserManagement.tsx, ui/app/src/components/AccountManagement/utils.tsx
UserManagement loads the stored showDisabled value for the active user, passes it into fetchAll, updates its callback dependencies, and persists changes while resetting pagination. AccountManagement clears the stored preference from the Miscellaneous preferences group.
UsersGridUI toggle and status display
ui/app/src/components/UsersGrid/UsersGridUI.tsx
UsersGridUIProps adds showDisabled and onShowDisabledChange. The table header adds an email column and checkbox control, and each row renders user.email plus a Disabled chip when the user is not enabled.
EditUserDialog delete flow removal
ui/app/src/components/EditUserDialog/utils.ts, ui/app/src/components/EditUserDialog/EditUserDialogContainer.tsx, ui/app/src/components/EditUserDialog/EditUserDialogUI.tsx
EditUserDialogUIProps drops onDelete and adds onResetPassword. The container removes the trash import and delete handler, adds onUserEdited calls after enable and disable, and stops passing onDelete. The UI removes the delete confirmation dropdown, its imports, and related translation strings.
Changelog bullets
ui/app/src/CHANGELOG.md
The changelog adds a 5.0.0 UserManagement bullet noting delete-user removal and a services bullet noting removal of users/trash.

Sequence Diagram(s)

sequenceDiagram
  participant UsersGridUI
  participant UserManagement
  participant localStorage
  participant fetchAll

  UsersGridUI->>UserManagement: onShowDisabledChange(checked)
  UserManagement->>localStorage: setStoredShowDisabledUsers(user, checked)
  UserManagement->>fetchAll: fetchAll({ showDisabled, keyword, offset })
  fetchAll-->>UserManagement: PagedArray<User>
  UserManagement-->>UsersGridUI: showDisabled, users
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • rart
  • sumerjabri
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: removing delete-user behavior and updating user enable/disable flow.
Description check ✅ Passed The PR description provides the ticket reference requested by the template and is sufficient for this repository.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
ui/app/src/components/UserManagement/UserManagement.tsx (1)

56-71: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Prevent double/racy fetches when toggling “show disabled users.”

Line 132 fires fetchUsers(keyword, 0) before setShowDisabled(checked) is reflected, so the first request uses stale showDisabled from Line 59. Then Line 71 causes useEffect (Line 74-77) to refetch after state update. This two-request pattern can render stale data if responses arrive out of order.

Also applies to: 128-133

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/app/src/components/UserManagement/UserManagement.tsx` around lines 56 -
71, The fetchUsers callback captures the current showDisabled value from
closure, but when the toggle handler calls fetchUsers before updating the
showDisabled state, the request uses the stale value, causing a double-fetch
when the state update triggers a useEffect. To fix this, update the showDisabled
state before calling fetchUsers in the toggle handler, or modify the fetchUsers
callback to accept showDisabled as a parameter so you can pass the new value
directly to it, ensuring the first request uses the correct showDisabled value
and avoiding the unnecessary second fetch triggered by the dependency array.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ui/app/src/CHANGELOG.md`:
- Line 93: In the CHANGELOG.md file on line 93, add a period after the
abbreviation "etc" to make it "etc." in the TODO comment line. The text should
read "FE2 TODO: image=>image-picker, text=>input, etc. services/contentType
typeMap removed" to follow standard English style conventions for abbreviations.
- Line 18: In the CHANGELOG.md file at line 18, there is a missing space before
the backtick in the text "Replaced by`sxs` prop." Add a space between "by" and
the backtick to read "Replaced by `sxs` prop." For improved clarity and grammar,
consider updating it to "Replaced by the `sxs` prop." instead.

---

Outside diff comments:
In `@ui/app/src/components/UserManagement/UserManagement.tsx`:
- Around line 56-71: The fetchUsers callback captures the current showDisabled
value from closure, but when the toggle handler calls fetchUsers before updating
the showDisabled state, the request uses the stale value, causing a double-fetch
when the state update triggers a useEffect. To fix this, update the showDisabled
state before calling fetchUsers in the toggle handler, or modify the fetchUsers
callback to accept showDisabled as a parameter so you can pass the new value
directly to it, ensuring the first request uses the correct showDisabled value
and avoiding the unnecessary second fetch triggered by the dependency array.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c184db9d-edfe-41f6-9330-60f32700e404

📥 Commits

Reviewing files that changed from the base of the PR and between c6402fd and 2506660.

📒 Files selected for processing (9)
  • ui/app/src/CHANGELOG.md
  • ui/app/src/components/AccountManagement/utils.tsx
  • ui/app/src/components/EditUserDialog/EditUserDialogContainer.tsx
  • ui/app/src/components/EditUserDialog/EditUserDialogUI.tsx
  • ui/app/src/components/EditUserDialog/utils.ts
  • ui/app/src/components/UserManagement/UserManagement.tsx
  • ui/app/src/components/UsersGrid/UsersGridUI.tsx
  • ui/app/src/services/users.ts
  • ui/app/src/utils/state.ts
💤 Files with no reviewable changes (1)
  • ui/app/src/components/EditUserDialog/EditUserDialogUI.tsx

Comment thread ui/app/src/CHANGELOG.md Outdated
Comment thread ui/app/src/CHANGELOG.md Outdated
…instead of a ref, and update UsersGridUI layout for better alignment. Fix getStoredShowDisabledUsers to return false instead of null when no value is found.
@jvega190

Copy link
Copy Markdown
Member Author

Outside diff range comment addressed

@jvega190

Copy link
Copy Markdown
Member Author

@coderabbitai can you check if everything looks good? Please give it a final review before I hand over for human review

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
echo "=== EditUserDialogContainer.tsx ===" 
cat ui/app/src/components/EditUserDialog/EditUserDialogContainer.tsx

echo ""
echo "=== EditUserDialogUI.tsx ===" 
cat ui/app/src/components/EditUserDialog/EditUserDialogUI.tsx

echo ""
echo "=== EditUserDialog/utils.ts ===" 
cat ui/app/src/components/EditUserDialog/utils.ts

echo ""
echo "=== UserManagement.tsx ===" 
cat ui/app/src/components/UserManagement/UserManagement.tsx

echo ""
echo "=== UsersGridUI.tsx ===" 
cat ui/app/src/components/UsersGrid/UsersGridUI.tsx

echo ""
echo "=== services/users.ts ===" 
cat ui/app/src/services/users.ts

echo ""
echo "=== utils/state.ts ===" 
cat ui/app/src/utils/state.ts

echo ""
echo "=== AccountManagement/utils.tsx ===" 
cat ui/app/src/components/AccountManagement/utils.tsx

Length of output: 69910



@jvega190 The PR looks good overall! The core logic is solid — the enable/disable flow correctly calls onUserEdited() after success, showDisabled state is properly initialized from and persisted to localStorage, pagination resets to zero on toggle, and the preference cleanup in AccountManagement is wired up correctly.

There are a few leftover artifacts from the delete feature removal that should be cleaned up before human review:

EditUserDialogUI.tsx — unused imports & translation messages:

// These two imports are no longer used (delete UI was removed):
import ConfirmDropdown from '../ConfirmDropdown';        // ← remove
import DeleteRoundedIcon from '`@mui/icons-material/DeleteRounded`'; // ← remove

// These three translation keys in the `translations` object are also orphaned:
confirmHelperText: { ... },  // ← remove
confirmOk: { ... },          // ← remove
confirmCancel: { ... },      // ← remove

EditUserDialogContainer.tsx — unused translation:

const translations = defineMessages({
  userDeleted: {              // ← remove (delete handler no longer exists)
    id: 'userInfoDialog.userDeleted',
    defaultMessage: 'User deleted successfully'
  },
  ...
});

Everything else — the fetchAll signature update, UsersGridUI email column + disabled chip + show-disabled checkbox, utils/state.ts new helpers, and the AccountManagement preference cleanup — all look correct. Just strip out those dead references and it's ready for human review. 🐇

@jvega190

Copy link
Copy Markdown
Member Author

@coderabbitai can you check if everything looks good? Please give it a final review before I hand over for human review

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
echo "=== EditUserDialogUI.tsx ==="
cat ui/app/src/components/EditUserDialog/EditUserDialogUI.tsx

echo ""
echo "=== EditUserDialogContainer.tsx ==="
cat ui/app/src/components/EditUserDialog/EditUserDialogContainer.tsx

echo ""
echo "=== UserManagement.tsx ==="
cat ui/app/src/components/UserManagement/UserManagement.tsx

echo ""
echo "=== UsersGridUI.tsx ==="
cat ui/app/src/components/UsersGrid/UsersGridUI.tsx

echo ""
echo "=== services/users.ts ==="
cat ui/app/src/services/users.ts

echo ""
echo "=== utils/state.ts ==="
cat ui/app/src/utils/state.ts

echo ""
echo "=== AccountManagement/utils.tsx ==="
cat ui/app/src/components/AccountManagement/utils.tsx

Length of output: 67785



@jvega190 Almost there! The two previously flagged import removals (ConfirmDropdown, DeleteRoundedIcon) and the userDeleted translation in the container are all gone. ✅

There's just one remaining artifact — three orphaned translation keys in EditUserDialogUI.tsx that still reference the deleted delete-user flow but are no longer used anywhere in the JSX:

// ui/app/src/components/EditUserDialog/EditUserDialogUI.tsx
const translations = defineMessages({
  externallyManaged: { ... }, // ✅ used
  siteName: { ... },           // pre-existing (out of scope)
  roles: { ... },              // pre-existing (out of scope)
  confirmHelperText: {         // ❌ remove — delete UI is gone
    id: 'userInfoDialog.helperText',
    defaultMessage: 'Delete user "{username}"?'
  },
  confirmOk: {                 // ❌ remove
    id: 'words.yes',
    defaultMessage: 'Yes'
  },
  confirmCancel: {             // ❌ remove
    id: 'words.no',
    defaultMessage: 'No'
  },
  invalidMinLength: { ... },   // ✅ used
});

Once those three entries are removed, the PR will be clean and ready for human review. Everything else looks solid! 🐇

@jvega190

Copy link
Copy Markdown
Member Author

@coderabbitai can you check if everything looks good? Please give it a final review before I hand over for human review

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
echo "=== EditUserDialogUI.tsx ==="
cat ui/app/src/components/EditUserDialog/EditUserDialogUI.tsx

Length of output: 12719



@jvega190 The PR is clean and ready for human review! 🎉

All previously flagged artifacts have been removed:

  • ConfirmDropdown & DeleteRoundedIcon imports — gone
  • userDeleted translation in EditUserDialogContainer — gone
  • confirmHelperText, confirmOk, confirmCancel translation keys in EditUserDialogUI — gone
  • onDelete prop — gone

The remaining translations object in EditUserDialogUI.tsx contains only actively used keys (externallyManaged, siteName, roles, invalidMinLength). Everything else — the enable/disable flow, showDisabled persistence, pagination reset, email column, disabled chip, and account management cleanup — is solid. Ship it! 🐇 🚀

@jvega190 jvega190 marked this pull request as ready for review June 19, 2026 15:04
@jvega190 jvega190 requested a review from rart as a code owner June 19, 2026 15:04
@rart

rart commented Jun 25, 2026

Copy link
Copy Markdown
Member

@coderabbitai, the last commit hasn't been reviewed. Please review and report findings.

@rart rart left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Conflicts

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Latest commits ==="
git log --oneline --decorate -n 5

echo
echo "=== HEAD commit metadata ==="
git show --no-patch --stat --format=fuller HEAD

echo
echo "=== Files changed in HEAD ==="
git diff-tree --no-commit-id --name-only -r HEAD

echo
echo "=== Diff for HEAD vs HEAD^ ==="
git diff --unified=3 HEAD^ HEAD

echo
echo "=== AST outlines for changed source files ==="
while IFS= read -r file; do
  case "$file" in
    *.ts|*.tsx|*.js|*.jsx)
      echo
      echo "--- outline: $file ---"
      ast-grep outline "$file" --view expanded || true
      ;;
  esac
done < <(git diff-tree --no-commit-id --name-only -r HEAD)

echo
echo "=== Full contents of changed source files ==="
while IFS= read -r file; do
  case "$file" in
    *.ts|*.tsx|*.js|*.jsx|*.json|*.md)
      echo
      echo "--- file: $file ---"
      sed -n '1,260p' "$file"
      ;;
  esac
done < <(git diff-tree --no-commit-id --name-only -r HEAD)

Length of output: 2672


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="ui/app/src/components/UsersGrid/UsersGridUI.tsx"

echo "=== Outline: $file ==="
ast-grep outline "$file" --view expanded || true

echo
echo "=== Relevant section around the latest change ==="
nl -ba "$file" | sed -n '1,180p'

echo
echo "=== Search for FormControlLabel usage in this file ==="
rg -n -C 4 'FormControlLabel|labelPlacement|Show disabled users|Checkbox' "$file"

Length of output: 1328


🏁 Script executed:

#!/bin/bash
set -euo pipefail

file="ui/app/src/components/UsersGrid/UsersGridUI.tsx"

echo "=== File contents (first 180 lines) ==="
sed -n '1,180p' "$file"

echo
echo "=== Grep for relevant JSX ==="
grep -n -E 'FormControlLabel|labelPlacement|Show disabled users|Checkbox|Typography' "$file"

Length of output: 6045



@rart I reviewed the latest commit (e43b2f89d09d7b4a0e8573a41c19cfe3dd70b7f1).

Findings: no issues found in that last commit.

It only updates ui/app/src/components/UsersGrid/UsersGridUI.tsx to add:

labelPlacement="start"

on the FormControlLabel for the Show disabled users checkbox, which matches the commit intent of placing the label before the checkbox. The existing checked and onChange wiring remains correct, so this looks like a safe UI-only adjustment.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

jvega190 added 2 commits June 25, 2026 12:12
…o feature/5424

# Conflicts:
#	ui/app/src/CHANGELOG.md
#	ui/app/src/utils/state.ts
@jvega190

Copy link
Copy Markdown
Member Author

@coderabbitai can you check if everything looks good? Please give it a final review before I hand over for human review

@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

@jvega190 Yes — this looks good to me for handoff to human review.

Final pass summary:

  • Previously flagged delete-user cleanup items are resolved
  • The enable/disable flow and onUserEdited() refresh behavior look correct
  • showDisabled persistence/reset behavior looks correct
  • UsersGridUI changes, including the email column, disabled chip, and checkbox wiring, look good
  • The latest commit appears safe and UI-only (labelPlacement="start" for the checkbox)

I don’t see any remaining issues from my side. Ready for human review. ✅

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@jvega190 jvega190 requested a review from rart June 25, 2026 18:16
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