Skip to content

Commit 10d661a

Browse files
committed
refactor(tables): move the grid's view layer to components/resources/table-view
Behaviour-neutral relocation. 18 files move with ~100% rename similarity; every other changed line in the diff is an import specifier, verified mechanically — filtering import lines out of the `table-grid.tsx` hunk leaves nothing. What moved is what draws a table: the row, the cells (render + content + resource chip), the headers, the column/selection primitives, find, the remote selection overlay, the select pill, and the pure value/grid helpers. What stayed is what writes one: `TableGrid` itself, the inline editor, the expanded-cell popover, and every mutation surface around them. Two types crossed with it — `SaveReason` and `EditingCell` describe the view's editing *protocol*, not the route's query state, so they now live in the unit while `QueryOptions` and `ContextMenuState` stay behind. The 4,420-line grid deliberately does NOT move. It reads `useParams()`, `useUserPermissionsContext()` and ten mutation hooks; it is the shell, and splitting it is not a prerequisite for giving the view layer an address. Worth recording for the next person: `apps/sim/tsconfig.json` excludes test files, so `tsc` stayed green while two moved tests still imported their subjects through dead absolute paths. Only vitest caught it. A green typecheck proves nothing about tests after a move.
1 parent 634eef7 commit 10d661a

33 files changed

Lines changed: 183 additions & 81 deletions

apps/sim/app/workspace/[workspaceId]/interfaces/[interfaceId]/components/module-inspector/components/resource-picker-field/resource-picker-field.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ChipCombobox, type ComboboxOption } from '@sim/emcn'
55
import {
66
MODULE_RESOURCE_COPY,
77
type ModuleResourceKind,
8-
} from '@/components/resources/interface-view/module-resource-copy'
8+
} from '@/components/resources/interface-view'
99
import { InspectorField } from '@/app/workspace/[workspaceId]/interfaces/[interfaceId]/components/inspector-field'
1010

1111
/** The minimal shape a pickable workspace resource exposes. */

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/row-modal/row-modal.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ import {
1717
import { createLogger } from '@sim/logger'
1818
import { getErrorMessage } from '@sim/utils/errors'
1919
import { useParams } from 'next/navigation'
20-
import type { ColumnDefinition, TableInfo, TableRow } from '@/lib/table'
21-
import { columnTypeOf } from '@/lib/table/column-types'
22-
import { resolveCurrencyCode } from '@/lib/table/currency'
23-
import { useTimezone } from '@/hooks/queries/general-settings'
24-
import { useDeleteTableRow, useDeleteTableRows, useUpdateTableRow } from '@/hooks/queries/tables'
2520
import {
2621
cleanCellValue,
2722
dateValueToLocalParts,
2823
formatValueForInput,
2924
localPartsToDateValue,
3025
todayLocalCalendarDate,
31-
} from '../../utils'
26+
} from '@/components/resources/table-view'
27+
import type { ColumnDefinition, TableInfo, TableRow } from '@/lib/table'
28+
import { columnTypeOf } from '@/lib/table/column-types'
29+
import { resolveCurrencyCode } from '@/lib/table/currency'
30+
import { useTimezone } from '@/hooks/queries/general-settings'
31+
import { useDeleteTableRow, useDeleteTableRows, useUpdateTableRow } from '@/hooks/queries/tables'
3232
import { SelectValueEditor } from '../select-field'
3333

3434
const logger = createLogger('RowModal')
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
export { SelectOptionsEditor } from './select-options-editor'
2-
export { resolveSelectOptions, SelectPill, selectedOptionIds, toSelectedIds } from './select-pill'
32
export { SelectValueEditor } from './select-value-editor'

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/select-field/select-value-editor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import { useMemo } from 'react'
44
import { ChipDropdown } from '@sim/emcn'
5+
import { SelectPill, selectedOptionIds } from '@/components/resources/table-view'
56
import type { ColumnDefinition } from '@/lib/table'
6-
import { SelectPill, selectedOptionIds } from './select-pill'
77

88
interface SelectValueEditorProps {
99
column: ColumnDefinition

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/cells/expanded-cell-popover.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@
33
import type React from 'react'
44
import { useEffect, useEffectEvent, useLayoutEffect, useMemo, useRef, useState } from 'react'
55
import { Button } from '@sim/emcn'
6-
import type { TableRow as TableRowType } from '@/lib/table'
7-
import { columnTypeOf } from '@/lib/table/column-types'
8-
import { useTimezone } from '@/hooks/queries/general-settings'
9-
import type { EditingCell, SaveReason } from '../../../types'
6+
import type { DisplayColumn, EditingCell, SaveReason } from '@/components/resources/table-view'
107
import {
118
cleanCellValue,
129
displayToStorage,
1310
formatValueForInput,
1411
storageToDisplay,
15-
} from '../../../utils'
16-
import type { DisplayColumn } from '../types'
12+
} from '@/components/resources/table-view'
13+
import type { TableRow as TableRowType } from '@/lib/table'
14+
import { columnTypeOf } from '@/lib/table/column-types'
15+
import { useTimezone } from '@/hooks/queries/general-settings'
1716

1817
interface ExpandedCellPopoverProps {
1918
expandedCell: EditingCell | null
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
export { CellContent } from './cell-content'
2-
export { CellRender, type CellRenderKind, resolveCellRender } from './cell-render'
31
export { ExpandedCellPopover } from './expanded-cell-popover'
42
export { InlineEditor } from './inline-editors'

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/cells/inline-editors.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,21 @@ import {
1414
toast,
1515
} from '@sim/emcn'
1616
import { Check } from '@sim/emcn/icons'
17-
import type { ColumnDefinition } from '@/lib/table'
18-
import { columnTypeOf } from '@/lib/table/column-types'
19-
import { isCalendarDateString } from '@/lib/table/dates'
20-
import { useTimezone } from '@/hooks/queries/general-settings'
21-
import type { SaveReason } from '../../../types'
17+
import type { SaveReason } from '@/components/resources/table-view'
2218
import {
2319
cleanCellValue,
2420
dateValueToLocalParts,
2521
displayToStorage,
2622
formatValueForInput,
23+
SelectPill,
24+
selectedOptionIds,
2725
storageToDisplay,
2826
todayLocalCalendarDate,
29-
} from '../../../utils'
30-
import { SelectPill, selectedOptionIds } from '../../select-field'
27+
} from '@/components/resources/table-view'
28+
import type { ColumnDefinition } from '@/lib/table'
29+
import { columnTypeOf } from '@/lib/table/column-types'
30+
import { isCalendarDateString } from '@/lib/table/dates'
31+
import { useTimezone } from '@/hooks/queries/general-settings'
3132

