feat: add operation quota reset button - #198
Conversation
|
Warning Review limit reached
Next review available in: 57 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (6)
📝 WalkthroughWalkthroughAdds a user quota reset action with API integration and translated feedback. Profile quota identifiers and payload fields are aligned with the operation quota contract. ChangesQuota Management
Sequence Diagram(s)sequenceDiagram
participant User
participant UserModificationForm
participant UserAdminSrv
participant Backend
User->>UserModificationForm: click reset-quota IconButton
UserModificationForm->>UserAdminSrv: resetUserCurrentQuotaUsage(sub)
UserAdminSrv->>Backend: POST quota reset request
Backend-->>UserAdminSrv: response
UserAdminSrv-->>UserModificationForm: resolve or throw
UserModificationForm-->>User: show translated success or error snack
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
30b23c1 to
367bd33
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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 `@src/pages/users/modification/user-modification-form.tsx`:
- Around line 108-117: The reset quota IconButton in user-modification-form
should be disabled when no user is selected instead of relying on
handleResetQuota to return early. Update the IconButton around the LockReset
action to use the existing sub state as its disabled condition, and keep the
tooltip/message behavior intact so the UI clearly reflects when the action is
unavailable.
In `@src/services/user-admin.ts`:
- Around line 72-82: The quota reset request in resetUserCurrentQuotaUsage is
building the path with the raw sub value, so update the URL construction to
encode the user identifier before interpolation. Use encodeURIComponent(sub)
when forming the backendFetch target in resetUserCurrentQuotaUsage so special
characters in sub cannot break the endpoint path.
In `@src/translations/fr.json`:
- Around line 47-49: Fix the French translation strings by correcting the accent
in “opération” in all three entries under users.table.*resetQuota, and update
the success message in users.table.success.resetQuota so “réinitialisé” agrees
with the feminine noun “Utilisation” by changing it to the feminine form. Use
the existing translation keys in fr.json as the reference point and keep the
rest of each string unchanged.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2ad52445-40fc-4cf8-812c-eec71f878988
📒 Files selected for processing (4)
src/pages/users/modification/user-modification-form.tsxsrc/services/user-admin.tssrc/translations/en.jsonsrc/translations/fr.json
367bd33 to
f30e462
Compare
82eabe1 to
d342462
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/pages/profiles/modification/profile-modification-dialog.tsx (1)
170-208: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse optional chaining to simplify the mappings.
The repetitive ternary operator checks can be concisely rewritten using the optional chaining operator (
?.). It safely handles nullish values and evaluates toundefined, making the object initialization significantly cleaner.♻️ Proposed refactor
- [USER_QUOTA_CASE_NB]: response.maxOperationQuota - ? response.maxOperationQuota[MAX_ALLOWED_CASES] - : undefined, - [USER_QUOTA_BUILD_NB]: response.maxOperationQuota - ? response.maxOperationQuota[MAX_ALLOWED_BUILD] - : undefined, - [USER_QUOTA_LOADFLOW_NB]: response.maxOperationQuota - ? response.maxOperationQuota[MAX_ALLOWED_LOADFLOW] - : undefined, - [USER_QUOTA_SECURITY_NB]: response.maxOperationQuota - ? response.maxOperationQuota[MAX_ALLOWED_SECURITY] - : undefined, - [USER_QUOTA_SENSITIVITY_NB]: response.maxOperationQuota - ? response.maxOperationQuota[MAX_ALLOWED_SENSITIVITY] - : undefined, - [USER_QUOTA_SHORTCIRCUIT_NB]: response.maxOperationQuota - ? response.maxOperationQuota[MAX_ALLOWED_SHORT_CIRCUIT] - : undefined, - [USER_QUOTA_VOLTAGE_INIT_NB]: response.maxOperationQuota - ? response.maxOperationQuota[MAX_ALLOWED_VOLTAGE_INIT] - : undefined, - [USER_QUOTA_PCC_MIN_NB]: response.maxOperationQuota - ? response.maxOperationQuota[MAX_ALLOWED_PCC_MIN] - : undefined, - [USER_QUOTA_STATE_ESTIMATION_NB]: response.maxOperationQuota - ? response.maxOperationQuota[MAX_ALLOWED_STATE_ESTIMATION] - : undefined, - [USER_QUOTA_BALANCE_ADJUSTEMENT_NB]: response.maxOperationQuota - ? response.maxOperationQuota[MAX_ALLOWED_BALANCE_ADJUSTEMENT] - : undefined, - [USER_QUOTA_DYNAMIC_SIMULATION_INIT_NB]: response.maxOperationQuota - ? response.maxOperationQuota[MAX_ALLOWED_DYNAMIC_SIMULATION] - : undefined, - [USER_QUOTA_DYNAMIC_SECURITY_INIT_NB]: response.maxOperationQuota - ? response.maxOperationQuota[MAX_ALLOWED_DYNAMIC_SECURITY] - : undefined, - [USER_QUOTA_DYNAMIC_MARGIN_INIT_NB]: response.maxOperationQuota - ? response.maxOperationQuota[MAX_ALLOWED_DYNAMIC_MARGIN] - : undefined, + [USER_QUOTA_CASE_NB]: response.maxOperationQuota?.[MAX_ALLOWED_CASES], + [USER_QUOTA_BUILD_NB]: response.maxOperationQuota?.[MAX_ALLOWED_BUILD], + [USER_QUOTA_LOADFLOW_NB]: response.maxOperationQuota?.[MAX_ALLOWED_LOADFLOW], + [USER_QUOTA_SECURITY_NB]: response.maxOperationQuota?.[MAX_ALLOWED_SECURITY], + [USER_QUOTA_SENSITIVITY_NB]: response.maxOperationQuota?.[MAX_ALLOWED_SENSITIVITY], + [USER_QUOTA_SHORTCIRCUIT_NB]: response.maxOperationQuota?.[MAX_ALLOWED_SHORT_CIRCUIT], + [USER_QUOTA_VOLTAGE_INIT_NB]: response.maxOperationQuota?.[MAX_ALLOWED_VOLTAGE_INIT], + [USER_QUOTA_PCC_MIN_NB]: response.maxOperationQuota?.[MAX_ALLOWED_PCC_MIN], + [USER_QUOTA_STATE_ESTIMATION_NB]: response.maxOperationQuota?.[MAX_ALLOWED_STATE_ESTIMATION], + [USER_QUOTA_BALANCE_ADJUSTEMENT_NB]: response.maxOperationQuota?.[MAX_ALLOWED_BALANCE_ADJUSTEMENT], + [USER_QUOTA_DYNAMIC_SIMULATION_INIT_NB]: response.maxOperationQuota?.[MAX_ALLOWED_DYNAMIC_SIMULATION], + [USER_QUOTA_DYNAMIC_SECURITY_INIT_NB]: response.maxOperationQuota?.[MAX_ALLOWED_DYNAMIC_SECURITY], + [USER_QUOTA_DYNAMIC_MARGIN_INIT_NB]: response.maxOperationQuota?.[MAX_ALLOWED_DYNAMIC_MARGIN],🤖 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 `@src/pages/profiles/modification/profile-modification-dialog.tsx` around lines 170 - 208, Replace the repetitive response.maxOperationQuota ternary checks in the profile modification dialog’s quota mapping with optional chaining property access. Preserve each existing quota constant mapping and the resulting undefined value when maxOperationQuota is nullish.
🤖 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.
Nitpick comments:
In `@src/pages/profiles/modification/profile-modification-dialog.tsx`:
- Around line 170-208: Replace the repetitive response.maxOperationQuota ternary
checks in the profile modification dialog’s quota mapping with optional chaining
property access. Preserve each existing quota constant mapping and the resulting
undefined value when maxOperationQuota is nullish.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 5028643a-2a61-472f-9e7a-2f0ad49fecfb
📒 Files selected for processing (3)
src/pages/profiles/modification/profile-modification-dialog.tsxsrc/pages/profiles/modification/profile-modification-form.tsxsrc/services/user-admin.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/services/user-admin.ts
d342462 to
046f3ef
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@src/pages/profiles/modification/profile-modification-form.tsx`:
- Around line 25-55: Rename USER_QUOTA_NB to UserQuotaNb and MAX_ALLOWED_KEYS to
MaxAllowedKeys, adding trailing commas where required by Prettier. Move these
enums and other exported constants from the React component module into a
separate profile-modification-constants module, then update all affected imports
and references while keeping the component module focused on React exports.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 231ff743-8274-4657-abb1-ca370e3125e1
📒 Files selected for processing (3)
src/pages/profiles/modification/profile-modification-dialog.tsxsrc/pages/profiles/modification/profile-modification-form.tsxsrc/services/user-admin.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/pages/profiles/modification/profile-modification-dialog.tsx
- src/services/user-admin.ts
046f3ef to
9a95b77
Compare
386c062 to
3aced50
Compare
|



PR Summary
add operation quota reset button in case of miscalculation in the backend