Skip to content

Consume network-modification-table renderers from commons-ui#3945

Open
flomillot wants to merge 9 commits into
mainfrom
perf/move-network-modification-renderers
Open

Consume network-modification-table renderers from commons-ui#3945
flomillot wants to merge 9 commits into
mainfrom
perf/move-network-modification-renderers

Conversation

@flomillot
Copy link
Copy Markdown
Contributor

@flomillot flomillot commented May 13, 2026

Summary

The per-row cells, the cell-renderers adapter, the two services (setModificationMetadata, updateModificationStatusByRootNetwork) and the @tanstack/react-table module augmentation they relied on have moved to commons-ui.

  • Local files are deleted and createColumns now imports the renderers from @gridsuite/commons-ui.
  • createRootNetworksColumns is simplified: it only needs the root-networks list since the rest of the per-column meta (rootNetwork, modificationsToExclude, isCurrentRootNetwork, currentRootNetworkTag) is now derived from TableMeta.
  • The node editor passes studyUuid, currentNodeId, currentRootNetworkUuid, rootNetworks, modificationsToExclude, setModificationsToExclude and a combined isDisabled (isAnyNodeBuilding || mapDataLoading) to NetworkModificationsTable.
  • gridstudy-app/src/module-tanstack.d.ts is removed; the augmentation lives in commons-ui.

Companion PR on commons-ui: https://github.com/gridsuite/commons-ui/pulls?q=is%3Apr+head%3Aperf%2Fmove-network-modification-renderers

flomillot and others added 6 commits May 4, 2026 18:00
Stop unmounting cells (and resetting their local state like SwitchCell's
modificationActivated) on every columns rebuild by hoisting all cell/header
renderers to module scope and routing dynamic values through react-table
meta instead of closure capture.

- Hoist renderers to a new cell-renderers.tsx (DragHandle, Select, Name,
  Description, Switch, RootNetwork)
- Replace createBaseColumns factory with a static BASE_COLUMNS constant
- Build the columns array directly in the editor and pass it as a `columns`
  prop instead of a createAllColumns callback
- Augment react-table TableMeta/ColumnMeta to type the meta channel
- Drop the optimistic global update from SwitchCell; the row state is
  refreshed by the server notification, and a local useState handles the
  immediate checkbox feedback with rollback on error
- Replace useState/useEffect in useIsAnyNodeBuilding with a direct selector
- Remove the now-broken inline debounce around handleCellClick

Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>
Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>
- Clarify the importance of stable references for cell/header renderers.
- Update explanatory comments about renderers' scope and usage in react-table.

Signed-off-by: Florent MILLOT <florent.millot_externe@rte-france.com>
The per-row cells, the cell-renderers adapter, the two services
(setModificationMetadata, updateModificationStatusByRootNetwork) and the
@tanstack/react-table module augmentation that they relied on have moved
to commons-ui. Local files are deleted and createColumns now imports the
renderers from commons-ui. createRootNetworksColumns is simplified: it
only needs the root-networks list since the rest of the per-column meta
(rootNetwork, modificationsToExclude, isCurrentRootNetwork,
currentRootNetworkTag) is now derived from TableMeta. The node editor
passes studyUuid, currentNodeId, currentRootNetworkUuid, rootNetworks,
modificationsToExclude, setModificationsToExclude and a combined
isDisabled (isAnyNodeBuilding || mapDataLoading) to NetworkModificationsTable.

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
The per-row cells, the cell-renderers adapter, the two services
(setModificationMetadata, updateModificationStatusByRootNetwork) and the
@tanstack/react-table module augmentation that they relied on have moved
to commons-ui. Local files are deleted and createColumns now imports the
renderers from commons-ui. createRootNetworksColumns is simplified: it
only needs the root-networks list since the rest of the per-column meta
(rootNetwork, modificationsToExclude, isCurrentRootNetwork,
currentRootNetworkTag) is now derived from TableMeta. The node editor
passes studyUuid, currentNodeId, currentRootNetworkUuid, rootNetworks,
modificationsToExclude, setModificationsToExclude and a combined
isDisabled (isAnyNodeBuilding || mapDataLoading) to NetworkModificationsTable.

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR consolidates network modification table cell renderers into a shared commons-ui library, removing local inline editing capabilities and simplifying the column definition API. The changes affect column definitions, component integration, service exports, and type augmentations.

Changes

Network Modification Table Refactoring

Layer / File(s) Summary
Column definition refactoring and shared imports
src/components/graph/menus/network-modifications/network-modification-table/createColumns.tsx
Cell and header renderers are imported from @gridsuite/commons-ui. The factory function createBaseColumns(onEditNameCell) is replaced with static BASE_COLUMNS export. The createRootNetworksColumns function signature is simplified to accept only rootNetworks parameter, removing parameters for current root network and modification exclusion state.
Node editor component integration update
src/components/graph/menus/network-modifications/network-modification-node-editor.tsx
The component removes the setModificationMetadata import and local handleCellEdit callback. Column construction switches from calling createBaseColumns(handleCellEdit) to using BASE_COLUMNS constant. The createRootNetworksColumns invocation is updated to match the simplified signature. NetworkModificationsTable props are adjusted to pass modificationsToExclude, setModificationsToExclude, and a new isDisabled flag derived from loading states.
Service function and type cleanup
src/services/study/network-modifications.ts
The exported functions setModificationMetadata and updateModificationStatusByRootNetwork are removed. Imports are updated to drop ComposedModificationMetadata and getStudyUrlWithNodeUuidAndRootNetworkUuid, while adding creation DTO types from commons-ui.
Error handling translations
src/translations/en.json, src/translations/fr.json
New translation key networkModificationRenamingError is added with error messages for failed modification rename operations in both English and French.

Suggested Reviewers

  • Meklo
  • Mathieu-Deharbe
  • dbraquart
🚥 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 accurately describes the main change: moving network-modification-table renderers from this repository to the commons-ui package.
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.
Description check ✅ Passed The PR description clearly explains the refactoring to move network-modification renderers and related services to commons-ui, with specific details on affected files and API changes.

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

Base automatically changed from perf/network-modifications-table-rendering to main May 19, 2026 16:44
flomillot added 3 commits May 20, 2026 11:05
…ification-renderers

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
Composite name editing is now self-contained in commons-ui's NameCell,
so the updateModification/handleCellEdit handlers and the onEditNameCell
prop are no longer needed. Adds the networkModificationRenamingError
message displayed by the cell on failure.

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
createBaseColumns takes the name column's onChange callback; the node
editor supplies handleNameChange, which persists the rename via
setModificationMetadata.

Signed-off-by: Florent MILLOT <75525996+flomillot@users.noreply.github.com>
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.

1 participant