🐛 Fixed staff invite error for existing users#28294
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThis PR refines the invite-user modal to provide clearer error feedback when users attempt to invite existing users. It imports Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
a0afecf to
b7677be
Compare
closes [ONC-1778](https://linear.app/ghost/issue/ONC-1778/bad-error-message-when-inviting-staff-that-already-exist) Staff invite validation could miss existing users outside the first paginated users response, then show a generic failure toast even though the API returned a known duplicate-user validation error. Mapping that server validation back to the email field keeps the paginated staff list while preserving a useful form error.
b7677be to
81e2cea
Compare
ref [ONC-1778](https://linear.app/ghost/issue/ONC-1778/bad-error-message-when-inviting-staff-that-already-exist) The staff invite modal should not depend on a translated validation message or context string to identify duplicate staff users. The API now returns a stable USER_ALREADY_REGISTERED code for that validation, and the Admin UI maps that code to the existing inline email error.
|
|
||
| type RoleType = 'administrator' | 'editor' | 'author' | 'contributor' | 'super editor'; | ||
|
|
||
| const USER_ALREADY_REGISTERED_CODE = 'USER_ALREADY_REGISTERED'; |
There was a problem hiding this comment.
nit: unnecessary constant / abstraction, could inline it
if (validationError?.code === 'USER_ALREADY_REGISTERED') { ... }
There was a problem hiding this comment.
Agree to disagree here. I would class this as a classical magic string which I'd probably tidy up going through the code later on 😄 I guess that's more about personal preference in this case 😅
There was a problem hiding this comment.
Yeh definitely taste-based!
Personally, I go for:
- Abstract in a constant if used in multiple places (benefit: if updated, need to update a single place)
- Keep it inline if used in a single place (still have the same benefit of updating a single place, but don't create the overhead of an abstraction, i.e. having to jump to another piece of code when reading)
closes https://linear.app/ghost/issue/ONC-1778
Summary
Testing