Skip to content

Migrate storage mappings table to GraphQL - #2031

Open
GregorShear wants to merge 2 commits into
mainfrom
worktree-claude+storage-mappings-gql
Open

Migrate storage mappings table to GraphQL#2031
GregorShear wants to merge 2 commits into
mainfrom
worktree-claude+storage-mappings-gql

Conversation

@GregorShear

Copy link
Copy Markdown
Contributor

Summary

Migrates the Storage Mappings settings table from PostgREST to a cursor-paginated GraphQL query, and drops react-intl from the touched components.

  • Fetch via usePaginatedStorageMappings (forward cursor pagination); remove the getStorageMappings PostgREST helper and the EntityTable / TableHydrator / selectable-table Zustand plumbing it required.
  • Render a plain MUI Table + TablePagination driven by useCursorPagination — no search or column sorting (the query supports neither); the "Last Updated" column is gone since the query doesn't expose it.
  • Invalidate the storageMappings query in the URQL cache on create/update, replacing the manual refresh mechanism.
  • Inline the component strings and delete the now-dead react-intl keys.

Replace the PostgREST-backed storage mappings settings table with a
cursor-paginated GraphQL query (usePaginatedStorageMappings).

- Drop the getStorageMappings PostgREST helper and the EntityTable /
  TableHydrator / selectable-table Zustand plumbing it required.
- Render a plain MUI Table with TablePagination driven by
  useCursorPagination; forward pagination only, no search or column
  sorting (the storageMappings query supports neither).
- Retype rows to StorageMappingTableRow (catalogPrefix / spec) and remove
  the "Last Updated" column, which the query does not expose.
- Invalidate the storageMappings query in the URQL cache on
  createStorageMapping / updateStorageMapping, replacing the manual
  useStorageMappingsRefresh mechanism.
- Add the storageMappingsTable.error.loadFailed message.
@GregorShear
GregorShear requested a review from a team as a code owner July 17, 2026 20:36
@github-actions

Copy link
Copy Markdown

⚪ Code Health

No change to the dead-code surface.

48 Unused files

File imported nowhere — delete (or import) it.

     src/hooks/useDelay.ts
     src/hooks/useDraft.ts
     src/pages/NoGrants.tsx
     src/pages/OAuth.tsx
     src/services/encryption.ts
     src/types/global.ts
     src/types/vitest.ts
     src/components/graphs/TaskHoursByMonthGraph.tsx
     src/components/tables/Link.tsx
     src/context/LoopIndex/index.tsx
…and 38 more

64 Unused exports

Exported symbol with no references outside its own file — un-export it, or delete it if unused entirely

     src/context/Theme.tsx : logoColors
     src/context/Theme.tsx : intensifiedOutlineThick
     src/context/Theme.tsx : tableAlternateRowsSx
     src/context/Theme.tsx : draggableChipIconSx
     src/context/Theme.tsx : hiddenButAccessibleInput
     src/context/Theme.tsx : primaryColoredBackground_hovered
     src/context/Theme.tsx : detailsPanelBgColor
     src/context/Theme.tsx : menuBackgroundColor
     src/context/Theme.tsx : flexGrowToSiblingsSx
     src/context/Theme.tsx : shardTableRow
…and 54 more

26 Unused exported types

Exported type with no references outside its own file — un-export it, or delete it if unused entirely

     src/utils/billing-utils.ts : FREE_GB_BY_TIER
     src/types/index.ts : InferredSchemas
     src/types/index.ts : Shard
     src/components/shared/WizardDialog/index.ts : WizardStep
     src/api/dataPlanes.ts : AwsDnsEntry
     src/stores/ShardDetail/types.ts : TaskShardDetailsWithShard
     src/stores/ShardDetail/types.ts : ShardDetails
     src/components/tables/Logs/types.ts : RefreshLogsFunction
     src/types/schemaModels.ts : CollectionSchema
     src/components/editor/Bindings/types.ts : SelectedCollectionChangeData
…and 16 more

14 Unused exported enum members

An enum member referenced nowhere

     src/services/supabase.ts : CONNECTOR_TAGS
     src/services/supabase.ts : DRAFTS_EXT
     src/services/supabase.ts : TASKS_BY_DAY
     src/stores/Tables/hooks.ts : accessGrants
     src/stores/Tables/hooks.ts : accessLinks
     src/stores/Tables/hooks.ts : billing
     src/stores/Tables/hooks.ts : connectors
     src/stores/Tables/hooks.ts : entitySelector
     src/stores/Tables/hooks.ts : prefixes
     src/stores/Tables/hooks.ts : prefixAlerts
…and 4 more

5 Unused dependencies

In package.json but never imported

     package.json : @mui/lab
     package.json : @testing-library/jest-dom
     package.json : @urql/exchange-retry
     package.json : logrocket-react
     package.json : stripe

3 Unused devDependencies

In package.json devDependencies but never used

     package.json : @types/logrocket-react
     package.json : @types/react-inspector
     package.json : sharp

@GregorShear GregorShear self-assigned this Jul 20, 2026

const selectedTenant = useTenantStore((state) => state.selectedTenant);
const { storageMappings, fetching, error, pageInfo, pageSize } =
usePaginatedStorageMappings(cursor);

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.

The pagination state isn't tied to the selected tenant. Settings keeps this table mounted when TenantSelector changes selectedTenant, so if I'm on page 2+ for tenant A and select tenant B, this sends A's after cursor with B's underPrefix. Best case we skip B's first page; worst case the query errors or returns zero edges. The latter strands the table because the footer below is gated on storageMappings.length > 0, so there isn't even a Previous button to recover.

Can we reset to page 0 when the tenant changes (or key/remount the paginated table by tenant)? I'd also mirror the Access Links / Refresh Tokens empty-page recovery using goToPage(currentPage - 1) after a completed zero-row fetch.

columnToSort,
setColumnToSort,
} = useTableState('sm', 'catalog_prefix');
const { currentPage, cursor, onPageChange } = useCursorPagination();

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.

useCursorPagination has a history bug that this makes reachable: after moving backwards, forward navigation always appends instead of truncating/replacing the abandoned tail. Reproduced sequence: 1 → 2 → 3 → 2 → 3 → 4 → 5 → 4; the final "page 4" uses the page-3 cursor. It needs enough rows and some backtracking, so low likelihood, but the label and data diverge once it happens.

Worth fixing the shared hook's forward branch to trim history to the target page before adding nextCursor, and pinning it with this sequence.

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