Skip to content

Commit d998f66

Browse files
committed
refactor(tables): move the shared dependencies out of the route tree
Step 1 of migrating tables onto the resource axes: pure relocations, no logic. A canonical unit may not import `@/app/**`, so everything the table shell reaches for has to either move somewhere both sides can see it, or be replaced later. - `Resource`/`BreadcrumbItem`/`ColumnOption`/`SortConfig` now come from `@/components/resource` directly. The workspace barrel was only re-exporting them, so this is the same module by a shorter path. - `useLogDetailsResize` moves to `@/hooks/`. Its only dependency is the logs UI store, which is already global, and it has consumers in two route trees. - `ImportCsvDialog` and `ImportProgressMenu` move to `components/table-import/`. Both are mounted by the tables *list* page as well as the detail shell, so they cannot live inside the unit — same reasoning as `Resource` and `AnchoredContextMenu` before them. Cross-route edges out of `tables/[tableId]` drop from 7 targets to 4. The two remaining `@/app/workspace/[workspaceId]/components` imports are in `error.tsx` and `loading.tsx`, which stay behind as route files.
1 parent 17de4bb commit d998f66

14 files changed

Lines changed: 22 additions & 18 deletions

File tree

apps/sim/app/workspace/[workspaceId]/logs/components/log-details/log-details.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import { useQueryState } from 'nuqs'
88
import type { LogViewTab } from '@/components/resources/log-view'
99
import { LogView } from '@/components/resources/log-view'
1010
import type { WorkflowLogRow } from '@/lib/api/contracts/logs'
11-
import { useLogDetailsResize } from '@/app/workspace/[workspaceId]/logs/hooks'
1211
import {
1312
logDetailsTabParam,
1413
logDetailsTabUrlKeys,
1514
} from '@/app/workspace/[workspaceId]/logs/search-params'
1615
import { useUserPermissionsContext } from '@/app/workspace/[workspaceId]/providers/workspace-permissions-provider'
16+
import { useLogDetailsResize } from '@/hooks/use-log-details-resize'
1717
import { usePermissionConfig } from '@/hooks/use-permission-config'
1818
import { grantsFromPermissions, workspaceSource } from '@/resources'
1919
import { useLogDetailsUIStore } from '@/stores/logs/store'

apps/sim/app/workspace/[workspaceId]/logs/hooks/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/enrichment-details/enrichment-details.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import {
1010
iconColorClass,
1111
} from '@/components/resources/log-view'
1212
import type { EnrichmentProviderOutcome, EnrichmentRunDetail } from '@/lib/table'
13-
import { useLogDetailsResize } from '@/app/workspace/[workspaceId]/logs/hooks'
1413
import { useEnrichmentDetail } from '@/hooks/queries/tables'
14+
import { useLogDetailsResize } from '@/hooks/use-log-details-resize'
1515
import { formatCost } from '@/providers/utils'
1616
import { useLogDetailsUIStore } from '@/stores/logs/store'
1717
import { MAX_LOG_DETAILS_WIDTH_RATIO, MIN_LOG_DETAILS_WIDTH } from '@/stores/logs/utils'

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/table.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@ import { useRouter } from 'next/navigation'
99
import { useQueryStates } from 'nuqs'
1010
import { usePostHog } from 'posthog-js/react'
1111
import { PresenceAvatars } from '@/components/presence'
12+
import {
13+
type BreadcrumbItem,
14+
type ColumnOption,
15+
Resource,
16+
type SortConfig,
17+
} from '@/components/resource'
1218
import {
1319
COLUMN_SIDEBAR_WIDTH,
1420
columnTypeIcon,
1521
generateColumnName,
1622
} from '@/components/resources/table-view'
23+
import { ImportCsvDialog, ImportProgressMenu } from '@/components/table-import'
1724
import type { RunLimit, RunMode, TableViewWire } from '@/lib/api/contracts/tables'
1825
import { captureEvent } from '@/lib/posthog/client'
1926
import type {
@@ -28,16 +35,8 @@ import type {
2835
} from '@/lib/table'
2936
import { getColumnId } from '@/lib/table/column-keys'
3037
import { TABLE_LIMITS } from '@/lib/table/constants'
31-
import {
32-
type BreadcrumbItem,
33-
type ColumnOption,
34-
Resource,
35-
type SortConfig,
36-
} from '@/app/workspace/[workspaceId]/components'
3738
import { LogDetails } from '@/app/workspace/[workspaceId]/logs/components'
3839
import { useUserPermissionsContext } from '@/app/workspace/[workspaceId]/providers/workspace-permissions-provider'
39-
import { ImportCsvDialog } from '@/app/workspace/[workspaceId]/tables/components/import-csv-dialog'
40-
import { ImportProgressMenu } from '@/app/workspace/[workspaceId]/tables/components/import-progress-menu'
4140
import { useLogByExecutionId } from '@/hooks/queries/logs'
4241
import {
4342
downloadTableExport,
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
export * from './import-csv-dialog'
2-
export * from './import-progress-menu'
31
export * from './table-context-menu'
42
export * from './tables-list-context-menu'

apps/sim/app/workspace/[workspaceId]/tables/tables.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { getErrorMessage } from '@sim/utils/errors'
99
import { generateId } from '@sim/utils/id'
1010
import { useParams, useRouter } from 'next/navigation'
1111
import { useQueryStates } from 'nuqs'
12+
import { ImportCsvDialog, ImportProgressMenu } from '@/components/table-import'
1213
import type { TableDefinition } from '@/lib/table'
1314
import { CSV_ASYNC_IMPORT_THRESHOLD_BYTES, generateUniqueTableName } from '@/lib/table/constants'
1415
import { SEARCH_DEBOUNCE_MS } from '@/lib/url-state'
@@ -48,11 +49,7 @@ import {
4849
useFolderRowDragDrop,
4950
} from '@/app/workspace/[workspaceId]/components/folders'
5051
import { useUserPermissionsContext } from '@/app/workspace/[workspaceId]/providers/workspace-permissions-provider'
51-
import {
52-
ImportCsvDialog,
53-
ImportProgressMenu,
54-
TablesListContextMenu,
55-
} from '@/app/workspace/[workspaceId]/tables/components'
52+
import { TablesListContextMenu } from '@/app/workspace/[workspaceId]/tables/components'
5653
import { TableContextMenu } from '@/app/workspace/[workspaceId]/tables/components/table-context-menu'
5754
import { useWorkspaceTablesRoom } from '@/app/workspace/[workspaceId]/tables/hooks/use-workspace-tables-room'
5855
import {

apps/sim/app/workspace/[workspaceId]/tables/components/import-csv-dialog/import-csv-dialog.tsx renamed to apps/sim/components/table-import/import-csv-dialog/import-csv-dialog.tsx

File renamed without changes.

apps/sim/app/workspace/[workspaceId]/tables/components/import-csv-dialog/index.ts renamed to apps/sim/components/table-import/import-csv-dialog/index.ts

File renamed without changes.

apps/sim/app/workspace/[workspaceId]/tables/components/import-progress-menu/import-progress-menu.tsx renamed to apps/sim/components/table-import/import-progress-menu/import-progress-menu.tsx

File renamed without changes.

apps/sim/app/workspace/[workspaceId]/tables/components/import-progress-menu/import-stage.ts renamed to apps/sim/components/table-import/import-progress-menu/import-stage.ts

File renamed without changes.

0 commit comments

Comments
 (0)