add cut off power tab#3906
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
✅ Files skipped from review due to trivial changes (2)
📝 WalkthroughWalkthroughIntroduce NMK_TYPE with three variants and wire a new "cut-off power from constraints" result path through types, mapper and column defs, mapping, columns hook, tab UI to select nmkType, and result component switching to the new rows/style logic. ChangesNMK power-cut-off + nmkType migration
Sequence DiagramsequenceDiagram
actor User
participant Tab as SecurityAnalysisResultTab
participant NmkResult as SecurityAnalysisResultNmk
participant Utils as ResultUtils
participant ColDefs as ColumnDefinitions
User->>Tab: Select nmkType from dropdown
Tab->>Tab: Set nmkType (constraints-from-contingencies,\ncontingencies-from-constraints, or\ncut-off-power-from-constraints)
Tab->>NmkResult: Pass nmkType prop
alt nmkType = constraints-from-contingencies
NmkResult->>Utils: flattenNmKResultsConstraints()
Utils-->>NmkResult: SecurityAnalysisNmkTableRow[]
else nmkType = contingencies-from-constraints
NmkResult->>Utils: flattenNmKResultsContingencies()
Utils-->>NmkResult: SecurityAnalysisNmkTableRow[]
else nmkType = cut-off-power-from-constraints
NmkResult->>Utils: mapNmKResultsCutOffPower()
Utils-->>NmkResult: SecurityAnalysisNmkTableRow[]
end
NmkResult->>ColDefs: Request column definitions for result type
ColDefs->>Utils: Get field-to-column mapping (mappingColumnToField)
Utils-->>ColDefs: Mapping specific to RESULT_TYPE
ColDefs-->>NmkResult: ColDef[]
NmkResult->>NmkResult: Render table with mapped rows and columns
NmkResult-->>User: Display results
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/components/results/securityanalysis/security-analysis-result-tab.tsx (1)
91-96:⚠️ Potential issue | 🟠 MajorReset the developer-only NMK type when developer mode is disabled.
If a user selects
POWER_CUT_OFF_FROM_CONTINGENCIESand then disables developer mode, the option disappears butnmkTypestill drivesRESULT_TYPE.NMK_POWER_CUT_OFF, so the hidden result remains fetchable/exportable.🛡️ Proposed fix
useEffect(() => { if (!isDeveloperMode && tabIndexRef.current === N_RESULTS_TAB_INDEX) { // handle tabIndex when dev mode is disabled setTabIndex(NMK_RESULTS_TAB_INDEX); } + if (!isDeveloperMode && nmkType === NMK_TYPE.POWER_CUT_OFF_FROM_CONTINGENCIES) { + setNmkType(NMK_TYPE.CONSTRAINTS_FROM_CONTINGENCIES); + resetResultStates(); + dispatchPagination({ page: 0, rowsPerPage }); + } -}, [isDeveloperMode]); +}, [dispatchPagination, isDeveloperMode, nmkType, resetResultStates, rowsPerPage]);Also applies to: 322-326
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/results/securityanalysis/security-analysis-result-tab.tsx` around lines 91 - 96, When developer mode is disabled (the useEffect that checks !isDeveloperMode && tabIndexRef.current === N_RESULTS_TAB_INDEX), also reset the developer-only NMK selection so it cannot drive RESULT_TYPE.NMK_POWER_CUT_OFF; call the setter that controls the nmkType (e.g., setNmkType(...)) to a safe default/none value so the NMK-specific result type is cleared, and apply the same reset in the other analogous block (around the other useEffect at lines 322-326).
🧹 Nitpick comments (1)
src/components/results/securityanalysis/security-analysis-result-utils.ts (1)
599-625: Wire sort params for sortable power cut-off columns.
FROM_COLUMN_TO_FIELD_NMK_POWER_CUT_OFFdefines backend fields forstatusand both power columns, but the column definitions passundefinedsort params, so these columns won’t participate in the persisted/server-side sort flow.♻️ Proposed fix
createEnumColumn( 'status', 'ComputationStatus', filterEnums['status'] ?? [], getEnumLabel, intl, - undefined, + sortParams, filterParams )makeAgGridFloatColumn( 'disconnectedLoadActivePower', 'disconnectedLoadActivePower', intl, filterParams, - undefined + sortParams )makeAgGridFloatColumn( 'disconnectedGenerationActivePower', 'disconnectedGenerationActivePower', intl, filterParams, - undefined + sortParams )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/components/results/securityanalysis/security-analysis-result-utils.ts` around lines 599 - 625, The three column defs (createEnumColumn('status', ...), and the two makeAgGridFloatColumn calls wrapped by makeAgGridCustomHeaderColumn) pass undefined for their sort params so they won't hook into the persisted/server-side sort flow; replace those undefined sort param arguments with the appropriate entries from FROM_COLUMN_TO_FIELD_NMK_POWER_CUT_OFF (e.g., the mapping value for 'status', 'disconnectedLoadActivePower' and 'disconnectedGenerationActivePower') so the columns use the backend field mapping when building sort/filter via filterParams.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/components/results/securityanalysis/security-analysis-result-tab.tsx`:
- Around line 191-195: When switching NMK subtype in handleChangeNmkType, clear
the Redux column filter and sort state before calling setNmkType to avoid stale
filters for the new field mapping; update the handler (alongside
dispatchPagination and resetResultStates) to dispatch the existing actions that
clear column filters and clear sort/order (or add and call new actions like
clearColumnFilters and clearSortState) so columnFilters and sort state are reset
prior to setNmkType.
In `@src/translations/en.json`:
- Line 399: Replace the awkward label value for the translation key
"PowerCutOffFromContingencies" in src/translations/en.json with a clearer
phrase; change the string "Cut-off powers" to a singular, clearer label such as
"Cut-off power" (or "Disconnected power" if that better matches nearby column
wording) so the tab label reads naturally and aligns with existing column text.
---
Outside diff comments:
In `@src/components/results/securityanalysis/security-analysis-result-tab.tsx`:
- Around line 91-96: When developer mode is disabled (the useEffect that checks
!isDeveloperMode && tabIndexRef.current === N_RESULTS_TAB_INDEX), also reset the
developer-only NMK selection so it cannot drive RESULT_TYPE.NMK_POWER_CUT_OFF;
call the setter that controls the nmkType (e.g., setNmkType(...)) to a safe
default/none value so the NMK-specific result type is cleared, and apply the
same reset in the other analogous block (around the other useEffect at lines
322-326).
---
Nitpick comments:
In `@src/components/results/securityanalysis/security-analysis-result-utils.ts`:
- Around line 599-625: The three column defs (createEnumColumn('status', ...),
and the two makeAgGridFloatColumn calls wrapped by makeAgGridCustomHeaderColumn)
pass undefined for their sort params so they won't hook into the
persisted/server-side sort flow; replace those undefined sort param arguments
with the appropriate entries from FROM_COLUMN_TO_FIELD_NMK_POWER_CUT_OFF (e.g.,
the mapping value for 'status', 'disconnectedLoadActivePower' and
'disconnectedGenerationActivePower') so the columns use the backend field
mapping when building sort/filter via filterParams.
🪄 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: 6f3085cf-d28e-4b87-a4e5-b7f82b4ac47d
📒 Files selected for processing (7)
src/components/results/securityanalysis/security-analysis-result-nmk.tsxsrc/components/results/securityanalysis/security-analysis-result-tab.tsxsrc/components/results/securityanalysis/security-analysis-result-utils.tssrc/components/results/securityanalysis/security-analysis.type.tssrc/components/results/securityanalysis/use-security-analysis-column-defs.tsxsrc/translations/en.jsonsrc/translations/fr.json
| const handleChangeNmkType = (event: SelectChangeEvent<NMK_TYPE>) => { | ||
| dispatchPagination({ page: 0, rowsPerPage }); | ||
| resetResultStates(); | ||
| setNmkType( | ||
| nmkType === NMK_TYPE.CONSTRAINTS_FROM_CONTINGENCIES | ||
| ? NMK_TYPE.CONTINGENCIES_FROM_CONSTRAINTS | ||
| : NMK_TYPE.CONSTRAINTS_FROM_CONTINGENCIES | ||
| ); | ||
| setNmkType(event.target.value as NMK_TYPE); | ||
| }; |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Inspect SecurityAnalysis table filter/sort state keys and available reset actions.
rg -n -C3 'useComputationColumnFilters|tableSort|SECURITY_ANALYSIS_RESULT_N_K|getStoreFields|mapFieldsToColumnsFilter|clear.*Filter|reset.*Filter|clear.*Sort|reset.*Sort'Repository: gridsuite/gridstudy-app
Length of output: 50379
🏁 Script executed:
#!/bin/bash
# Find NMK_TYPE definition and its values
rg -n "enum.*NMK_TYPE|type.*NMK_TYPE|NMK_TYPE.*=" -A 5Repository: gridsuite/gridstudy-app
Length of output: 1438
🏁 Script executed:
#!/bin/bash
# Check how mappingColumnToField uses NMK type and what fields it maps
rg -n "mappingColumnToField|NMK_POWER_CUT_OFF" -B 2 -A 8 | head -100Repository: gridsuite/gridstudy-app
Length of output: 10993
🏁 Script executed:
#!/bin/bash
# Search for column filter clearing or reset actions in security analysis context
rg -n "clearColumnFilters|resetColumnFilters|clearFilters|CLEAR.*FILTER" src/components/results/securityanalysis/ -A 3Repository: gridsuite/gridstudy-app
Length of output: 49
🏁 Script executed:
#!/bin/bash
# Check the useComputationColumnFilters hook for any clear/reset capabilities
cat src/components/results/common/column-filter/use-computation-column-filters.tsRepository: gridsuite/gridstudy-app
Length of output: 1563
🏁 Script executed:
#!/bin/bash
# Find resetResultStates implementation
rg -n "resetResultStates|const resetResultStates" src/components/results/securityanalysis/ -B 2 -A 15Repository: gridsuite/gridstudy-app
Length of output: 3411
🏁 Script executed:
#!/bin/bash
# Check the security-analysis-result-tab.tsx file around handleChangeNmkType to see the full context
sed -n '185,210p' src/components/results/securityanalysis/security-analysis-result-tab.tsxRepository: gridsuite/gridstudy-app
Length of output: 891
🏁 Script executed:
#!/bin/bash
# Look for column filter clearing or resetting actions in Redux
rg -n "CLEAR.*COLUMN|RESET.*COLUMN|clearColumnFilters|resetColumnFilters|UPDATE_COMPUTATION_COLUMN_FILTERS" src/redux/ -B 2 -A 5Repository: gridsuite/gridstudy-app
Length of output: 49
🏁 Script executed:
#!/bin/bash
# Check what actions/dispatches are available related to table filters and sorts
rg -n "export const.*[Ff]ilter|export const.*[Ss]ort" src/redux/actions.ts | grep -i "column\|clear\|reset" -iRepository: gridsuite/gridstudy-app
Length of output: 233
🏁 Script executed:
#!/bin/bash
# Check the tableFilters redux structure
rg -n "tableFilters|columnsFilters" src/redux/reducer.ts -B 2 -A 5 | head -80Repository: gridsuite/gridstudy-app
Length of output: 4065
🏁 Script executed:
#!/bin/bash
# Look for how column filters are updated for computation results
rg -n "updateComputationColumnFilters|UPDATE_COMPUTATION_COLUMN_FILTERS" src/ -B 2 -A 10 | head -100Repository: gridsuite/gridstudy-app
Length of output: 6071
🏁 Script executed:
#!/bin/bash
# Check what updateColumnFiltersAction does
sed -n '1133,1155p' src/redux/actions.tsRepository: gridsuite/gridstudy-app
Length of output: 597
Clear column filters and sort when switching NMK subtype.
Within the N-K tab, different NMK subtypes use different field mappings: NMK_POWER_CUT_OFF only maps contingencyId, status, and two disconnected power fields, while CONSTRAINTS_FROM_CONTINGENCIES and CONTINGENCIES_FROM_CONSTRAINTS include fields like limitType and side. Since filter/sort state is keyed by tab index only (not NMK subtype), switching between subtypes leaves stale filters in Redux that don't exist in the new field mapping, causing undefined field references in queryParams.
Add clearing of both column filters and sort state in handleChangeNmkType before setNmkType() is called.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/components/results/securityanalysis/security-analysis-result-tab.tsx`
around lines 191 - 195, When switching NMK subtype in handleChangeNmkType, clear
the Redux column filter and sort state before calling setNmkType to avoid stale
filters for the new field mapping; update the handler (alongside
dispatchPagination and resetResultStates) to dispatch the existing actions that
clear column filters and clear sort/order (or add and call new actions like
clearColumnFilters and clearSortState) so columnFilters and sort state are reset
prior to setNmkType.
There was a problem hiding this comment.
Actionable comments posted: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/components/results/securityanalysis/security-analysis-result-utils.ts (1)
169-184:⚠️ Potential issue | 🟠 Major | ⚡ Quick win
mapNmKResultsCutOffPowerrows are missingelementId, which breakshandlePostSortRowsgrouping.
handlePostSortRowsindexes parent rows byrow.data.elementId(line 649) and, for the cut-off case, will be invoked withisFromContingency = false(sincenmkType !== CONSTRAINTS_FROM_CONTINGENCIESinsecurity-analysis-result-nmk.tsxline 80). That setsisContingency = trueandidField = 'subjectId'. Cut-off rows havecontingencyIdbut nosubjectId, so:
- The first loop's
row.data[idField] != nullcheck is false → no parents are registered.- The second loop treats every row as a child and falls into the orphan branch
mappedRows.get('contingencies').push(row).The net result is that all rows are grouped under the
'contingencies'orphan bucket, which is not the intended behavior for a flat cut-off table. Either setelementIdper row and callhandlePostSortRowswith a mode that treats cut-off as flat (no parent/child), or skippostSortRowsentirely forCUT_OFF_POWER_FROM_CONSTRAINTS.🛠️ Suggested direction
In
security-analysis-result-nmk.tsx, only attachpostSortRowsfor the two grouped NMK types:- postSortRows: handlePostSortRows(nmkType === NMK_TYPE.CONSTRAINTS_FROM_CONTINGENCIES), + postSortRows: + nmkType === NMK_TYPE.CUT_OFF_POWER_FROM_CONSTRAINTS + ? undefined + : handlePostSortRows(nmkType === NMK_TYPE.CONSTRAINTS_FROM_CONTINGENCIES),🤖 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/components/results/securityanalysis/security-analysis-result-utils.ts` around lines 169 - 184, mapNmKResultsCutOffPower builds rows for the cut-off table but omits elementId/subjectId, so handlePostSortRows treats every row as a child and dumps them into the 'contingencies' orphan bucket; fix by populating the appropriate id field on each row (set elementId or subjectId to the cut-off row's unique id, e.g., contingencyId or subject identifier used by handlePostSortRows) or avoid attaching postSortRows for CUT_OFF_POWER_FROM_CONSTRAINTS in security-analysis-result-nmk.tsx so cut-off remains a flat table; reference mapNmKResultsCutOffPower and handlePostSortRows / the idField ('subjectId') when making the change.
♻️ Duplicate comments (2)
src/components/results/securityanalysis/security-analysis-result-nmk.tsx (1)
78-85:⚠️ Potential issue | 🟠 Major | ⚡ Quick win
postSortRowsis broken forCUT_OFF_POWER_FROM_CONSTRAINTS.See the root-cause comment in
security-analysis-result-utils.tsonmapNmKResultsCutOffPower/handlePostSortRows. WithnmkType === CUT_OFF_POWER_FROM_CONSTRAINTS, the call here passesfalse, which triggers the “contingencies-from-constraints” grouping path on rows that have neithersubjectIdnorlinkedElementId, dumping every row into the orphan bucket. Either skippostSortRowsfor the cut-off case or extendhandlePostSortRowsto handle a flat mode.🤖 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/components/results/securityanalysis/security-analysis-result-nmk.tsx` around lines 78 - 85, The current useMemo for agGridProps passes postSortRows: handlePostSortRows(nmkType === NMK_TYPE.CONSTRAINTS_FROM_CONTINGENCIES), which sends false for NMK_TYPE.CUT_OFF_POWER_FROM_CONSTRAINTS and causes handlePostSortRows to run the contingencies-from-constraints grouping (orphan bucket) for rows without subjectId/linkedElementId; to fix, change agGridProps so it does not set postSortRows when nmkType === NMK_TYPE.CUT_OFF_POWER_FROM_CONSTRAINTS (i.e., omit or null-out postSortRows in useMemo), or alternatively update handlePostSortRows and mapNmKResultsCutOffPower to add a flat-mode branch that correctly handles cut-off rows — target the useMemo/ agGridProps block and the functions handlePostSortRows and mapNmKResultsCutOffPower when making the change.src/components/results/securityanalysis/security-analysis-result-tab.tsx (1)
191-195:⚠️ Potential issue | 🟠 Major | ⚡ Quick winStale column filters/sort when switching NMK subtype.
Filter/sort state in Redux is keyed by tab index only, not by
nmkType. Switching fromCONSTRAINTS_FROM_CONTINGENCIES/CONTINGENCIES_FROM_CONSTRAINTS(which exposelimitType,side, etc.) toCUT_OFF_POWER_FROM_CONSTRAINTS(which only mapscontingencyId,status,disconnectedLoadActivePower,disconnectedGenerationActivePower) leaves previously-set filters/sort entries that reference fields absent fromFROM_COLUMN_TO_FIELD_NMK_POWER_CUT_OFF. Those will be looked up viamappingColumnToField(resultType)[sort.colId]and produceundefinedcolIds inqueryParams. Clear column filters and sort state inhandleChangeNmkTypebeforesetNmkType.🤖 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/components/results/securityanalysis/security-analysis-result-tab.tsx` around lines 191 - 195, handleChangeNmkType must clear column-filter and sort state tied to the previous NMK subtype before calling setNmkType to avoid stale filters mapping to missing fields (see mappingColumnToField and FROM_COLUMN_TO_FIELD_NMK_POWER_CUT_OFF). Update handleChangeNmkType to dispatch actions that remove/clear column filters and sort state for the current tab (and any nmkType-keyed entries) — e.g., clear columnFilters and sort entries in Redux so mappingColumnToField(resultType)[sort.colId] cannot return undefined — and do these clears before calling setNmkType; keep the existing calls to dispatchPagination and resetResultStates intact. Ensure the clears target the same keys the UI uses (tab index and nmkType) so queryParams no longer include undefined colIds after switching NMK subtype.
🧹 Nitpick comments (2)
src/components/results/securityanalysis/security-analysis-result-nmk.tsx (1)
51-60: 💤 Low value
rowsswitch has no default — TS will returnundefinedif a newNMK_TYPEis added.The
switchcovers all three current variants but lacks adefault. If a newNMK_TYPEmember is introduced without updating this site,rowswill silently becomeundefinedat runtime. Consider an exhaustiveness guard (e.g., assign to anever-typed variable indefault) to surface this at compile time.🤖 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/components/results/securityanalysis/security-analysis-result-nmk.tsx` around lines 51 - 60, The switch inside useMemo that computes rows (using nmkType and NMK_TYPE) is missing a default/exhaustiveness guard so adding a new NMK_TYPE can make rows undefined; update the switch to include a default branch that performs an exhaustive type check (e.g., assign nmkType to a never-typed variable and throw an error) so TypeScript will force handling new NMK_TYPE values — locate the rows useMemo and the cases calling flattenNmKResultsContingencies, flattenNmKResultsConstraints, and mapNmKResultsCutOffPower and add the default/exhaustive branch there.src/components/results/securityanalysis/security-analysis-result-utils.ts (1)
582-632: 💤 Low valueUnused
filterEnumsparameter and pointlesslinkedElementIdcolumn.
filterEnumsis only consumed by thestatusenum column viafilterEnums['status'] ?? [], but the function signature exposes the wholeFilterEnumsType. That's fine, but note: cut-off rows produced bymapNmKResultsCutOffPowernever populatelinkedElementId, so the hiddenlinkedElementIdcolumn (lines 626–630) serves no parent/child grouping purpose here and is just copied from the other definitions. Consider dropping it to avoid suggesting a grouping semantic that doesn't exist for this table.- Also, in the first column (lines 591–596),
isChildren: falseis the implicit default — passing it explicitly is unnecessary noise.🤖 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/components/results/securityanalysis/security-analysis-result-utils.ts` around lines 582 - 632, In securityAnalysisTableNmKCutOffPowerColumnsDefinition, remove the hidden linkedElementId column block (the makeAgGridCustomHeaderColumn with colId/field 'linkedElementId') because mapNmKResultsCutOffPower never sets linkedElementId and that column falsely implies parent/child grouping; also simplify the first column by deleting the explicit isChildren: false passed into makeAgGridStringColumn (it’s the default) so the call to makeAgGridStringColumn('Contingency', 'contingencyId', ...) is cleaner; keep filterEnums usage for the 'status' column as-is.
🤖 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/components/results/securityanalysis/security-analysis-result-tab.tsx`:
- Around line 322-326: When isDeveloperMode is turned off the component can
retain nmkType = NMK_TYPE.CUT_OFF_Power_FROM_CONSTRAINTS (a developer-only
option) which causes the MUI Select "out-of-range value" warning and leaves
resultType resolving to NMK_POWER_CUT_OFF with no visible option; inside the
existing isDeveloperMode effect (the effect that watches isDeveloperMode around
lines 91-96) add logic to detect when isDeveloperMode becomes false and reset
nmkType to a non-developer default (for example the app’s regular default
NMK_TYPE used elsewhere, e.g., NMK_TYPE.NMK_POWER or whatever default constant
is used in this component) so the Select always has a rendered option and
resultType remains reachable from the UI.
In `@src/components/results/securityanalysis/security-analysis.type.ts`:
- Line 26: Rename the enum member CUT_OFF_Power_FROM_CONSTRAINTS to use
consistent SCREAMING_SNAKE_CASE (CUT_OFF_POWER_FROM_CONSTRAINTS) in
security-analysis.type (the enum declaration) and update every reference to that
enum member throughout the codebase (e.g., the usages currently referencing
CUT_OFF_Power_FROM_CONSTRAINTS in security-analysis-result-nmk and
security-analysis-result-tab) to the new name so all call sites compile and
remain consistent.
In `@src/translations/fr.json`:
- Line 399: The translation value for the key "CutOffPowerFromConstraints" is
plural in French ("Puissances coupées") but the English source uses singular
("Cut-off power"); update the French value to the singular form "Puissance
coupée" to match the English string (or, if the feature actually represents
multiple powers, update the English counterpart to a plural form instead) and
ensure the change is applied where "CutOffPowerFromConstraints" is defined.
---
Outside diff comments:
In `@src/components/results/securityanalysis/security-analysis-result-utils.ts`:
- Around line 169-184: mapNmKResultsCutOffPower builds rows for the cut-off
table but omits elementId/subjectId, so handlePostSortRows treats every row as a
child and dumps them into the 'contingencies' orphan bucket; fix by populating
the appropriate id field on each row (set elementId or subjectId to the cut-off
row's unique id, e.g., contingencyId or subject identifier used by
handlePostSortRows) or avoid attaching postSortRows for
CUT_OFF_POWER_FROM_CONSTRAINTS in security-analysis-result-nmk.tsx so cut-off
remains a flat table; reference mapNmKResultsCutOffPower and handlePostSortRows
/ the idField ('subjectId') when making the change.
---
Duplicate comments:
In `@src/components/results/securityanalysis/security-analysis-result-nmk.tsx`:
- Around line 78-85: The current useMemo for agGridProps passes postSortRows:
handlePostSortRows(nmkType === NMK_TYPE.CONSTRAINTS_FROM_CONTINGENCIES), which
sends false for NMK_TYPE.CUT_OFF_POWER_FROM_CONSTRAINTS and causes
handlePostSortRows to run the contingencies-from-constraints grouping (orphan
bucket) for rows without subjectId/linkedElementId; to fix, change agGridProps
so it does not set postSortRows when nmkType ===
NMK_TYPE.CUT_OFF_POWER_FROM_CONSTRAINTS (i.e., omit or null-out postSortRows in
useMemo), or alternatively update handlePostSortRows and
mapNmKResultsCutOffPower to add a flat-mode branch that correctly handles
cut-off rows — target the useMemo/ agGridProps block and the functions
handlePostSortRows and mapNmKResultsCutOffPower when making the change.
In `@src/components/results/securityanalysis/security-analysis-result-tab.tsx`:
- Around line 191-195: handleChangeNmkType must clear column-filter and sort
state tied to the previous NMK subtype before calling setNmkType to avoid stale
filters mapping to missing fields (see mappingColumnToField and
FROM_COLUMN_TO_FIELD_NMK_POWER_CUT_OFF). Update handleChangeNmkType to dispatch
actions that remove/clear column filters and sort state for the current tab (and
any nmkType-keyed entries) — e.g., clear columnFilters and sort entries in Redux
so mappingColumnToField(resultType)[sort.colId] cannot return undefined — and do
these clears before calling setNmkType; keep the existing calls to
dispatchPagination and resetResultStates intact. Ensure the clears target the
same keys the UI uses (tab index and nmkType) so queryParams no longer include
undefined colIds after switching NMK subtype.
---
Nitpick comments:
In `@src/components/results/securityanalysis/security-analysis-result-nmk.tsx`:
- Around line 51-60: The switch inside useMemo that computes rows (using nmkType
and NMK_TYPE) is missing a default/exhaustiveness guard so adding a new NMK_TYPE
can make rows undefined; update the switch to include a default branch that
performs an exhaustive type check (e.g., assign nmkType to a never-typed
variable and throw an error) so TypeScript will force handling new NMK_TYPE
values — locate the rows useMemo and the cases calling
flattenNmKResultsContingencies, flattenNmKResultsConstraints, and
mapNmKResultsCutOffPower and add the default/exhaustive branch there.
In `@src/components/results/securityanalysis/security-analysis-result-utils.ts`:
- Around line 582-632: In securityAnalysisTableNmKCutOffPowerColumnsDefinition,
remove the hidden linkedElementId column block (the makeAgGridCustomHeaderColumn
with colId/field 'linkedElementId') because mapNmKResultsCutOffPower never sets
linkedElementId and that column falsely implies parent/child grouping; also
simplify the first column by deleting the explicit isChildren: false passed into
makeAgGridStringColumn (it’s the default) so the call to
makeAgGridStringColumn('Contingency', 'contingencyId', ...) is cleaner; keep
filterEnums usage for the 'status' column as-is.
🪄 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: fa68400c-43d4-4c88-a19e-323cef7ada0d
📒 Files selected for processing (7)
src/components/results/securityanalysis/security-analysis-result-nmk.tsxsrc/components/results/securityanalysis/security-analysis-result-tab.tsxsrc/components/results/securityanalysis/security-analysis-result-utils.tssrc/components/results/securityanalysis/security-analysis.type.tssrc/components/results/securityanalysis/use-security-analysis-column-defs.tsxsrc/translations/en.jsonsrc/translations/fr.json
| {isDeveloperMode && ( | ||
| <MenuItem value={NMK_TYPE.CUT_OFF_Power_FROM_CONSTRAINTS}> | ||
| <FormattedMessage id="CutOffPowerFromConstraints" /> | ||
| </MenuItem> | ||
| )} |
There was a problem hiding this comment.
Developer-only MenuItem can leave nmkType in an invalid state when dev mode is toggled off.
If a user selects CUT_OFF_POWER_FROM_CONSTRAINTS while isDeveloperMode is true and dev mode is later disabled, nmkType remains set to a value whose corresponding MenuItem is no longer rendered. MUI Select will warn ("out-of-range value") and resultType will still resolve to NMK_POWER_CUT_OFF, but the option is no longer reachable from the UI. Consider resetting nmkType back to a non-developer default in the existing isDeveloperMode effect (line 91-96).
♻️ Suggested fix
useEffect(() => {
if (!isDeveloperMode && tabIndexRef.current === N_RESULTS_TAB_INDEX) {
// handle tabIndex when dev mode is disabled
setTabIndex(NMK_RESULTS_TAB_INDEX);
}
+ if (!isDeveloperMode && nmkType === NMK_TYPE.CUT_OFF_POWER_FROM_CONSTRAINTS) {
+ setNmkType(NMK_TYPE.CONSTRAINTS_FROM_CONTINGENCIES);
+ }
}, [isDeveloperMode]);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| {isDeveloperMode && ( | |
| <MenuItem value={NMK_TYPE.CUT_OFF_Power_FROM_CONSTRAINTS}> | |
| <FormattedMessage id="CutOffPowerFromConstraints" /> | |
| </MenuItem> | |
| )} | |
| useEffect(() => { | |
| if (!isDeveloperMode && tabIndexRef.current === N_RESULTS_TAB_INDEX) { | |
| // handle tabIndex when dev mode is disabled | |
| setTabIndex(NMK_RESULTS_TAB_INDEX); | |
| } | |
| if (!isDeveloperMode && nmkType === NMK_TYPE.CUT_OFF_POWER_FROM_CONSTRAINTS) { | |
| setNmkType(NMK_TYPE.CONSTRAINTS_FROM_CONTINGENCIES); | |
| } | |
| }, [isDeveloperMode]); |
🤖 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/components/results/securityanalysis/security-analysis-result-tab.tsx`
around lines 322 - 326, When isDeveloperMode is turned off the component can
retain nmkType = NMK_TYPE.CUT_OFF_Power_FROM_CONSTRAINTS (a developer-only
option) which causes the MUI Select "out-of-range value" warning and leaves
resultType resolving to NMK_POWER_CUT_OFF with no visible option; inside the
existing isDeveloperMode effect (the effect that watches isDeveloperMode around
lines 91-96) add logic to detect when isDeveloperMode becomes false and reset
nmkType to a non-developer default (for example the app’s regular default
NMK_TYPE used elsewhere, e.g., NMK_TYPE.NMK_POWER or whatever default constant
is used in this component) so the Select always has a rendered option and
resultType remains reachable from the UI.
|
|
||
| "ConstraintsFromContingencies": "Aléas -> contraintes", | ||
| "ContingenciesFromConstraints": "Contraintes -> aléas", | ||
| "CutOffPowerFromConstraints": "Puissances coupées", |
There was a problem hiding this comment.
Verify singular/plural consistency with English translation.
The French translation uses plural form "Puissances coupées" while the English translation at the same key uses singular "Cut-off power". This inconsistency should be verified:
- If the feature refers to a single concept, both should use singular form: "Puissance coupée"
- If multiple powers are meant, English should also be plural
Please confirm whether the French translation should match the English singular form.
🤖 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/translations/fr.json` at line 399, The translation value for the key
"CutOffPowerFromConstraints" is plural in French ("Puissances coupées") but the
English source uses singular ("Cut-off power"); update the French value to the
singular form "Puissance coupée" to match the English string (or, if the feature
actually represents multiple powers, update the English counterpart to a plural
form instead) and ensure the change is applied where
"CutOffPowerFromConstraints" is defined.
|
|



PR Summary
add cut off power tab