3233
interface InlineEditorProps {
3334
value: unknown

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

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,41 @@ import { getErrorMessage } from '@sim/utils/errors'
1010
import { useVirtualizer } from '@tanstack/react-virtual'
1111
import { useParams } from 'next/navigation'
1212
import { usePostHog } from 'posthog-js/react'
13+
import type { EditingCell, SaveReason } from '@/components/resources/table-view'
14+
import {
15+
ADD_COL_WIDTH,
16+
AddRowButton,
17+
buildHeaderGroups,
18+
type CellCoord,
19+
COL_WIDTH,
20+
ColumnHeaderMenu,
21+
checkboxColLayout,
22+
classifyExecStatusMix,
23+
cleanCellValue,
24+
collectRowSnapshots,
25+
computeNormalizedSelection,
26+
DataRow,
27+
type DisplayColumn,
28+
type ExecStatusMix,
29+
expandToDisplayColumns,
30+
isCellInSelection,
31+
moveCell,
32+
RemoteSelectionOverlay,
33+
type RemoteTableSelection,
34+
ROW_SELECTION_ALL,
35+
ROW_SELECTION_NONE,
36+
type RowSelection,
37+
rowSelectionCoversAll,
38+
rowSelectionIncludes,
39+
rowSelectionIsEmpty,
40+
rowSelectionMaterialize,
41+
SELECTION_TINT_BG,
42+
SelectAllCheckbox,
43+
generateColumnName as sharedGenerateColumnName,
44+
TableColGroup,
45+
TableFind,
46+
WorkflowGroupMetaCell,
47+
} from '@/components/resources/table-view'
1348
import type { RunLimit, RunMode, TableFindMatch } from '@/lib/api/contracts/tables'
1449
import { captureEvent } from '@/lib/posthog/client'
1550
import type {
@@ -44,39 +79,12 @@ import { useInlineRename } from '@/hooks/use-inline-rename'
4479
import { extractCreatedRowId, useTableUndo } from '@/hooks/use-table-undo'
4580
import type { DeletedRowSnapshot } from '@/stores/table/types'
4681
import { useContextMenu, useTable } from '../../hooks'
47-
import type { EditingCell, QueryOptions, SaveReason } from '../../types'
48-
import { cleanCellValue, generateColumnName as sharedGenerateColumnName } from '../../utils'
82+
import type { QueryOptions } from '../../types'
4983
import type { ColumnConfig } from '../column-config-sidebar'
5084
import { ContextMenu } from '../context-menu'
5185
import { NewColumnDropdown } from '../new-column-dropdown'
5286
import type { WorkflowConfig } from '../workflow-sidebar'
5387
import { ExpandedCellPopover, InlineEditor } from './cells'
54-
import { ADD_COL_WIDTH, COL_WIDTH, SELECTION_TINT_BG } from './constants'
55-
import { DataRow } from './data-row'
56-
import { ColumnHeaderMenu, WorkflowGroupMetaCell } from './headers'
57-
import { RemoteSelectionOverlay } from './remote-selection-overlay'
58-
import { TableFind } from './table-find'
59-
import { AddRowButton, SelectAllCheckbox, TableColGroup } from './table-primitives'
60-
import type { DisplayColumn, RemoteTableSelection } from './types'
61-
import {
62-
buildHeaderGroups,
63-
type CellCoord,
64-
checkboxColLayout,
65-
classifyExecStatusMix,
66-
collectRowSnapshots,
67-
computeNormalizedSelection,
68-
type ExecStatusMix,
69-
expandToDisplayColumns,
70-
isCellInSelection,
71-
moveCell,
72-
ROW_SELECTION_ALL,
73-
ROW_SELECTION_NONE,
74-
type RowSelection,
75-
rowSelectionCoversAll,
76-
rowSelectionIncludes,
77-
rowSelectionIsEmpty,
78-
rowSelectionMaterialize,
79-
} from './utils'
8088

8189
const logger = createLogger('TableView')
8290

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/hooks/use-table-room.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const JOIN_RETRY_BASE_MS = 1000
2424
const SELECTION_EMIT_THROTTLE_MS = 50
2525

2626
/** The `table:presence-update` broadcast name, derived from the room type. */
27-
import type { RemoteTableSelection } from '@/app/workspace/[workspaceId]/tables/[tableId]/components/table-grid/types'
27+
import type { RemoteTableSelection } from '@/components/resources/table-view'
2828

2929
const TABLE_PRESENCE_UPDATE_EVENT = presenceEventName(ROOM_TYPES.TABLE)
3030

apps/sim/app/workspace/[workspaceId]/tables/[tableId]/hooks/use-table.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { useCallback, useMemo } from 'react'
44
import { useQueryClient } from '@tanstack/react-query'
5+
import type { BlockIconInfo, ColumnSourceInfo } from '@/components/resources/table-view'
56
import type {
67
ColumnDefinition,
78
TableDefinition,
@@ -22,7 +23,6 @@ import { countLoadedTableRows, hasMoreTableRows } from '@/hooks/queries/utils/ta
2223
import { useWorkflowStates, useWorkflows } from '@/hooks/queries/workflows'
2324
import type { WorkflowMetadata } from '@/stores/workflows/registry/types'
2425
import type { WorkflowState } from '@/stores/workflows/workflow/types'
25-
import type { BlockIconInfo, ColumnSourceInfo } from '../components/table-grid/types'
2626
import type { QueryOptions } from '../types'
2727

2828
const EMPTY_COLUMNS: ColumnDefinition[] = []

0 commit comments

Comments
 (0)