Skip to content

feat: add operation quota reset button - #198

Merged
GhilesA merged 5 commits into
mainfrom
feat/add_quota_reset
Jul 21, 2026
Merged

feat: add operation quota reset button#198
GhilesA merged 5 commits into
mainfrom
feat/add_quota_reset

Conversation

@GhilesA

@GhilesA GhilesA commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

PR Summary

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

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@GhilesA, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 57 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9ec2da8c-3a74-4778-925f-91cfde26cb44

📥 Commits

Reviewing files that changed from the base of the PR and between 046f3ef and 9f302fc.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (6)
  • package.json
  • src/pages/profiles/modification/max-allowed-keys.tsx
  • src/pages/profiles/modification/profile-modification-dialog.tsx
  • src/pages/profiles/modification/profile-modification-form.tsx
  • src/pages/profiles/modification/user-quota-nb.tsx
  • src/services/user-admin.ts
📝 Walkthrough

Walkthrough

Adds a user quota reset action with API integration and translated feedback. Profile quota identifiers and payload fields are aligned with the operation quota contract.

Changes

Quota Management

Layer / File(s) Summary
Profile quota contract and mapping
src/pages/profiles/modification/profile-modification-form.tsx, src/pages/profiles/modification/profile-modification-dialog.tsx, src/services/user-admin.ts
Updates quota identifiers to backend tokens and maps profile quota values through maxOperationQuota.
Quota reset API service
src/services/user-admin.ts
Adds resetUserCurrentQuotaUsage(sub: string): Promise<void> with encoded path handling, POST submission, and error propagation.
Form integration with snack feedback
src/pages/users/modification/user-modification-form.tsx, src/translations/en.json, src/translations/fr.json
Adds a reset button that reads the user identifier, invokes the service, and displays translated success or error messages.

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
Loading

Suggested reviewers: etiennehomer

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding an operation quota reset button.
Description check ✅ Passed The description matches the change and explains the reset button's purpose.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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.

@GhilesA
GhilesA force-pushed the feat/add_quota_reset branch from 30b23c1 to 367bd33 Compare July 7, 2026 14:57
@GhilesA
GhilesA requested review from flomillot and removed request for flomillot July 8, 2026 07:35
@GhilesA
GhilesA marked this pull request as ready for review July 8, 2026 07:39
@GhilesA
GhilesA marked this pull request as draft July 8, 2026 07:39
@GhilesA
GhilesA marked this pull request as ready for review July 8, 2026 07:41
@GhilesA
GhilesA requested review from EtienneLt and etiennehomer July 8, 2026 07:41

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5f26141 and 367bd33.

📒 Files selected for processing (4)
  • src/pages/users/modification/user-modification-form.tsx
  • src/services/user-admin.ts
  • src/translations/en.json
  • src/translations/fr.json

Comment thread src/pages/users/modification/user-modification-form.tsx
Comment thread src/services/user-admin.ts
Comment thread src/translations/fr.json Outdated
@GhilesA
GhilesA force-pushed the feat/add_quota_reset branch from 367bd33 to f30e462 Compare July 8, 2026 08:34

@EtienneLt EtienneLt 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.

Code Ok

@GhilesA
GhilesA force-pushed the feat/add_quota_reset branch 2 times, most recently from 82eabe1 to d342462 Compare July 15, 2026 14:26

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/pages/profiles/modification/profile-modification-dialog.tsx (1)

170-208: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use 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 to undefined, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 25a26f4 and d342462.

📒 Files selected for processing (3)
  • src/pages/profiles/modification/profile-modification-dialog.tsx
  • src/pages/profiles/modification/profile-modification-form.tsx
  • src/services/user-admin.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/services/user-admin.ts

Comment thread src/pages/profiles/modification/profile-modification-form.tsx
@GhilesA
GhilesA force-pushed the feat/add_quota_reset branch from d342462 to 046f3ef Compare July 17, 2026 08:54

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between d342462 and 046f3ef.

📒 Files selected for processing (3)
  • src/pages/profiles/modification/profile-modification-dialog.tsx
  • src/pages/profiles/modification/profile-modification-form.tsx
  • src/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

Comment thread src/pages/profiles/modification/profile-modification-form.tsx Outdated
@GhilesA
GhilesA force-pushed the feat/add_quota_reset branch from 046f3ef to 9a95b77 Compare July 17, 2026 09:12
@GhilesA
GhilesA force-pushed the feat/add_quota_reset branch from 386c062 to 3aced50 Compare July 21, 2026 12:26
@sonarqubecloud

Copy link
Copy Markdown

@GhilesA
GhilesA merged commit 9341178 into main Jul 21, 2026
4 of 5 checks passed
@GhilesA
GhilesA deleted the feat/add_quota_reset branch July 21, 2026 12:36
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