Skip to content

Manage DS mapping by directory - #1183

Merged
thangqp merged 16 commits into
mainfrom
manage_ds_mapping_via_directory
Jun 26, 2026
Merged

Manage DS mapping by directory#1183
thangqp merged 16 commits into
mainfrom
manage_ds_mapping_via_directory

Conversation

@thangqp

@thangqp thangqp commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

PR Summary

Signed-off-by: Thang PHAM <phamthang37@gmail.com>
@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@thangqp, we couldn't start this review because you've reached your PR review rate limit.

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 @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 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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2a704d6a-d199-4de9-b402-4e9157b38710

📥 Commits

Reviewing files that changed from the base of the PR and between 04b96e6 and d9e4f3b.

📒 Files selected for processing (1)
  • src/components/ui/reactHookForm/directory-item-input/directory-item-input.tsx
📝 Walkthrough

Walkthrough

The PR refactors dynamic simulation mapping from a plain string field to a structured IdName object. It introduces DynamicSimulationParametersEnriched, updates form conversion and validation, adds a directory selection input, refactors mapping rendering, updates the service API, and renames related i18n keys.

Changes

Dynamic simulation mapping enriched type refactor

Layer / File(s) Summary
Type contracts: enriched mapping shape and IdName alignment
src/utils/types/dynamic-simulation.type.ts, src/utils/types/parameters.type.ts, src/utils/types/dynamic-margin-calculation.type.ts
DynamicSimulationParametersInfos now uses mappingId?: UUID. DynamicSimulationParametersEnriched adds mapping?: IdName, mapDynamicSimulationParameters converts it back to infos, ParametersInfos<T> resolves to the enriched type, and LoadsVariationInfos.loadFilters now uses IdName[].
Form schema and conversion functions
src/features/parameters/dynamic-simulation/mapping/mapping-parameters-utils.ts, src/features/parameters/dynamic-simulation/use-dynamic-simulation-parameters-form.ts
MAPPING validation becomes a required array of { ID, NAME } objects, default mapping data becomes [], toFormValues accepts enriched parameters and writes mapping as a single-element array, and toParamsEnriched reads mapping from the first array item.
Directory item selection input component
src/components/ui/reactHookForm/constants.ts, src/components/ui/reactHookForm/directory-item-input/*, src/components/ui/reactHookForm/index.ts
Adds directory item field constants, the DirectoryItemInput component, directory item schema utilities, and barrel exports for the new module.
Element type and icon support
src/utils/types/elementType.ts, src/utils/mapper/getFileIcon.tsx
ElementType replaces DYNAMIC_SIMULATION_MAPPING with DYNAMIC_MAPPING, and getFileIcon returns AutoGraphRoundedIcon for that value.
Service API layer updates
src/services/dynamic-mapping.ts
fetchDynamicSimulationModels now accepts IdName and uses mapping.id, and getDynamicMappings is removed.
Dynamic simulation form field handling
src/features/parameters/dynamic-simulation/curve/curve-parameters.tsx, src/features/parameters/common/widget/parameter-line-directory-items-input.tsx, src/features/parameters/dynamic-simulation/curve/common/checkbox-treeview.tsx
curve-parameters reads the first mapping item before fetching models, hideErrorMessage becomes optional, and checkbox-treeview no longer passes theme state into BorderedTreeItem.
UI rendering and call-site updates
src/features/parameters/dynamic-simulation/mapping/mapping-parameters.tsx, src/features/parameters/dynamic-simulation/dynamic-simulation-inline.tsx
MappingParameters now renders ParameterLineDirectoryItemsInput directly for DYNAMIC_MAPPING, and dynamic-simulation-inline switches to toParamsEnriched in submit and dialog formatting paths.
i18n key rename
src/translations/en/businessErrorsEn.ts, src/translations/fr/businessErrorsFr.ts
The dynamic mapping missing-value translation key changes from mappingNameNotProvided to mappingNotProvided in English and French.

Suggested reviewers

  • dbraquart
  • khouadrired
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main change: DS mapping is now managed through a directory-based selector and UUID-based mapping.
Description check ✅ Passed The description aligns with the changes, covering the new directory item input and the DS mapping UUID conversion.
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.

✏️ 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.

❤️ 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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between af59593 and 0454cc4.

📒 Files selected for processing (10)
  • src/features/parameters/dynamic-simulation/dynamic-simulation-inline.tsx
  • src/features/parameters/dynamic-simulation/mapping/mapping-parameters-utils.ts
  • src/features/parameters/dynamic-simulation/mapping/mapping-parameters.tsx
  • src/features/parameters/dynamic-simulation/use-dynamic-simulation-parameters-form.ts
  • src/services/dynamic-mapping.ts
  • src/translations/en/businessErrorsEn.ts
  • src/translations/fr/businessErrorsFr.ts
  • src/utils/types/dynamic-margin-calculation.type.ts
  • src/utils/types/dynamic-simulation.type.ts
  • src/utils/types/parameters.type.ts

Comment thread src/features/parameters/dynamic-simulation/mapping/mapping-parameters-utils.ts Outdated
Comment thread src/utils/types/dynamic-simulation.type.ts

@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: 2

♻️ Duplicate comments (1)
src/components/ui/reactHookForm/directory-item-input/directory-item-input.tsx (1)

11-11: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Build failure: '@gridsuite/commons-ui' module not found.

The import of @gridsuite/commons-ui is causing TypeScript compilation to fail. This is the same dependency issue affecting directory-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

📥 Commits

Reviewing files that changed from the base of the PR and between 0454cc4 and 96bd5fb.

📒 Files selected for processing (10)
  • src/components/ui/reactHookForm/constants.ts
  • src/components/ui/reactHookForm/directory-item-input/directory-item-input.tsx
  • src/components/ui/reactHookForm/directory-item-input/directory-item-utils.ts
  • src/components/ui/reactHookForm/directory-item-input/index.ts
  • src/components/ui/reactHookForm/index.ts
  • src/features/parameters/dynamic-simulation/dynamic-simulation-inline.tsx
  • src/features/parameters/dynamic-simulation/mapping/mapping-parameters.tsx
  • src/services/dynamic-mapping.ts
  • src/utils/mapper/getFileIcon.tsx
  • src/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

Comment thread src/components/ui/reactHookForm/directory-item-input/directory-item-utils.ts Outdated
thangqp and others added 4 commits June 23, 2026 10:31
Signed-off-by: Thang PHAM <phamthang37@gmail.com>
Signed-off-by: Thang PHAM <phamthang37@gmail.com>

@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/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

📥 Commits

Reviewing files that changed from the base of the PR and between 96bd5fb and b2ee530.

📒 Files selected for processing (11)
  • src/components/ui/reactHookForm/directory-item-input/directory-item-input.tsx
  • src/components/ui/reactHookForm/directory-item-input/directory-item-utils.ts
  • src/features/parameters/common/widget/parameter-line-directory-items-input.tsx
  • src/features/parameters/dynamic-simulation/curve/common/checkbox-treeview.tsx
  • src/features/parameters/dynamic-simulation/curve/curve-parameters.tsx
  • src/features/parameters/dynamic-simulation/mapping/mapping-parameters-utils.ts
  • src/features/parameters/dynamic-simulation/mapping/mapping-parameters.tsx
  • src/features/parameters/dynamic-simulation/use-dynamic-simulation-parameters-form.ts
  • src/services/dynamic-mapping.ts
  • src/translations/en/businessErrorsEn.ts
  • src/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

Comment thread src/features/parameters/dynamic-simulation/curve/common/checkbox-treeview.tsx Outdated
Comment thread src/features/parameters/dynamic-simulation/curve/curve-parameters.tsx Outdated
thangqp and others added 3 commits June 23, 2026 18:25
Signed-off-by: Thang PHAM <phamthang37@gmail.com>
Signed-off-by: Thang PHAM <phamthang37@gmail.com>
@thangqp
thangqp requested a review from FranckLecuyer June 24, 2026 10:38
@sonarqubecloud

Copy link
Copy Markdown

@thangqp thangqp added the waiting-for-review PR ready for an owner to review label Jun 25, 2026
@antoinebhs
antoinebhs requested a review from Copilot June 26, 2026 07:47
name: string;
}

export function DirectoryItemInput({ name, types, ...props }: Readonly<DirectoryItemSelectorInputProps>) {

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.

be sure to clean in study

@thangqp thangqp Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

will be done in Sprint 38

Copilot AI 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.

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_MAPPING element type + icon).
  • Add a reusable reactHookForm/directory-item-input module 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.

Comment on lines +40 to +48
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);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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

Comment on lines 89 to 93
const onSubmit = useCallback(
(formData: FieldValues) => {
// update params after convert form representation to dto representation
updateParameters(toParamsInfos(formData, getDefaultParams()));
updateParameters(toParamsEnriched(formData, getDefaultParams()));
},
Comment on lines 43 to 52
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
@antoinebhs antoinebhs removed the waiting-for-review PR ready for an owner to review label Jun 26, 2026
@antoinebhs antoinebhs self-assigned this Jun 26, 2026
@thangqp
thangqp merged commit f711259 into main Jun 26, 2026
7 checks passed
@thangqp
thangqp deleted the manage_ds_mapping_via_directory branch June 26, 2026 11:02
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.

4 participants