Skip to content

feat(ui-tablemodes): use API instead of localStorage#3275

Merged
skamril merged 11 commits into
devfrom
feature/4966-table-mode
Jun 29, 2026
Merged

feat(ui-tablemodes): use API instead of localStorage#3275
skamril merged 11 commits into
devfrom
feature/4966-table-mode

Conversation

@skamril

@skamril skamril commented Jun 23, 2026

Copy link
Copy Markdown
Member

also create table modes inside localStorage with the API

ANT-4966

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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/tablemode API client with Zod schemas/types and TanStack Query keys/queries/mutations.
  • Replace the old /explore/tablemode route (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 (TableModeTableModeDataForm, getTableModegetTableModeData, 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.

Comment thread webapp/src/utils/zodUtils.ts Outdated
Comment thread webapp/src/services/api/tablemode/schemas.ts
Comment thread webapp/src/routes/_authenticated/studies/$studyId/explore/table-modes/route.tsx Outdated
@skamril skamril changed the title feat(ui-tablemodes): use API instead of localSTorage feat(ui-tablemodes): use API instead of localStorage Jun 23, 2026
Comment thread webapp/src/routes/_authenticated/studies/$studyId/explore/table-modes/-utils.ts Outdated
Comment thread webapp/public/locales/fr/main.json Outdated
Comment thread webapp/src/routes/_authenticated/studies/$studyId/explore/table-modes/route.tsx Outdated
Comment thread webapp/src/services/api/tablemode/schemas.ts
Comment thread webapp/src/utils/zodUtils.ts Outdated
@skamril skamril force-pushed the feature/4966-table-mode branch from 8c5aac3 to 756cd65 Compare June 25, 2026 13:47
hdinia
hdinia previously approved these changes Jun 26, 2026

setState({
status: failed.length > 0 ? "error" : "success",
migrated: oldTableModes.length - failed.length,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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}

@hdinia hdinia Jun 29, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

no key collision risk ?

hdinia
hdinia previously approved these changes Jun 29, 2026
@skamril skamril force-pushed the feature/4966-table-mode branch from 6a7d8e4 to 7e36bc2 Compare June 29, 2026 16:01
@skamril skamril requested a review from hdinia June 29, 2026 16:03
@skamril skamril merged commit a04c6d5 into dev Jun 29, 2026
14 of 15 checks passed
@skamril skamril deleted the feature/4966-table-mode branch June 29, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants