Skip to content

Commit ec936be

Browse files
authored
improvement(workflow-block): support manual workflow ID via advanced mode (#4573)
* improvement(workflow-block): support manual workflow ID via advanced mode * fix(input-mapping): resolve workflowId via canonical hook for advanced mode * fix(input-mapping): fall back to manualWorkflowId in preview context * refactor(input-mapping): resolve workflowId via useDependsOnGate canonical pattern
1 parent 43f53bb commit ec936be

9 files changed

Lines changed: 40 additions & 13 deletions

File tree

apps/sim/app/chat/components/message/components/markdown-renderer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const COMPONENTS = {
115115
),
116116

117117
blockquote: ({ children }: React.HTMLAttributes<HTMLQuoteElement>) => (
118-
<blockquote className='my-4 break-words border-[var(--divider)] border-l-2 pl-4 font-sans text-[var(--text-primary)] italic [&>p]:my-2 [&>p:first-child]:mt-0 [&>p:last-child]:mb-0'>
118+
<blockquote className='my-4 break-words border-[var(--divider)] border-l-2 pl-4 font-sans text-[var(--text-primary)] italic [&>p:first-child]:mt-0 [&>p:last-child]:mb-0 [&>p]:my-2'>
119119
{children}
120120
</blockquote>
121121
),

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-panel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ function CalloutBlock({ type, children }: { type: string; children?: React.React
263263
const config = CALLOUT_CONFIG[type]
264264
if (!config) {
265265
return (
266-
<blockquote className='my-4 break-words border-[var(--divider)] border-l-2 pl-4 text-[var(--text-primary)] italic [&>p]:my-2 [&>p:first-child]:mt-0 [&>p:last-child]:mb-0'>
266+
<blockquote className='my-4 break-words border-[var(--divider)] border-l-2 pl-4 text-[var(--text-primary)] italic [&>p:first-child]:mt-0 [&>p:last-child]:mb-0 [&>p]:my-2'>
267267
{children}
268268
</blockquote>
269269
)
@@ -605,7 +605,7 @@ const STATIC_MARKDOWN_COMPONENTS = {
605605
return <CalloutBlock type={calloutType}>{children}</CalloutBlock>
606606
}
607607
return (
608-
<blockquote className='my-4 break-words border-[var(--divider)] border-l-2 pl-4 text-[var(--text-primary)] italic [&>p]:my-2 [&>p:first-child]:mt-0 [&>p:last-child]:mb-0'>
608+
<blockquote className='my-4 break-words border-[var(--divider)] border-l-2 pl-4 text-[var(--text-primary)] italic [&>p:first-child]:mt-0 [&>p:last-child]:mb-0 [&>p]:my-2'>
609609
{children}
610610
</blockquote>
611611
)

apps/sim/app/workspace/[workspaceId]/home/components/message-content/components/chat-content/chat-content.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ const MARKDOWN_COMPONENTS = {
224224
},
225225
blockquote({ children }: { children?: React.ReactNode }) {
226226
return (
227-
<blockquote className='my-4 break-words border-[var(--divider)] border-l-2 pl-4 text-[var(--text-primary)] italic [&>p]:my-2 [&>p:first-child]:mt-0 [&>p:last-child]:mb-0'>
227+
<blockquote className='my-4 break-words border-[var(--divider)] border-l-2 pl-4 text-[var(--text-primary)] italic [&>p:first-child]:mt-0 [&>p:last-child]:mb-0 [&>p]:my-2'>
228228
{children}
229229
</blockquote>
230230
)

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/note-block/note-block.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ const NOTE_COMPONENTS = {
430430
<em className='break-words text-[var(--text-tertiary)]'>{children}</em>
431431
),
432432
blockquote: ({ children }: { children?: React.ReactNode }) => (
433-
<blockquote className='my-4 break-words border-[var(--divider)] border-l-2 pl-4 text-[var(--text-primary)] italic [&>p]:my-2 [&>p:first-child]:mt-0 [&>p:last-child]:mb-0'>
433+
<blockquote className='my-4 break-words border-[var(--divider)] border-l-2 pl-4 text-[var(--text-primary)] italic [&>p:first-child]:mt-0 [&>p:last-child]:mb-0 [&>p]:my-2'>
434434
{children}
435435
</blockquote>
436436
),

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +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 { useDependsOnGate } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-depends-on-gate'
910
import { useSubBlockInput } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-sub-block-input'
1011
import { useSubBlockValue } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-sub-block-value'
11-
import { resolvePreviewContextValue } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/utils'
1212
import { useAccessibleReferencePrefixes } from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-accessible-reference-prefixes'
13+
import type { SubBlockConfig } from '@/blocks/types'
1314
import { useWorkflowState } from '@/hooks/queries/workflows'
1415

1516
/**
@@ -35,7 +36,7 @@ interface InputMappingFieldProps {
3536
*/
3637
interface InputMappingProps {
3738
blockId: string
38-
subBlockId: string
39+
subBlock: SubBlockConfig
3940
isPreview?: boolean
4041
previewValue?: Record<string, unknown>
4142
disabled?: boolean
@@ -50,17 +51,20 @@ interface InputMappingProps {
5051
*/
5152
export function InputMapping({
5253
blockId,
53-
subBlockId,
54+
subBlock,
5455
isPreview = false,
5556
previewValue,
5657
disabled = false,
5758
previewContextValues,
5859
}: InputMappingProps) {
60+
const subBlockId = subBlock.id
5961
const [mapping, setMapping] = useSubBlockValue(blockId, subBlockId)
60-
const [storeWorkflowId] = useSubBlockValue(blockId, 'workflowId')
61-
const selectedWorkflowId = previewContextValues
62-
? resolvePreviewContextValue(previewContextValues.workflowId)
63-
: storeWorkflowId
62+
const { dependencyValues } = useDependsOnGate(blockId, subBlock, {
63+
disabled,
64+
isPreview,
65+
previewContextValues,
66+
})
67+
const selectedWorkflowId = dependencyValues.workflowId
6468

6569
const inputController = useSubBlockInput({
6670
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}

apps/sim/blocks/blocks/workflow.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,20 @@ export const WorkflowBlock: BlockConfig = {
1414
id: 'workflowId',
1515
title: 'Select Workflow',
1616
type: 'workflow-selector',
17+
canonicalParamId: 'workflowId',
1718
selectorKey: 'sim.workflows',
1819
placeholder: 'Search workflows...',
1920
required: true,
21+
mode: 'basic',
22+
},
23+
{
24+
id: 'manualWorkflowId',
25+
title: 'Workflow ID',
26+
type: 'short-input',
27+
canonicalParamId: 'workflowId',
28+
placeholder: 'Enter workflow ID',
29+
required: true,
30+
mode: 'advanced',
2031
},
2132
{
2233
id: 'input',

apps/sim/blocks/blocks/workflow_input.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,20 @@ export const WorkflowInputBlock: BlockConfig = {
1919
id: 'workflowId',
2020
title: 'Select Workflow',
2121
type: 'workflow-selector',
22+
canonicalParamId: 'workflowId',
2223
selectorKey: 'sim.workflows',
2324
placeholder: 'Search workflows...',
2425
required: true,
26+
mode: 'basic',
27+
},
28+
{
29+
id: 'manualWorkflowId',
30+
title: 'Workflow ID',
31+
type: 'short-input',
32+
canonicalParamId: 'workflowId',
33+
placeholder: 'Enter workflow ID',
34+
required: true,
35+
mode: 'advanced',
2536
},
2637
{
2738
id: 'inputMapping',

bun.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)