Manage DS mapping by directory - #1183
Conversation
Signed-off-by: Thang PHAM <phamthang37@gmail.com>
|
Warning Review limit reached
More reviews will be available in 58 minutes and 21 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?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 credits. 🚦 How do rate 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 see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR refactors dynamic simulation mapping from a plain string field to a structured ChangesDynamic simulation mapping enriched type refactor
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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: 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/features/parameters/dynamic-simulation/mapping/mapping-parameters-utils.ts`:
- Around line 12-18: The MAPPING schema validation in the
mapping-parameters-utils.ts file requires the NAME field, but the IdName
interface contract defines the name property as optional. Update the schema
definition for the MAPPING object to make the NAME field optional instead of
required. Remove the .required() call from the NAME validation chain (the one
that validates yup.string().required() for the NAME key) so that the schema
allows undefined or missing name values, while keeping the ID field required as
it is mandatory in the IdName type.
In `@src/features/parameters/dynamic-simulation/mapping/mapping-parameters.tsx`:
- Around line 19-24: The ParameterLineDirectoryItemsInput component in the
mapping-parameters.tsx file is missing an explicit allowMultiSelect={false}
prop. This component defaults to allowMultiSelect={true}, which causes users to
be able to select multiple mappings, but the form schema expects MAPPING to be a
single IdName object rather than an array. Add allowMultiSelect={false} to the
ParameterLineDirectoryItemsInput component props to enforce single-select
behavior and align with the schema contract.
In `@src/utils/types/dynamic-simulation.type.ts`:
- Around line 103-112: The mapDynamicSimulationParameters function uses delete
to remove the mapping property, which creates a type safety gap since TypeScript
doesn't track the delete operation for type inference. Instead of spreading all
parameters and then deleting mapping, use destructuring to directly extract the
properties you want by omitting mapping in the destructuring pattern (using rest
syntax to capture all properties except mapping), then add the mappingId
property. This ensures the return type is correct without relying on TypeScript
to infer types after a delete operation.
🪄 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: d9924d59-1783-403b-8325-8ddf0284753f
📒 Files selected for processing (10)
src/features/parameters/dynamic-simulation/dynamic-simulation-inline.tsxsrc/features/parameters/dynamic-simulation/mapping/mapping-parameters-utils.tssrc/features/parameters/dynamic-simulation/mapping/mapping-parameters.tsxsrc/features/parameters/dynamic-simulation/use-dynamic-simulation-parameters-form.tssrc/services/dynamic-mapping.tssrc/translations/en/businessErrorsEn.tssrc/translations/fr/businessErrorsFr.tssrc/utils/types/dynamic-margin-calculation.type.tssrc/utils/types/dynamic-simulation.type.tssrc/utils/types/parameters.type.ts
Signed-off-by: Thang PHAM <phamthang37@gmail.com>
Signed-off-by: Thang PHAM <phamthang37@gmail.com>
… into manage_ds_mapping_via_directory
There was a problem hiding this comment.
Actionable comments posted: 2
♻️ Duplicate comments (1)
src/components/ui/reactHookForm/directory-item-input/directory-item-input.tsx (1)
11-11:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winBuild failure: '
@gridsuite/commons-ui' module not found.The import of
@gridsuite/commons-uiis causing TypeScript compilation to fail. This is the same dependency issue affectingdirectory-item-utils.ts. Ensure the package is installed and properly configured.🤖 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/ui/reactHookForm/directory-item-input/directory-item-input.tsx` at line 11, The import statement in directory-item-input.tsx is referencing the `@gridsuite/commons-ui` module which is not found, causing build failure. Verify that the `@gridsuite/commons-ui` package is properly installed in your project dependencies by checking the package.json file, ensuring the correct package name and version are specified, and then run your package manager's install command to resolve all dependencies. If the issue persists, try clearing your node_modules directory and reinstalling all packages to ensure a clean state.Source: Linters/SAST tools
🤖 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/ui/reactHookForm/directory-item-input/directory-item-input.tsx`:
- Around line 37-53: In the onNodeChanged callback function, the assignment of
fullPath using nodes[0]?.name is incorrect because name only contains the short
element name rather than the complete directory path. Replace the logic that
assigns nodes[0]?.name to fullPath with code that constructs or retrieves the
actual full directory path, either by building it from the node hierarchy using
available parent information in the TreeViewFinderNodeProps or by passing the
full path explicitly through the callback mechanism. Ensure that
DIRECTORY_ITEM_FULL_PATH receives the complete directory path, not just the
element name.
In
`@src/components/ui/reactHookForm/directory-item-input/directory-item-utils.ts`:
- Line 8: Replace the package name import of ElementType in the import statement
with a relative path. Change from importing ElementType using the
`@gridsuite/commons-ui` package name to using a relative path that points to the
utils directory where ElementType is defined (e.g., '../../../utils'). Apply
this same fix to both the directory-item-utils.ts file and the
directory-item-input.tsx file in the same directory to resolve the circular
self-import issue that occurs during development.
---
Duplicate comments:
In
`@src/components/ui/reactHookForm/directory-item-input/directory-item-input.tsx`:
- Line 11: The import statement in directory-item-input.tsx is referencing the
`@gridsuite/commons-ui` module which is not found, causing build failure. Verify
that the `@gridsuite/commons-ui` package is properly installed in your project
dependencies by checking the package.json file, ensuring the correct package
name and version are specified, and then run your package manager's install
command to resolve all dependencies. If the issue persists, try clearing your
node_modules directory and reinstalling all packages to ensure a clean state.
🪄 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: f575b69e-7add-4f2b-84c6-483c83a6af50
📒 Files selected for processing (10)
src/components/ui/reactHookForm/constants.tssrc/components/ui/reactHookForm/directory-item-input/directory-item-input.tsxsrc/components/ui/reactHookForm/directory-item-input/directory-item-utils.tssrc/components/ui/reactHookForm/directory-item-input/index.tssrc/components/ui/reactHookForm/index.tssrc/features/parameters/dynamic-simulation/dynamic-simulation-inline.tsxsrc/features/parameters/dynamic-simulation/mapping/mapping-parameters.tsxsrc/services/dynamic-mapping.tssrc/utils/mapper/getFileIcon.tsxsrc/utils/types/elementType.ts
✅ Files skipped from review due to trivial changes (2)
- src/components/ui/reactHookForm/constants.ts
- src/components/ui/reactHookForm/directory-item-input/index.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/features/parameters/dynamic-simulation/mapping/mapping-parameters.tsx
- src/services/dynamic-mapping.ts
Signed-off-by: Thang PHAM <phamthang37@gmail.com>
… into manage_ds_mapping_via_directory
Signed-off-by: Thang PHAM <phamthang37@gmail.com>
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/features/parameters/dynamic-simulation/curve/common/checkbox-treeview.tsx`:
- Around line 12-13: The BorderedTreeItem styled component has a type signature
marking theme as optional (theme?: Theme) but then uses unsafe null-safety
operators (optional chaining ?. and non-null assertion !) when accessing
theme.palette.text.primary. Since Material-UI's styled() function always
provides a theme, update the type signature for BorderedTreeItem to require
theme as a non-optional parameter by changing theme?: Theme to theme: Theme, and
remove both the optional chaining operator (?) and the non-null assertion (!)
from the theme.palette.text.primary access.
In `@src/features/parameters/dynamic-simulation/curve/curve-parameters.tsx`:
- Around line 160-161: The code assumes getValues(mappingPath) returns a
non-empty array without validation, and can pass undefined or invalid mapping to
fetchDynamicSimulationModels. Add a guard to check that getValues(mappingPath)
returns a non-empty array before accessing the first element at index [0].
Additionally, validate that the mapping object is valid and non-empty before
passing it to fetchDynamicSimulationModels, returning undefined early if either
the array is empty or the mapping object is empty or undefined.
In
`@src/features/parameters/dynamic-simulation/use-dynamic-simulation-parameters-form.ts`:
- Line 59: The MAPPING field conversion is not handling the optional mapping
safely in both directions. At line 59 where the MAPPING array is created from
_params.mapping, add a conditional check to only create the one-item array if
mapping exists, otherwise use an empty array. At line 88 where the mapping value
is read from index 0 of the array, add a safety check to verify the array exists
and has content before accessing index 0, otherwise use a fallback value (likely
undefined or null). This ensures undefined values are not propagated through the
form pipeline.
🪄 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: 1c36f084-d6b0-4fa3-bea8-5d5b861397d3
📒 Files selected for processing (11)
src/components/ui/reactHookForm/directory-item-input/directory-item-input.tsxsrc/components/ui/reactHookForm/directory-item-input/directory-item-utils.tssrc/features/parameters/common/widget/parameter-line-directory-items-input.tsxsrc/features/parameters/dynamic-simulation/curve/common/checkbox-treeview.tsxsrc/features/parameters/dynamic-simulation/curve/curve-parameters.tsxsrc/features/parameters/dynamic-simulation/mapping/mapping-parameters-utils.tssrc/features/parameters/dynamic-simulation/mapping/mapping-parameters.tsxsrc/features/parameters/dynamic-simulation/use-dynamic-simulation-parameters-form.tssrc/services/dynamic-mapping.tssrc/translations/en/businessErrorsEn.tssrc/translations/fr/businessErrorsFr.ts
💤 Files with no reviewable changes (1)
- src/features/parameters/dynamic-simulation/mapping/mapping-parameters.tsx
🚧 Files skipped from review as they are similar to previous changes (4)
- src/translations/fr/businessErrorsFr.ts
- src/components/ui/reactHookForm/directory-item-input/directory-item-utils.ts
- src/translations/en/businessErrorsEn.ts
- src/components/ui/reactHookForm/directory-item-input/directory-item-input.tsx
|
| name: string; | ||
| } | ||
|
|
||
| export function DirectoryItemInput({ name, types, ...props }: Readonly<DirectoryItemSelectorInputProps>) { |
There was a problem hiding this comment.
be sure to clean in study
There was a problem hiding this comment.
will be done in Sprint 38
There was a problem hiding this comment.
Pull request overview
This PR updates dynamic simulation (DS) “mapping” handling to use directory-backed selection and UUID-based identification, and moves the related RHF directory-item input into commons-ui for reuse.
Changes:
- Replace DS mapping selection from a string/list fetcher to a directory selector (single-select) returning
{id,name}. - Update DS-related types and services to work with mapping UUIDs (and add
DYNAMIC_MAPPINGelement type + icon). - Add a reusable
reactHookForm/directory-item-inputmodule and related constants/utilities.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/types/parameters.type.ts | Switches DS ParametersInfos to an enriched shape (mapping object) |
| src/utils/types/elementType.ts | Replaces DYNAMIC_SIMULATION_MAPPING with DYNAMIC_MAPPING |
| src/utils/types/dynamic-simulation.type.ts | Introduces mappingId (DTO) + enriched mapping + mapper helper |
| src/utils/types/dynamic-margin-calculation.type.ts | Reuses shared IdName type for load filters |
| src/utils/mapper/getFileIcon.tsx | Adds icon mapping for DYNAMIC_MAPPING |
| src/translations/fr/businessErrorsFr.ts | Renames DS mapping error translation key/value (FR) |
| src/translations/en/businessErrorsEn.ts | Renames DS mapping error translation key/value (EN) |
| src/services/dynamic-mapping.ts | Updates model fetch to use mapping UUID (from {id,name}) |
| src/features/parameters/dynamic-simulation/use-dynamic-simulation-parameters-form.ts | Adapts DS form mapping field to directory-items array model |
| src/features/parameters/dynamic-simulation/mapping/mapping-parameters.tsx | Replaces old mapping dropdown with directory-items input |
| src/features/parameters/dynamic-simulation/mapping/mapping-parameters-utils.ts | Updates mapping validation schema to array-of-object |
| src/features/parameters/dynamic-simulation/dynamic-simulation-inline.tsx | Uses enriched params on submit and maps only for create-dialog formatter |
| src/features/parameters/dynamic-simulation/curve/curve-parameters.tsx | Uses selected mapping {id,name} to fetch models |
| src/features/parameters/dynamic-simulation/curve/common/checkbox-treeview.tsx | Cleans up theme prop usage in styled TreeItem |
| src/features/parameters/common/widget/parameter-line-directory-items-input.tsx | Makes hideErrorMessage optional |
| src/components/ui/reactHookForm/index.ts | Exports new directory-item-input module |
| src/components/ui/reactHookForm/directory-item-input/index.ts | Barrel export for new directory-item-input |
| src/components/ui/reactHookForm/directory-item-input/directory-item-utils.ts | Adds directory-item schema + absence label helper |
| src/components/ui/reactHookForm/directory-item-input/directory-item-input.tsx | New RHF input wrapping DirectoryItemSelector |
| src/components/ui/reactHookForm/constants.ts | Adds directory-item-related RHF constants |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (nodes.length > 0) { | ||
| const fullPath = nodes[0]?.name; | ||
| const nodeId: UUID | null = nodes[0]?.id; | ||
| if (nodeId) { | ||
| const newNodeInfos = { | ||
| [DIRECTORY_ITEM_ID]: nodeId, | ||
| [DIRECTORY_ITEM_FULL_PATH]: fullPath, | ||
| }; | ||
| onChange(newNodeInfos); |
There was a problem hiding this comment.
to build the full path, as demanded by our PO, the full path shoud be built by a specific maner to avoid cases in which path is so long.. This wil be done later..
| const onSubmit = useCallback( | ||
| (formData: FieldValues) => { | ||
| // update params after convert form representation to dto representation | ||
| updateParameters(toParamsInfos(formData, getDefaultParams())); | ||
| updateParameters(toParamsEnriched(formData, getDefaultParams())); | ||
| }, |
| export type ParametersInfos<T extends ComputingType> = T extends ComputingType.SENSITIVITY_ANALYSIS | ||
| ? SensitivityAnalysisParametersInfosEnriched | ||
| : T extends ComputingType.SECURITY_ANALYSIS | ||
| ? SAParametersEnriched | ||
| : T extends ComputingType.LOAD_FLOW | ||
| ? LoadFlowParametersInfos | ||
| : T extends ComputingType.DYNAMIC_SIMULATION | ||
| ? DynamicSimulationParametersInfos | ||
| ? DynamicSimulationParametersEnriched | ||
| : T extends ComputingType.DYNAMIC_SECURITY_ANALYSIS | ||
| ? DynamicSecurityAnalysisParametersFetchReturn |



PR Summary
https://github.com/gridsuite/gridstudy-app/tree/main/src/components/utils/rhf-inputs/directory-item-input