Skip to content

move contingencies table to a tab in sa parameters - #1243

Merged
khouadrired merged 6 commits into
mainfrom
add-contingencies-tab-in-sa-params
Jul 17, 2026
Merged

move contingencies table to a tab in sa parameters#1243
khouadrired merged 6 commits into
mainfrom
add-contingencies-tab-in-sa-params

Conversation

@khouadrired

@khouadrired khouadrired commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

new SA params :

image

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 45 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: 7ae9e48f-00dd-4f66-9f0a-85cafb819f8c

📥 Commits

Reviewing files that changed from the base of the PR and between 719bd5a and 80500ce.

📒 Files selected for processing (13)
  • src/features/parameters/common/constants.ts
  • src/features/parameters/common/limitreductions/columns-definitions.ts
  • src/features/parameters/security-analysis/columns-definitions.ts
  • src/features/parameters/security-analysis/constants.ts
  • src/features/parameters/security-analysis/index.ts
  • src/features/parameters/security-analysis/security-analysis-parameters-content.tsx
  • src/features/parameters/security-analysis/security-analysis-parameters-dialog.tsx
  • src/features/parameters/security-analysis/security-analysis-parameters-form.tsx
  • src/features/parameters/security-analysis/security-analysis-parameters-inline.tsx
  • src/features/parameters/security-analysis/security-analysis-violations-hiding.tsx
  • src/features/parameters/security-analysis/use-security-analysis-parameters-form.ts
  • src/translations/en/parameters.ts
  • src/translations/fr/parameters.ts
📝 Walkthrough

Walkthrough

Changes

The security analysis form delegates contingency-table rendering to the selector. The selector now manages the expanded tab set, tab selection behavior, contingency-table props, and panel rendering.

Security analysis tabs

