Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions console/packages/console-frontend/src/api/flows/flows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,37 @@ export async function fetchFlows(): Promise<FlowResponse[]> {

const functions = functionsData.functions || []

// Build a map of function_id -> triggers
// Build a map of function_id -> triggers, normalizing engine config field names
// to the metadata format that createStep expects (e.g. api_path -> path)
const triggersByFunction = new Map<string, Array<Record<string, unknown>>>()
for (const trigger of triggersData.triggers || []) {
const funcId = trigger.function_id
const existing = triggersByFunction.get(funcId) ?? []
existing.push({
const config = trigger.config as Record<string, unknown>
const normalized: Record<string, unknown> = {
...config,
type: trigger.trigger_type,
...trigger.config,
})
}

if (trigger.trigger_type === 'http') {
const rawPath = config.api_path as string | undefined
normalized.path = rawPath
? rawPath.startsWith('/')
? rawPath
: `/${rawPath}`
: config.path
normalized.method = config.http_method ?? config.method
} else if (trigger.trigger_type === 'cron') {
normalized.expression = config.expression
} else if (
trigger.trigger_type === 'event' ||
trigger.trigger_type === 'queue' ||
trigger.trigger_type === 'durable:subscriber'
) {
normalized.topic = config.topic
}

existing.push(normalized)
triggersByFunction.set(funcId, existing)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Position } from '@xyflow/react'
import { clsx } from 'clsx'
import { Children } from 'react'
import type { NodeData } from '../../../api/flows/types'
import { BaseHandle } from './base-handle'
import { NodeHeader } from './node-header'
Expand All @@ -26,6 +27,7 @@ export function BaseNode({
const sourcePos =
data.nodeConfig?.sourceHandlePosition === 'right' ? Position.Right : Position.Bottom
const targetPos = data.nodeConfig?.targetHandlePosition === 'left' ? Position.Left : Position.Top
const hasChildren = Children.toArray(children).length > 0

return (
<div className="rounded-lg max-w-[350px]">
Expand All @@ -34,7 +36,7 @@ export function BaseNode({
<NodeHeader text={title} variant={variant} triggers={data.triggers} />

{subtitle && <div className="py-3 px-3 text-[11px] text-[#9CA3AF]">{subtitle}</div>}
{children && (
{hasChildren && (
<div className="p-2">
<div
className={clsx(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ const DEFAULT_CONFIG: NodeConfig = { x: 0, y: 0 }
const NODE_TYPES = {
event: EventFlowNode,
http: ApiFlowNode,
api: ApiFlowNode, // fallback
noop: NoopFlowNode,
cron: CronFlowNode,
queue: QueueFlowNode,
'queue': QueueFlowNode, // fallback
'durable:subscriber': QueueFlowNode,
state: StateFlowNode,
}

Expand Down Expand Up @@ -93,6 +95,8 @@ export function useFlowState(flow: FlowResponse, flowConfig: FlowConfigResponse)
if (syncKey === lastSyncKeyRef.current) return
lastSyncKeyRef.current = syncKey



setNodes(buildNodes(flow, flowConfig))
setEdges(buildEdges(flow))
}, [flow, flowConfig, configStr, setNodes, setEdges])
Expand Down Expand Up @@ -130,6 +134,10 @@ export function useFlowState(flow: FlowResponse, flowConfig: FlowConfigResponse)
}
}, [savePositions])

useEffect(() => {
console.log(nodes)
}, [nodes])

return useMemo(
() => ({
nodes,
Expand Down
Loading