Skip to content

Commit 0a8dd68

Browse files
committed
refactor(input-mapping): resolve workflowId via useDependsOnGate canonical pattern
1 parent 48d4abb commit 0a8dd68

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

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

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/input-mapping/input-mapping.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import { handleKeyboardActivation } from '@/lib/core/utils/keyboard'
66
import { extractInputFieldsFromBlocks } from '@/lib/workflows/input-format'
77
import { formatDisplayText } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/formatted-text'
88
import { TagDropdown } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown'
9-
import { useCanonicalSubBlockValue } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-canonical-sub-block-value'
9+
import { useDependsOnGate } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-depends-on-gate'
1010
import { useSubBlockInput } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-sub-block-input'
1111
import { useSubBlockValue } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-sub-block-value'
12-
import { resolvePreviewContextValue } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/utils'
1312
import { useAccessibleReferencePrefixes } from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-accessible-reference-prefixes'
13+
import type { SubBlockConfig } from '@/blocks/types'
1414
import { useWorkflowState } from '@/hooks/queries/workflows'
1515

1616
/**
@@ -36,7 +36,7 @@ interface InputMappingFieldProps {
3636
*/
3737
interface InputMappingProps {
3838
blockId: string
39-
subBlockId: string
39+
subBlock: SubBlockConfig
4040
isPreview?: boolean
4141
previewValue?: Record<string, unknown>
4242
disabled?: boolean
@@ -51,18 +51,20 @@ interface InputMappingProps {
5151
*/
5252
export function InputMapping({
5353
blockId,
54-
subBlockId,
54+
subBlock,
5555
isPreview = false,
5656
previewValue,
5757
disabled = false,
5858
previewContextValues,
5959
}: InputMappingProps) {
60+
const subBlockId = subBlock.id
6061
const [mapping, setMapping] = useSubBlockValue(blockId, subBlockId)
61-
const storeWorkflowId = useCanonicalSubBlockValue<string>(blockId, 'workflowId')
62-
const selectedWorkflowId = previewContextValues
63-
? (resolvePreviewContextValue(previewContextValues.workflowId) ??
64-
resolvePreviewContextValue(previewContextValues.manualWorkflowId))
65-
: storeWorkflowId
62+
const { dependencyValues } = useDependsOnGate(blockId, subBlock, {
63+
disabled,
64+
isPreview,
65+
previewContextValues,
66+
})
67+
const selectedWorkflowId = dependencyValues.workflowId
6668

6769
const inputController = useSubBlockInput({
6870
blockId,

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/sub-block.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ function SubBlockComponent({
10401040
return (
10411041
<InputMapping
10421042
blockId={blockId}
1043-
subBlockId={config.id}
1043+
subBlock={config}
10441044
isPreview={isPreview}
10451045
previewValue={previewValue as any}
10461046
disabled={isDisabled}

0 commit comments

Comments
 (0)