Skip to content

chore: use equipment deletion form from commons UI#3794

Open
dbraquart wants to merge 13 commits intomainfrom
dbraquart/use-eqpt-deletion-form-from-commons-ui
Open

chore: use equipment deletion form from commons UI#3794
dbraquart wants to merge 13 commits intomainfrom
dbraquart/use-eqpt-deletion-form-from-commons-ui

Conversation

@dbraquart
Copy link
Contributor

PR Summary

All files copied to commons-ui in gridsuite/commons-ui#1049 have been removed from grid-study in this PR.

Signed-off-by: David BRAQUART <david.braquart@rte-france.com>
Signed-off-by: David BRAQUART <david.braquart@rte-france.com>
Signed-off-by: David BRAQUART <david.braquart@rte-france.com>
Signed-off-by: David BRAQUART <david.braquart@rte-france.com>
@dbraquart dbraquart force-pushed the dbraquart/use-eqpt-deletion-form-from-commons-ui branch from 0411568 to c10c38a Compare March 10, 2026 20:27
@TheMaskedTurtle TheMaskedTurtle self-requested a review March 18, 2026 12:55
currentRootNetworkUuid,
editData,
isUpdate,
defaultIdValue, // Used to pre-select an equipmentId when calling this dialog from the SLD/map
Copy link
Contributor

Choose a reason for hiding this comment

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

keep comment ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure. done

…letion-form-from-commons-ui

# Conflicts:
#	src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-form.tsx
#	src/services/study/network-modifications.ts
#	src/translations/en.json
#	src/translations/fr.json
Signed-off-by: David BRAQUART <david.braquart@rte-france.com>
Signed-off-by: David BRAQUART <david.braquart@rte-france.com>
Signed-off-by: David BRAQUART <david.braquart@rte-france.com>
Signed-off-by: David BRAQUART <david.braquart@rte-france.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 20, 2026

📝 Walkthrough

Walkthrough

Consolidates equipment-deletion logic and shared UI into @gridsuite/commons-ui: local deletion forms, HVDC LCC helpers, read-only input components, and some hooks/types/translations were removed; service and dialog APIs were adapted to use shared DTOs, schemas, and utilities.

Changes

Cohort / File(s) Summary
Commons UI imports & i18n
src/components/app-wrapper.jsx
Merged equipmentTypesEn/equipmentTypesFr into app messages by importing from @gridsuite/commons-ui.
Read-only input imports
src/components/dialogs/line-types-catalog/line-type-segment-creation.tsx, src/components/dialogs/line-types-catalog/line-type-segment-form.tsx
Switched ReadOnlyInput/ButtonReadOnlyInput imports to @gridsuite/commons-ui instead of local read-only input modules.
Hook import migration
src/components/dialogs/network-modifications/.../modification-by-assignment-form.tsx, src/components/dialogs/network-modifications/.../by-filter-deletion-form.tsx
Replaced local useGetLabelEquipmentTypes with the export from @gridsuite/commons-ui for option labeling.
Equipment deletion dialog refactor
src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-dialog.tsx, src/components/graph/menus/network-modifications/network-modification-node-editor.tsx
Replaced local schema/logic with shared equipmentDeletionFormSchema, equipmentDeletionEmptyFormData, conversion helpers and added EquipmentDeletionDtoWithId; made equipmentType prop optional and adjusted editData type.
Removed local deletion UI modules
src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-form.tsx, src/components/dialogs/network-modifications/equipment-deletion/hvdc-lcc-deletion/hvdc-lcc-deletion-specific-form.tsx
Deleted DeleteEquipmentForm and HvdcLccDeletionSpecificForm components (UI and form wiring moved to commons-ui).
Removed HVDC LCC utilities & hook
src/components/dialogs/network-modifications/equipment-deletion/hvdc-lcc-deletion/hvdc-lcc-deletion-utils.ts, .../use-hvdc-lcc-deletion.ts
Deleted HVDC LCC validation utilities and useHvdcLccDeletion hook; their behavior was migrated to shared utilities.
Local types removed
src/components/dialogs/network-modifications/equipment-deletion/equipement-deletion-dialog.type.ts
Deleted local equipment-deletion-related TypeScript interfaces/types (LCC/HVDC-specific and composite deletion infos).
Read-only input modules removed
src/components/utils/rhf-inputs/read-only/read-only-input.tsx, src/components/utils/rhf-inputs/read-only/button-read-only-input.tsx
Deleted local ReadOnlyInput and ButtonReadOnlyInput implementations — now sourced from @gridsuite/commons-ui.
Service API signature change
src/services/study/network-modifications.ts
Replaced object-style deleteEquipment signature with deleteEquipment(studyUuid, nodeUuid, modificationUuid, dto: EquipmentDeletionDto) and send dto as request body via backendFetchText. Removed DeleteEquipmentInfo interface.
Network map & hook call updates
src/components/network/network-map-panel.tsx, src/hooks/use-equipment-dialogs.tsx
Updated calls to use new deleteEquipment signature and newEquipmentDeletionDto(...) factory from commons-ui; adjusted guards to require currentNode.id.
Service return type update
src/services/study/network-map.ts
Changed fetchHvdcLineWithShuntCompensators return type from Promise<HvdcLccDeletionInfos> to Promise<LccDeletionDto> and updated imports.
Local hook removed
src/hooks/use-get-label-equipment-types.ts
Deleted local useGetLabelEquipmentTypes hook; functionality now imported from commons-ui.
Translations trimmed
src/translations/en.json, src/translations/fr.json
Removed many equipment/type and HVDC/LCC-related translation keys and error/side labels (now provided via commons-ui translations).
🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'chore: use equipment deletion form from commons UI' directly and clearly describes the main objective of the changeset—consolidating equipment deletion form implementation by removing local copies and importing from commons-ui.
Description check ✅ Passed The description 'All files copied to commons-ui in gridsuite/commons-ui#1049 have been removed from grid-study in this PR' is directly related to and accurately summarizes the changeset's purpose.

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

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

