Skip to content

Move Voltage Level Modification functionality and related components into commons-ui#3820

Merged
achour94 merged 10 commits intomainfrom
achour/move-vl-modification-into-commons-ui
Mar 25, 2026
Merged

Move Voltage Level Modification functionality and related components into commons-ui#3820
achour94 merged 10 commits intomainfrom
achour/move-vl-modification-into-commons-ui

Conversation

@achour94
Copy link
Contributor

PR Summary

…into commons-ui

Signed-off-by: achour94 <berrahmaachour@gmail.com>
@achour94 achour94 self-assigned this Mar 19, 2026
…cation-into-commons-ui

# Conflicts:
#	src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-form.tsx
@coderabbitai
Copy link

coderabbitai bot commented Mar 20, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Voltage-level modification flow was refactored to use shared DTOs and form utilities from @gridsuite/commons-ui, the local form component and several local types were removed, the service API now accepts/spreads a VoltageLevelModificationDto, and two i18n keys were deleted.

Changes

Cohort / File(s) Summary
Dialog refactor
src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.tsx
Dialog now consumes VoltageLevelModificationDto, initializes form via shared utilities (useFormWithDirtyTracking, voltageLevelModificationFormSchema, voltageLevelModificationEmptyFormData with FieldConstants), preserves equipment/substation IDs on reset/update, and submits via voltageLevelModificationFormToDto.
Form removal
src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-form.tsx
Deleted the VoltageLevelModificationForm React component and its local form types/props/UI rendering; dialog relies on shared form component/DTOs.
Type cleanup
src/components/dialogs/network-modifications/voltage-level/voltage-level.type.ts, src/services/network-modification-types.ts
Removed local types (VoltageLevelDto, IdentifiableShortCircuitDto, VoltageLeveModificationInfo) and the SwitchKind import; code now uses shared DTOs from @gridsuite/commons-ui.
Service signature
src/services/study/network-modifications.ts
modifyVoltageLevel signature changed to accept { studyUuid, nodeUuid, modificationUuid? } & VoltageLevelModificationDto and sends the DTO as request body (JSON.stringify(dto)) instead of assembling per-field modification operations.
Translations
src/translations/en.json, src/translations/fr.json
Removed ModifyVoltageLevel and VoltageLevelModificationError keys from English and French locales. Review callers for removed i18n keys.
Creation dialog import
src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-dialog.tsx
Switched to importing VoltageLevelDto from @gridsuite/commons-ui instead of local type file; usage unchanged.

Sequence Diagram(s)

sequenceDiagram
  participant User as "User"
  participant Dialog as "VoltageLevelModificationDialog"
  participant FormUtil as "commons-ui\nForm Utilities"
  participant Service as "Study Service\nmodifyVoltageLevel"
  participant Backend as "Backend API"

  rect rgba(63, 81, 181, 0.5)
  User->>Dialog: open dialog / request voltage-level data
  Dialog->>FormUtil: init form (voltageLevelModificationEmptyFormData + flags)
  FormUtil-->>Dialog: form instance
  end

  rect rgba(3, 169, 244, 0.5)
  Dialog->>Service: fetch equipment/voltage-level (if needed)
  Service-->>Dialog: voltageLevelToModify (VoltageLevelDto)
  Dialog->>FormUtil: reset(formFromDto(voltageLevelToModify)), preserve IDs
  end

  rect rgba(0, 150, 136, 0.5)
  User->>Dialog: submit
  Dialog->>FormUtil: get current form state
  FormUtil-->>Dialog: voltageLevelModificationFormData
  Dialog->>Service: modifyVoltageLevel({ studyUuid, nodeUuid, ...dto })
  Service->>Backend: POST body = JSON.stringify(dto)
  Backend-->>Service: 200 / error
  Service-->>Dialog: result
  Dialog-->>User: success / error
  end
Loading

Suggested reviewers

  • TheMaskedTurtle
🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is completely empty, providing no information about the changeset or its objectives. Add a detailed description explaining what was moved, why, and any breaking changes or migration steps for reviewers.
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 (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: moving Voltage Level Modification functionality into commons-ui, which aligns with the substantial refactoring shown across multiple files.

✏️ 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 and usage tips.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

license-eye has totally checked 938 files.

Valid Invalid Ignored Fixed
892 1 45 0
Click to see the invalid file list
  • src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-form.tsx

Signed-off-by: achour94 <berrahmaachour@gmail.com>
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

license-eye has totally checked 938 files.

Valid Invalid Ignored Fixed
892 1 45 0
Click to see the invalid file list
  • src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-form.tsx

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.tsx`:
- Around line 145-156: When the fetch fails we clear voltageLevelToModify but
leave the selector hidden because selectedId remains set; update the catch block
to also restore the equipment selector by calling setSelectedId(null) (or
setSelectedId(editData?.equipmentId) if you want to fall back to the previous
selection) after setDataFetchStatus(FetchStatus.FAILED) and reset(...). Modify
the catch branch that calls setVoltageLevelToModify(undefined) to also invoke
setSelectedId(...) so the selector becomes visible and the user can pick another
equipment.

In `@src/services/study/network-modifications.ts`:
- Around line 59-61: The import list containing VoltageLevelCreationInfo and
VscCreationInfos has an extra blank line breaking Prettier rules; edit the named
import block that includes VoltageLevelCreationInfo and VscCreationInfos (the
import statement that exports these types) and remove the stray blank line so
the named imports are contiguous on consecutive lines with no empty line between
them.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7e90b025-5dd8-462f-8775-158629d61686

📥 Commits

Reviewing files that changed from the base of the PR and between 602ba8e and 2c15592.

📒 Files selected for processing (7)
  • src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.tsx
  • src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-form.tsx
  • src/components/dialogs/network-modifications/voltage-level/voltage-level.type.ts
  • src/services/network-modification-types.ts
  • src/services/study/network-modifications.ts
  • src/translations/en.json
  • src/translations/fr.json
💤 Files with no reviewable changes (5)
  • src/services/network-modification-types.ts
  • src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-form.tsx
  • src/translations/en.json
  • src/translations/fr.json
  • src/components/dialogs/network-modifications/voltage-level/voltage-level.type.ts

Comment on lines +145 to +156
.catch(() => {
setDataFetchStatus(FetchStatus.FAILED);
reset((formValues) => ({ ...formValues, [FieldConstants.EQUIPMENT_ID]: equipmentId }), {
keepDirty: true,
});
if (editData?.equipmentId !== equipmentId) {
setVoltageLevelInfos(null);
setVoltageLevelToModify(undefined);
}
});
} else {
setVoltageLevelInfos(null);
reset(emptyFormData, { keepDefaultValues: true });
setVoltageLevelToModify(undefined);
reset(voltageLevelModificationEmptyFormData, { keepDefaultValues: true });
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Restore the equipment selector after a fetch failure.

If a newly selected or default voltage level fails to load, selectedId stays set while voltageLevelToModify is cleared. Because the selector is only shown when selectedId == null, the dialog gets stuck on an empty form and the user cannot pick another equipment without closing it.

↩️ One simple recovery path
                 .catch(() => {
                     setDataFetchStatus(FetchStatus.FAILED);
                     reset((formValues) => ({ ...formValues, [FieldConstants.EQUIPMENT_ID]: equipmentId }), {
                         keepDirty: true,
                     });
                     if (editData?.equipmentId !== equipmentId) {
                         setVoltageLevelToModify(undefined);
+                        setSelectedId(null);
                     }
                 });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.tsx`
around lines 145 - 156, When the fetch fails we clear voltageLevelToModify but
leave the selector hidden because selectedId remains set; update the catch block
to also restore the equipment selector by calling setSelectedId(null) (or
setSelectedId(editData?.equipmentId) if you want to fall back to the previous
selection) after setDataFetchStatus(FetchStatus.FAILED) and reset(...). Modify
the catch branch that calls setVoltageLevelToModify(undefined) to also invoke
setSelectedId(...) so the selector becomes visible and the user can pick another
equipment.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

license-eye has totally checked 938 files.

Valid Invalid Ignored Fixed
892 1 45 0
Click to see the invalid file list
  • src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-form.tsx

@KoloMenek
Copy link
Member

There is an issue with the substationid field being empty in the form. A solution is being implemented. The other components of the form seemed to be working fine.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

license-eye has totally checked 938 files.

Valid Invalid Ignored Fixed
892 1 45 0
Click to see the invalid file list
  • src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-form.tsx

Signed-off-by: achour94 <berrahmaachour@gmail.com>
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

license-eye has totally checked 939 files.

Valid Invalid Ignored Fixed
893 1 45 0
Click to see the invalid file list
  • src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-form.tsx

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

license-eye has totally checked 939 files.

Valid Invalid Ignored Fixed
893 1 45 0
Click to see the invalid file list
  • src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-form.tsx

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.tsx (1)

153-160: ⚠️ Potential issue | 🟠 Major

Restore the selector after a fetch failure.

This branch still clears voltageLevelToModify without clearing selectedId, so the dialog stays on the form path and the user cannot pick another equipment after the error.

Suggested recovery fix
                     if (editData?.equipmentId !== equipmentId) {
                         setVoltageLevelToModify(undefined);
+                        setSelectedId(null);
                     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.tsx`
around lines 153 - 160, On fetch failure the catch branch clears
voltageLevelToModify but leaves selectedId set, preventing the UI from returning
to the selector; update the catch block (the code using setDataFetchStatus,
reset and setVoltageLevelToModify) to also clear the selection by calling the
selector setter (e.g. setSelectedId(undefined) or equivalent) so both
voltageLevelToModify and selectedId are cleared when editData?.equipmentId !==
equipmentId, ensuring the dialog returns to the equipment selector after a
failed fetch; keep the existing reset(...) and
setDataFetchStatus(FetchStatus.FAILED) behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In
`@src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.tsx`:
- Around line 153-160: On fetch failure the catch branch clears
voltageLevelToModify but leaves selectedId set, preventing the UI from returning
to the selector; update the catch block (the code using setDataFetchStatus,
reset and setVoltageLevelToModify) to also clear the selection by calling the
selector setter (e.g. setSelectedId(undefined) or equivalent) so both
voltageLevelToModify and selectedId are cleared when editData?.equipmentId !==
equipmentId, ensuring the dialog returns to the equipment selector after a
failed fetch; keep the existing reset(...) and
setDataFetchStatus(FetchStatus.FAILED) behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 572871b6-532b-481b-8556-2566fd44e085

📥 Commits

Reviewing files that changed from the base of the PR and between 20aa5c4 and e259d63.

📒 Files selected for processing (1)
  • src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-dialog.tsx

@KoloMenek KoloMenek self-requested a review March 25, 2026 14:43
Copy link
Member

@KoloMenek KoloMenek left a comment

Choose a reason for hiding this comment

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

Looks good to me

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

license-eye has totally checked 931 files.

Valid Invalid Ignored Fixed
885 1 45 0
Click to see the invalid file list
  • src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-form.tsx

…tion dialog

Signed-off-by: achour94 <berrahmaachour@gmail.com>
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

license-eye has totally checked 931 files.

Valid Invalid Ignored Fixed
885 1 45 0
Click to see the invalid file list
  • src/components/dialogs/network-modifications/voltage-level/modification/voltage-level-modification-form.tsx

…tion dialog

Signed-off-by: achour94 <berrahmaachour@gmail.com>
@sonarqubecloud
Copy link

@achour94 achour94 merged commit 07c880d into main Mar 25, 2026
6 checks passed
@achour94 achour94 deleted the achour/move-vl-modification-into-commons-ui branch March 25, 2026 18:26
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