Skip to content

feat: add generic VoltageLevelCreationForm component#1037

Open
achour94 wants to merge 11 commits intogridsuite:mainfrom
achour94:claude/genericize-voltage-level-form-IWuc8
Open

feat: add generic VoltageLevelCreationForm component#1037
achour94 wants to merge 11 commits intogridsuite:mainfrom
achour94:claude/genericize-voltage-level-form-IWuc8

Conversation

@achour94
Copy link
Contributor

@achour94 achour94 commented Mar 2, 2026

Move VoltageLevelCreationForm from gridstudy-app to commons-ui as a reusable component. The form includes basic voltage level fields (ID, name, substation, nominal voltage, voltage limits, short circuit limits, properties) and supports optional substationOptions prop for autocomplete mode vs free text. When no substationOptions are provided, the substation field is a free text input. The component also accepts children for extending with additional form sections.

Includes types, utils (schema, dto converters, empty form data), and translations (en/fr).

https://claude.ai/code/session_01CUA6hVhwcTV96EMWeQrKFv

PR Summary

claude added 11 commits March 2, 2026 09:05
Move VoltageLevelCreationForm from gridstudy-app to commons-ui as a
reusable component. The form includes basic voltage level fields (ID,
name, substation, nominal voltage, voltage limits, short circuit limits,
properties) and supports optional substationOptions prop for autocomplete
mode vs free text. When no substationOptions are provided, the substation
field is a free text input. The component also accepts children for
extending with additional form sections.

Includes types, utils (schema, dto converters, empty form data), and
translations (en/fr).

https://claude.ai/code/session_01CUA6hVhwcTV96EMWeQrKFv
…d sub-components

Move all VL creation related code into commons-ui:
- Add missing field constants to FieldConstants enum (BUS_BAR_COUNT, SECTION_COUNT, etc.)
- Move full VL creation schema, form data types, DTO types, and form-to-dto/dto-to-form converters
- Move SwitchesBetweenSections, CreateSwitchesDialog, and related components
- Move CouplingOmnibusForm, CouplingOmnibusCreation, and related components
- Create SubstationCreationSection component for inline substation creation
- Include BusBarSections and CouplingOmnibus in VoltageLevelCreationForm
- Add EN/FR translations for all VL creation form labels
- Make form generic with optional props (substationOptions, customSubstationSection, hideBusBarSection)

https://claude.ai/code/session_01CUA6hVhwcTV96EMWeQrKFv
…ble field names

- Move full gridstudy schema into commons-ui (ADD_SUBSTATION_CREATION,
  SUBSTATION_CREATION_ID, SUBSTATION_NAME, COUNTRY, SUBSTATION_CREATION fields)
- Replace IS_ATTACHMENT_POINT_CREATION with HIDE_NOMINAL_VOLTAGE and
  HIDE_BUS_BAR_SECTION for clearer schema intent
- Add SubstationCreationSection toggle logic directly in VoltageLevelCreationForm
  (watches ADD_SUBSTATION_CREATION to switch between substation select and creation)
- Add AttachedSubstationCreationDto type and include substationCreation in
  VoltageLevelCreationDto
- Update formToDto to build substationCreation object when ADD_SUBSTATION_CREATION
- Update dtoToForm to detect and restore substationCreation data
- Remove customSubstationSection, hideNominalVoltage, hideBusBarSection props
  (form reads these from form context fields instead)

https://claude.ai/code/session_01CUA6hVhwcTV96EMWeQrKFv
…VL form

Use yup from commons-ui yupConfig (with locale) instead of direct yup
imports, and move fetchDefaultCountry logic from gridstudy into the
generic VoltageLevelCreationForm component.

https://claude.ai/code/session_01CUA6hVhwcTV96EMWeQrKFv
…ected DTO types

- Replace manually written VoltageLevelCreationFormData interface with
  yup.InferType<typeof voltageLevelCreationFormSchema>
- Add SwitchKind enum to replace string literals
- Fix CouplingDevice DTO to use busbarSectionId1/2 matching backend API
- Map coupling device field names between form (busBarSectionId1) and DTO (busbarSectionId1)
- Remove topologyKind from DTO and formToDto/dtoToForm
- Remove FormSchemaType duplication in consumers

https://claude.ai/code/session_01CUA6hVhwcTV96EMWeQrKFv
…sion

Add VoltageLevelFormInfos type matching network-map-server schema and
refactor voltageLevelCreationDtoToForm to accept both VoltageLevelFormInfos
and VoltageLevelCreationDto using a type guard discriminator.

https://claude.ai/code/session_01CUA6hVhwcTV96EMWeQrKFv
…ions

Export voltageLevelCreationDtoToForm (VoltageLevelCreationDto → form) and
voltageLevelInfosToForm (VoltageLevelFormInfos → form) as separate public
functions instead of a single discriminated union function.

https://claude.ai/code/session_01CUA6hVhwcTV96EMWeQrKFv
- Add optional intl param for switch kind translation
- Fix substation properties: use raw properties instead of
  getFilledPropertiesFromModification to match original setValue behavior
- Fix main VL properties: use getPropertiesFromModification (keeps all
  properties including null values) instead of getFilledPropertiesFromModification

https://claude.ai/code/session_01CUA6hVhwcTV96EMWeQrKFv
Extract the showDeleteSubstationButton logic from the component internals
and expose it as an optional prop with a default value of true.

https://claude.ai/code/session_01CUA6hVhwcTV96EMWeQrKFv
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