🧹 Nitpick comments (1)
src/hooks/use-equipment-dialogs.tsx (1)

102-108: Please verify the new deletion DTO path still accepts non-UUID equipment ids.

This hook still works with plain string equipment ids, but the new commons-ui deletion helpers are only being satisfied via as UUID casts here. That hides the mismatch rather than fixing it; if newEquipmentDeletionDto or the shared deletion schema actually enforce UUID-shaped ids, direct deletes and the LCC preset path will stop working for regular network identifiers. The same cast was added in NetworkMapPanel, so it’s worth confirming both entrypoints together.

Also applies to: 228-228

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/hooks/use-equipment-dialogs.tsx` around lines 102 - 108, The code is
casting equipmentId to UUID when calling newEquipmentDeletionDto inside the
deleteEquipment path (in use-equipment-dialogs hook) which masks a potential
type mismatch: verify whether newEquipmentDeletionDto and the shared deletion
schema (used by deleteEquipment and NetworkMapPanel) truly require UUID-shaped
ids; if they must accept plain string network identifiers then remove the unsafe
"as UUID" casts and update the DTO/type definitions or overloads for
newEquipmentDeletionDto/deleteEquipment to accept string | UUID, or
alternatively enforce UUID validation at the callsite before casting so direct
deletes and the LCC preset path continue to work consistently.
🤖 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/equipment-deletion/equipment-deletion-dialog.tsx`:
- Around line 108-119: The effect currently always prefers truthy editData which
can be stale; update the useEffect logic (the block that calls
fromEditDataToFormValues, presetTypeAndId, presetType) to only apply
fromEditDataToFormValues when editData actually corresponds to the dialog
instance (e.g. editData?.id === defaultIdValue or editData?.type ===
equipmentType or another identifying field), otherwise fall through to creation
presets; specifically modify the first branch to guard editData with a match
check and keep presetTypeAndId/presetType branches when
equipmentType/defaultIdValue indicate creation mode so stale editData won't
overwrite presets.

---

