Skip to content

Commit d2fbab1

Browse files
fix(tables): source workspaceId for column selector from route context
1 parent 033d416 commit d2fbab1

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

  • apps/sim
    • app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks
    • hooks/selectors/providers/sim

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-selector-setup.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export function useSelectorSetup(
3131
const params = useParams()
3232
const activeWorkflowId = useWorkflowRegistry((s) => s.activeWorkflowId)
3333
const workflowId = (params?.workflowId as string) || activeWorkflowId || ''
34+
const workspaceId = (params?.workspaceId as string) || ''
3435

3536
const { data: envVariables = {} } = usePersonalEnvironment()
3637

@@ -63,6 +64,7 @@ export function useSelectorSetup(
6364
const selectorContext = useMemo<SelectorContext>(() => {
6465
const context: SelectorContext = {
6566
workflowId,
67+
workspaceId: workspaceId || undefined,
6668
mimeType: subBlock.mimeType,
6769
}
6870

@@ -87,6 +89,7 @@ export function useSelectorSetup(
8789
resolvedDependencyValues,
8890
canonicalIndex,
8991
workflowId,
92+
workspaceId,
9093
subBlock.mimeType,
9194
impersonateUserEmail,
9295
])

apps/sim/hooks/selectors/providers/sim/selectors.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import type {
1414
SelectorQueryArgs,
1515
} from '@/hooks/selectors/types'
1616
import type { WorkflowFolder } from '@/stores/folders/types'
17-
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
1817
import type { WorkflowMetadata } from '@/stores/workflows/registry/types'
1918

2019
/**
@@ -94,25 +93,24 @@ export const simSelectors = {
9493
getQueryKey: ({ context, search }: SelectorQueryArgs) => [
9594
...selectorKeys.all,
9695
'table.columns',
96+
context.workspaceId ?? 'none',
9797
context.tableId ?? 'none',
9898
search ?? '',
9999
],
100-
enabled: ({ context }) => Boolean(context.tableId),
100+
enabled: ({ context }) => Boolean(context.workspaceId && context.tableId),
101101
fetchList: async ({ context }: SelectorQueryArgs): Promise<SelectorOption[]> => {
102-
const workspaceId = useWorkflowRegistry.getState().hydration.workspaceId
103-
if (!workspaceId || !context.tableId) return []
102+
if (!context.workspaceId || !context.tableId) return []
104103
const table = await getQueryClient().ensureQueryData(
105-
getTableDetailQueryOptions(workspaceId, context.tableId)
104+
getTableDetailQueryOptions(context.workspaceId, context.tableId)
106105
)
107106
return (table.schema?.columns ?? [])
108107
.filter((col) => col.unique)
109108
.map((col) => ({ id: getColumnId(col), label: col.name }))
110109
},
111110
fetchById: async ({ context, detailId }: SelectorQueryArgs): Promise<SelectorOption | null> => {
112-
const workspaceId = useWorkflowRegistry.getState().hydration.workspaceId
113-
if (!detailId || !workspaceId || !context.tableId) return null
111+
if (!detailId || !context.workspaceId || !context.tableId) return null
114112
const table = await getQueryClient().ensureQueryData(
115-
getTableDetailQueryOptions(workspaceId, context.tableId)
113+
getTableDetailQueryOptions(context.workspaceId, context.tableId)
116114
)
117115
const col = (table.schema?.columns ?? []).find((c) => getColumnId(c) === detailId)
118116
return col ? { id: getColumnId(col), label: col.name } : null

0 commit comments

Comments
 (0)