Layer / File(s) Summary
Tab contract and selection behavior
src/features/parameters/common/limitreductions/columns-definitions.ts, src/features/parameters/security-analysis/security-analysis-parameters-selector.tsx, src/translations/*/parameters.ts
Tab values and labels now cover Contingencies, Aggravation, and Limit Reductions; selector initialization and fallback behavior use the updated values.
Contingency rendering and form wiring
src/features/parameters/security-analysis/security-analysis-parameters-form.tsx, src/features/parameters/security-analysis/security-analysis-parameters-selector.tsx
The form passes contingency-related props to the selector, which renders ContingencyTable for the Contingencies panel and retains Aggravation and Limit Reductions rendering conditions.

Sequence Diagram(s)

sequenceDiagram
  participant SecurityAnalysisParametersForm
  participant SecurityAnalysisParametersSelector
  participant ContingencyTable
  participant fetchContingencyCount
  SecurityAnalysisParametersForm->>SecurityAnalysisParametersSelector: pass contingency props
  SecurityAnalysisParametersSelector->>ContingencyTable: render Contingencies panel
  ContingencyTable->>fetchContingencyCount: fetch contingency count
Loading

Suggested reviewers: ayolab, flomillot, themaskedturtle, klesaulnier

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: moving the contingencies table into a dedicated Security Analysis parameters tab.
Description check ✅ Passed The description is related to the changeset and shows the new Security Analysis parameters UI.
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.

@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

Caution

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

⚠️ Outside diff range comments (1)
src/features/parameters/security-analysis/security-analysis-parameters-selector.tsx (1)

70-110: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Decouple tab values from array indices.

Relying on the array .map index for the Tab and TabPanel values is fragile. If a tab is ever filtered out of visibleTabs (e.g., via developerModeOnly), the remaining array indices will shift and immediately desync from your TabValues enum.

Additionally, evaluating the active tabValue inside the TabPanel children means every mapped panel processes the same active condition, needlessly creating React element objects for the active tab inside every panel iteration.

Use the tab's enum value directly to determine its identity, value, and rendered content.

♻️ Proposed refactor
-            <Tabs value={tabValue} onChange={handleTabChange}>
-                {visibleTabs.map(
-                    (tab, index) =>
+            <Tabs value={tabValue} onChange={handleTabChange}>
+                {visibleTabs.map((tab) => {
+                    const tabEnumValue = TabValues[tab.label as keyof typeof TabValues];
+                    return (
                         (tab.label !== TabValues[TabValues.LimitReductions] ||
                             (currentProvider === PARAM_PROVIDER_OPENLOADFLOW && params?.limitReductions)) && (
                             <Tab
                                 key={tab.label}
                                 label={<FormattedMessage id={tab.label} />}
-                                value={index}
+                                value={tabEnumValue}
                                 sx={{
                                     fontSize: 17,
                                     fontWeight: 'bold',
                                 }}
                             />
                         )
-                )}
+                    );
+                })}
             </Tabs>
 
-            {visibleTabs.map((tab, index) => (
-                <TabPanel key={tab.label} value={tabValue} index={index}>
-                    {tabValue === TabValues.Contingencies && (
+            {visibleTabs.map((tab) => {
+                const tabEnumValue = TabValues[tab.label as keyof typeof TabValues];
+                return (
+                <TabPanel key={tab.label} value={tabValue} index={tabEnumValue}>
+                    {tabEnumValue === TabValues.Contingencies && (
                         <ContingencyTable
                             name={CONTINGENCY_LISTS_INFOS}
                             showContingencyCount={showContingencyCount}
                             fetchContingencyCount={fetchContingencyCount}
                             isBuiltCurrentNode={isBuiltCurrentNode}
                             ref={contingencyTableApiRef}
                         />
                     )}
 
-                    {tabValue === TabValues.General && <ViolationsHidingParameters />}
+                    {tabEnumValue === TabValues.General && <ViolationsHidingParameters />}
 
-                    {tabValue === TabValues.LimitReductions &&
+                    {tabEnumValue === TabValues.LimitReductions &&
                         currentProvider === PARAM_PROVIDER_OPENLOADFLOW &&
                         params?.limitReductions && (
                             <Grid sx={{ width: '100%' }}>
                                 <LimitReductionsTableForm limits={params?.limitReductions ?? defaultLimitReductions} />
                             </Grid>
                         )}
                 </TabPanel>
-            ))}
+                );
+            })}
🤖 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/features/parameters/security-analysis/security-analysis-parameters-selector.tsx`
around lines 70 - 110, Update the tab rendering in the security-analysis
parameters selector to use each tab’s enum value rather than the visibleTabs map
index for Tab value, TabPanel index, and active-content selection. Render each
tab’s content based on that tab identity, preserving the existing visibility
conditions and component behavior while preventing filtered tabs from
desynchronizing the active value.
🤖 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/features/parameters/security-analysis/security-analysis-parameters-selector.tsx`:
- Line 13: Convert the UUID imports to type-only imports so the Node.js crypto
module is erased from client-side bundles: update
src/features/parameters/security-analysis/security-analysis-parameters-selector.tsx
lines 13-13 and
src/features/parameters/security-analysis/security-analysis-parameters-form.tsx
lines 9-9, preserving their type annotation usage.

---

Outside diff comments:
In
`@src/features/parameters/security-analysis/security-analysis-parameters-selector.tsx`:
- Around line 70-110: Update the tab rendering in the security-analysis
parameters selector to use each tab’s enum value rather than the visibleTabs map
index for Tab value, TabPanel index, and active-content selection. Render each
tab’s content based on that tab identity, preserving the existing visibility
conditions and component behavior while preventing filtered tabs from
desynchronizing the active value.
🪄 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: 098416aa-79c8-46c3-80ea-cda89e17478c

📥 Commits

Reviewing files that changed from the base of the PR and between 8abcd03 and ccb37fd.

📒 Files selected for processing (3)
  • src/features/parameters/common/limitreductions/columns-definitions.ts
  • src/features/parameters/security-analysis/security-analysis-parameters-form.tsx
  • src/features/parameters/security-analysis/security-analysis-parameters-selector.tsx

@khouadrired
khouadrired force-pushed the add-contingencies-tab-in-sa-params branch from ccb37fd to 1e59a65 Compare July 16, 2026 21:48
@khouadrired
khouadrired force-pushed the add-contingencies-tab-in-sa-params branch from 49f29b8 to 951229a Compare July 17, 2026 09:19

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

LGTM
would like to make it consistent with other params #1247

@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/features/parameters/common/limitreductions/columns-definitions.ts`:
- Around line 44-46: Add the missing Contingencies translation key to both the
English and French parameters translation definitions, using the existing
translation structure and appropriate localized labels. Ensure the
TabValues.Contingencies message ID resolves correctly for the TAB_INFO entry.
🪄 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: 74ebc447-6a62-4396-8b3c-b97769d95cef

📥 Commits

Reviewing files that changed from the base of the PR and between 49f29b8 and 719bd5a.

📒 Files selected for processing (5)
  • src/features/parameters/common/limitreductions/columns-definitions.ts
  • src/features/parameters/security-analysis/security-analysis-parameters-form.tsx
  • src/features/parameters/security-analysis/security-analysis-parameters-selector.tsx
  • src/translations/en/parameters.ts
  • src/translations/fr/parameters.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/features/parameters/security-analysis/security-analysis-parameters-form.tsx
  • src/features/parameters/security-analysis/security-analysis-parameters-selector.tsx

Comment on lines +44 to +46
export const TAB_INFO = [
{ label: TabValues[TabValues.General], developerModeOnly: false },
{ label: TabValues[TabValues.Contingencies], developerModeOnly: false },
{ label: TabValues[TabValues.Aggravation], developerModeOnly: false },

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Add the missing Contingencies translation key.

TabValues[TabValues.Contingencies] produces the message ID Contingencies, but neither src/translations/en/parameters.ts nor src/translations/fr/parameters.ts defines that key. The new tab will therefore render a missing-translation fallback instead of its label.

🤖 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/features/parameters/common/limitreductions/columns-definitions.ts` around
lines 44 - 46, Add the missing Contingencies translation key to both the English
and French parameters translation definitions, using the existing translation
structure and appropriate localized labels. Ensure the TabValues.Contingencies
message ID resolves correctly for the TAB_INFO entry.

@khouadrired
khouadrired force-pushed the add-contingencies-tab-in-sa-params branch from 719bd5a to 0dee063 Compare July 17, 2026 12:36
* adress reviews

* keep contingencies tab mounted to avoid fetching data on every tab selection

* Simplify AS tabs handling

* Simplify AS tabs handling

* Simplify AS tabs handling

* Simplify AS tabs handling

* Simplify AS tabs handling

* Remove unnecessary Grid

* Lint

---------

Co-authored-by: Radouane Khouadri <redouane.khouadri_externe@rte-france.com>
@sonarqubecloud

Copy link
Copy Markdown

@khouadrired
khouadrired merged commit 432c7b6 into main Jul 17, 2026
6 checks passed
@khouadrired
khouadrired deleted the add-contingencies-tab-in-sa-params branch July 17, 2026 12:47
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