Nitpick comments:
In `@src/hooks/use-equipment-dialogs.tsx`:
- Around line 102-108: The code is casting equipmentId to UUID when calling
newEquipmentDeletionDto inside the deleteEquipment path (in
use-equipment-dialogs hook) which masks a potential type mismatch: verify
whether newEquipmentDeletionDto and the shared deletion schema (used by
deleteEquipment and NetworkMapPanel) truly require UUID-shaped ids; if they must
accept plain string network identifiers then remove the unsafe "as UUID" casts
and update the DTO/type definitions or overloads for
newEquipmentDeletionDto/deleteEquipment to accept string | UUID, or
alternatively enforce UUID validation at the callsite before casting so direct
deletes and the LCC preset path continue to work consistently.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fda49a69-bd05-4701-8873-34b53d1105f2

📥 Commits

Reviewing files that changed from the base of the PR and between 08f70d1 and 8023f53.

📒 Files selected for processing (21)
  • src/components/app-wrapper.jsx
  • src/components/dialogs/line-types-catalog/line-type-segment-creation.tsx
  • src/components/dialogs/line-types-catalog/line-type-segment-form.tsx
  • src/components/dialogs/network-modifications/by-filter/by-assignment/modification-by-assignment-form.tsx
  • src/components/dialogs/network-modifications/by-filter/by-filter-deletion/by-filter-deletion-form.tsx
  • src/components/dialogs/network-modifications/equipment-deletion/equipement-deletion-dialog.type.ts
  • src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-dialog.tsx
  • src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-form.tsx
  • src/components/dialogs/network-modifications/equipment-deletion/hvdc-lcc-deletion/hvdc-lcc-deletion-specific-form.tsx
  • src/components/dialogs/network-modifications/equipment-deletion/hvdc-lcc-deletion/hvdc-lcc-deletion-utils.ts
  • src/components/dialogs/network-modifications/equipment-deletion/hvdc-lcc-deletion/use-hvdc-lcc-deletion.ts
  • src/components/graph/menus/network-modifications/network-modification-node-editor.tsx
  • src/components/network/network-map-panel.tsx
  • src/components/utils/rhf-inputs/read-only/button-read-only-input.tsx
  • src/components/utils/rhf-inputs/read-only/read-only-input.tsx
  • src/hooks/use-equipment-dialogs.tsx
  • src/hooks/use-get-label-equipment-types.ts
  • src/services/study/network-map.ts
  • src/services/study/network-modifications.ts
  • src/translations/en.json
  • src/translations/fr.json
💤 Files with no reviewable changes (10)
  • src/hooks/use-get-label-equipment-types.ts
  • src/components/dialogs/network-modifications/equipment-deletion/equipement-deletion-dialog.type.ts
  • src/components/dialogs/network-modifications/equipment-deletion/hvdc-lcc-deletion/hvdc-lcc-deletion-utils.ts
  • src/components/dialogs/network-modifications/equipment-deletion/hvdc-lcc-deletion/hvdc-lcc-deletion-specific-form.tsx
  • src/components/utils/rhf-inputs/read-only/button-read-only-input.tsx
  • src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-form.tsx
  • src/components/utils/rhf-inputs/read-only/read-only-input.tsx
  • src/translations/fr.json
  • src/components/dialogs/network-modifications/equipment-deletion/hvdc-lcc-deletion/use-hvdc-lcc-deletion.ts
  • src/translations/en.json

Comment on lines 108 to +119
useEffect(() => {
if (editData) {
// edition mode
fromEditDataToFormValues(editData);
} else if (defaultIdValue) {
fromMenuDataValues(defaultIdValue);
} else if (equipmentType && defaultIdValue) {
// creation mode with both Id and Type (ex: from diagram)
presetTypeAndId(equipmentType, defaultIdValue);
} else if (equipmentType) {
resetFormWithEquipmentType(equipmentType);
// creation mode with only Type (ex: from node modifications menu)
presetType(equipmentType);
}
}, [
fromEditDataToFormValues,
editData,
fromMenuDataValues,
defaultIdValue,
equipmentType,
resetFormWithEquipmentType,
]);
}, [defaultIdValue, editData, equipmentType, fromEditDataToFormValues, presetType, presetTypeAndId]);
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

Guard the new creation presets from stale edit data.

