Repository navigation
feat(admin): ✨ add report reasons management module with CRUD operations - #890
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
React Doctor found 4 new issues in 2 files · 2 errors & 2 warnings · score 84 / 100 (Needs work) · 0 fixed · vs Errors
2 warnings
Reviewed by React Doctor for commit |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8ba486676b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (total >= MODERATION_LIMITS.maxReportReasons) { | ||
| return c.json({ error: "limit_reached" }, 409); |
There was a problem hiding this comment.
Enforce the reason limit atomically
Serialize this check with the insertion or enforce the maximum in the database. If two administrators create reasons while nine exist, both requests can observe total === 9 and both insert, leaving 11 reasons despite the documented hard limit.
Useful? React with 👍 / 👎.
| const [{ total }] = await db | ||
| .select({ total: count() }) | ||
| .from(core_moderation_report_reasons); | ||
| if (total <= 1) return c.json({ error: "last_reason" }, 409); |
There was a problem hiding this comment.
Prevent concurrent deletion of the final reasons
Make the count check and deletion one serialized operation. When two reasons remain, two administrators can delete different reasons concurrently; both requests can read total === 2, then both transactions delete successfully, leaving no reason and an empty report dialog.
Useful? React with 👍 / 👎.
| const observer = new ResizeObserver(([entry]) => { | ||
| setHeight(entry.borderBoxSize[0].blockSize); | ||
| }); | ||
| observer.observe(element); |
There was a problem hiding this comment.
React Doctor · react-doctor/effect-needs-cleanup (error)
observe creates a subscription in a function that outlives the render, with no cleanup path. Store the handle and release it, or move this into a useEffect that returns cleanup, so it does not leak after unmount.
Fix → Return a cleanup function that stops the subscription or timer: return () => target.removeEventListener(name, handler) for listeners, return () => clearInterval(id) or clearTimeout(id) for timers, return () => observer.disconnect() for observers, return () => socket.close() for connections, or return unsubscribe if the subscribe call already gave you one.
| <MotionConfig reducedMotion="user"> | ||
| <MotionFeatures> | ||
| <m.div | ||
| animate={{ height: visibleHeight }} |
There was a problem hiding this comment.
React Doctor · react-doctor/no-layout-property-animation (error)
This stutters because animating "height" makes the browser redo page layout every frame, so animate transform or scale instead, or use the layout prop
Fix → Use transform: translateX() or scale() instead. They animate smoothly without making the browser redo layout or repaint
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b4e3b097e4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| @@ -1,495 +0,0 @@ | |||
| import { describe, expect, it } from "vitest"; | |||
There was a problem hiding this comment.
Restore the deleted navigation model tests
Adding the moderation group only requires updating the root-admin navigation expectation, but this deletes the only direct suite for adminNavDeclarations, resolveAdminNav, and adminNavNamespaces, including plugin permission namespacing and opt-out behavior. The remaining search-sources.test.ts covers only a subset through the flattened palette, so sidebar and namespace regressions can now pass unnoticed; restore and update this suite instead.
AGENTS.md reference: AGENTS.md:L128-L132
Useful? React with 👍 / 👎.
| }); | ||
| if (!created) return c.json({ error: "limit_reached" }, 409); | ||
|
|
||
| await saveReasonWords(c, created.id, body); |
There was a problem hiding this comment.
Roll back creation when translations fail
Keep the reason row and its language words in one transaction. If saveReasonWords fails after the preceding transaction commits—for example, because the request supplies a nonexistent languageCode, which this schema permits but the language foreign key rejects—the endpoint returns an error while leaving a titleless reason that is visible to members and consumes one of the ten slots.
Useful? React with 👍 / 👎.
Improving Documentation
pnpm lint:fixto fix formatting issues before opening the PR.Description
What?
Why?