feat(ui-tablemodes): use API instead of localStorage#3275
Conversation
88c3fa4 to
356f88f
Compare
There was a problem hiding this comment.
Pull request overview
This PR migrates the “table modes” feature from a localStorage-based implementation to a backend-backed API, updating the UI routing and forms to create/update/delete table modes through TanStack Query. It also adds a one-time client-side migration path from the old localStorage key to the new backend system, and adjusts study import on the backend to avoid cross-filesystem rename issues.
Changes:
- Introduce a new
/v1/tablemodeAPI client with Zod schemas/types and TanStack Query keys/queries/mutations. - Replace the old
/explore/tablemoderoute (localStorage templates) with/explore/table-modes(backend list + CRUD dialogs + optimistic updates), plus a localStorage migration workaround. - Rename and rewire “table mode data” calls/components (
TableMode→TableModeDataForm,getTableMode→getTableModeData, etc.) and update routes/translations accordingly.
Reviewed changes
Copilot reviewed 40 out of 40 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| webapp/src/utils/zodUtils.ts | Adds uniqueArray() helper used by new table mode schemas. |
| webapp/src/services/utils/localStorage.ts | Removes legacy table-mode-template key/type migration logic from storage utilities. |
| webapp/src/services/api/tablemode/types.ts | Adds DTO/domain/request param types for the new table mode API. |
| webapp/src/services/api/tablemode/schemas.ts | Adds Zod schemas for table modes (list/create/update) with transforms. |
| webapp/src/services/api/tablemode/index.ts | Adds API client functions for CRUD operations on table modes. |
| webapp/src/services/api/studies/tableMode/types.ts | Refactors table mode data API types to reuse new table mode type definitions. |
| webapp/src/services/api/studies/tableMode/index.ts | Renames functions to getTableModeData/setTableModeData and updates typing. |
| webapp/src/services/api/studies/outputs/schemas.ts | Removes outputsSchema in favor of inline z.array(outputSchema) usage. |
| webapp/src/services/api/studies/outputs/index.ts | Updates parsing to use z.array(outputSchema) directly. |
| webapp/src/routeTree.gen.ts | Regenerates routes for /explore/table-modes and removes old /tablemode paths. |
| webapp/src/routes/_authenticated/studies/index.tsx | Adjusts imports ordering and SplitView sizing for studies page. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/tablemode/route.tsx | Deletes the old localStorage-driven table mode list route. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/tablemode/$tableModeId/-components/TableTemplateFormDialog.tsx | Deletes localStorage template add/edit dialog. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/tablemode/-utils.ts | Deletes localStorage template types/utilities. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/table-modes/route.tsx | Adds new backend-driven table modes list route + localStorage migration hook. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/table-modes/index.ts | Adds index redirect to the first table mode. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/table-modes/$tableModeId/index.tsx | Switches detail view to backend table mode + CRUD actions with optimistic disabling. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/table-modes/$tableModeId/-hooks/useTableMode.ts | Adds hook to resolve a table mode from the cached list. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/table-modes/$tableModeId/-components/utils.ts | Consolidates table mode type/columns constants and select options for dialogs. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/table-modes/$tableModeId/-components/UpdateTableModeDialog.tsx | Adds update dialog wired to mutation hook. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/table-modes/$tableModeId/-components/BaseTableModeDialog.tsx | Adds shared form dialog used for create/update. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/table-modes/$tableModeId/-components/AddTableModeDialog.tsx | Adds create dialog wired to mutation hook. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/table-modes/-utils.ts | Adds mapping helper from table mode DTOs to RouterListView items. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/table-modes/-hooks/useUpdateTableMode.ts | Adds optimistic update mutation hook for table modes. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/table-modes/-hooks/useDeleteTableMode.ts | Adds optimistic delete mutation hook + navigation to next item. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/table-modes/-hooks/useCreateTableMode.ts | Adds optimistic create mutation hook + navigation from temp id to server id. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/route.tsx | Updates explore sidebar entry to /table-modes and new translation key. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/modeling/route.tsx | Normalizes modeling sidebar item id for binding constraints. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/modeling/binding-constraints/-hooks/useDeleteBindingConstraint.ts | Minor refactor of variable names and error handling order. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/configuration/geo-trimming/links.tsx | Switches to TableModeDataForm. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/configuration/geo-trimming/binding-constraints.tsx | Switches to TableModeDataForm. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/configuration/geo-trimming/areas.tsx | Switches to TableModeDataForm. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/configuration/eco-options.tsx | Switches to TableModeDataForm. |
| webapp/src/routes/_authenticated/studies/$studyId/explore/configuration/adequacy-patch/perimeter.tsx | Switches to TableModeDataForm. |
| webapp/src/queries/tableMode/queries.ts | Adds list query definition for table modes. |
| webapp/src/queries/tableMode/mutations.ts | Adds create/update/delete mutation option helpers. |
| webapp/src/queries/tableMode/keys.ts | Adds query/mutation keys for table modes. |
| webapp/src/components/TableModeDataForm.tsx | Renames/refactors component to use renamed API methods and updated types. |
| webapp/public/locales/fr/main.json | Updates translation keys/messages for table modes (plural + new errors). |
| webapp/public/locales/en/main.json | Updates translation keys/messages for table modes (plural + new errors). |
| antarest/study/storage/file_study_storage.py | Uses copytree(..., ignore=output) during import to avoid cross-filesystem rename issues. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
8c5aac3 to
756cd65
Compare
756cd65 to
8ccf34c
Compare
|
|
||
| setState({ | ||
| status: failed.length > 0 ? "error" : "success", | ||
| migrated: oldTableModes.length - failed.length, |
There was a problem hiding this comment.
migrated count includes skipped invalid entries
Entries that fail safeParse are continued, not migrated, but also not in failed. So this expression counts them as migrated. e.g : 10 entries, 2 invalid, 0 errors -> toast says "10 migrated" when only 8 actually were.
The state.migrated incremented in the loop is already the correct value. It's intentional, or should you use that instead of re-deriving from length - failed?
| <List dense sx={{ overflow: "auto" }}> | ||
| {state.failed.map(([tableModeCreation, error]) => ( | ||
| <ListItem | ||
| key={tableModeCreation.name} |
6a7d8e4 to
7e36bc2
Compare
also create table modes inside localStorage with the API
ANT-4966