A late edit-data response can still land after a previous edit dialog was closed. With the new equipmentType / defaultIdValue branches, this effect will still prefer any truthy editData, so reopening the dialog in creation mode can reset the form with stale deletion values instead of the requested preset.

Suggested fix
-        if (editData) {
+        if (isUpdate && editData) {
             // edition mode
             fromEditDataToFormValues(editData);
         } else if (equipmentType && defaultIdValue) {
             // creation mode with both Id and Type (ex: from diagram)
             presetTypeAndId(equipmentType, defaultIdValue);
         } else if (equipmentType) {
             // creation mode with only Type (ex: from node modifications menu)
             presetType(equipmentType);
         }
-    }, [defaultIdValue, editData, equipmentType, fromEditDataToFormValues, presetType, presetTypeAndId]);
+    }, [defaultIdValue, editData, equipmentType, fromEditDataToFormValues, isUpdate, presetType, presetTypeAndId]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-dialog.tsx`
around lines 108 - 119, The effect currently always prefers truthy editData
which can be stale; update the useEffect logic (the block that calls
fromEditDataToFormValues, presetTypeAndId, presetType) to only apply
fromEditDataToFormValues when editData actually corresponds to the dialog
instance (e.g. editData?.id === defaultIdValue or editData?.type ===
equipmentType or another identifying field), otherwise fall through to creation
presets; specifically modify the first branch to guard editData with a match
check and keep presetTypeAndId/presetType branches when
equipmentType/defaultIdValue indicate creation mode so stale editData won't
overwrite presets.

Signed-off-by: David BRAQUART <david.braquart@rte-france.com>
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/equipment-deletion/equipment-deletion-dialog.tsx (1)

112-123: ⚠️ Potential issue | 🟠 Major

Guard edit mapping with update mode to avoid stale creation presets.

Line 113 should not prioritize editData in creation mode; stale edit payloads can overwrite equipmentType/defaultIdValue presets.

Proposed fix
-    useEffect(() => {
-        if (editData) {
+    useEffect(() => {
+        if (isUpdate && editData) {
             // edition mode
             fromEditDataToFormValues(editData);
         } else if (equipmentType && defaultIdValue) {
             // creation mode with both Id and Type (ex: from diagram)
             presetTypeAndId(equipmentType, defaultIdValue);
         } else if (equipmentType) {
             // creation mode with only Type (ex: from node modifications menu)
             presetType(equipmentType);
         }
-    }, [defaultIdValue, editData, equipmentType, fromEditDataToFormValues, presetType, presetTypeAndId]);
+    }, [defaultIdValue, editData, equipmentType, fromEditDataToFormValues, isUpdate, presetType, presetTypeAndId]);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-dialog.tsx`
around lines 112 - 123, The effect currently applies editData unconditionally,
overwriting creation presets; change the condition to only call
fromEditDataToFormValues(editData) when the dialog is in update mode (e.g.,
guard with an isUpdateMode/isEditing flag) so that creation flows use
presetTypeAndId(presetType) when equipmentType/defaultIdValue exist; update the
useEffect dependency list to include that mode flag and ensure the branches
check (isUpdateMode && editData) first, otherwise preserve the existing
equipmentType/defaultIdValue handling using presetType and presetTypeAndId.
🤖 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/equipment-deletion/equipment-deletion-dialog.tsx`:
- Around line 112-123: The effect currently applies editData unconditionally,
overwriting creation presets; change the condition to only call
fromEditDataToFormValues(editData) when the dialog is in update mode (e.g.,
guard with an isUpdateMode/isEditing flag) so that creation flows use
presetTypeAndId(presetType) when equipmentType/defaultIdValue exist; update the
useEffect dependency list to include that mode flag and ensure the branches
check (isUpdateMode && editData) first, otherwise preserve the existing
equipmentType/defaultIdValue handling using presetType and presetTypeAndId.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d1935305-dc5b-44a6-a271-6e8fc610a83d

📥 Commits

Reviewing files that changed from the base of the PR and between 8023f53 and ac3a4dd.

📒 Files selected for processing (1)
  • src/components/dialogs/network-modifications/equipment-deletion/equipment-deletion-dialog.tsx

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