Skip to content
20 changes: 11 additions & 9 deletions src/main/frontend/app/hooks/use-handle-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@ import type { ElementProperty } from '@frankframework/ff-doc'

export function useHandleTypes(typesAllowed?: Record<string, ElementProperty>) {
return useMemo(() => {
// Elements should always have access to a success handle, indicating a happy path
const base: string[] = ['success']
// Always include the 'success' handle, using a Set to avoid duplicates
const handles = new Set<string>(['success'])

if (!typesAllowed) return base
if (!typesAllowed) return [...handles]

// Replace wildcard with 'custom' type
const hasWildcard = '*' in typesAllowed
if (hasWildcard) {
base.push('custom')
if ('*' in typesAllowed) {
handles.add('custom')
}

const forwards = Object.keys(typesAllowed).filter((type) => type !== '*')
for (const type of Object.keys(typesAllowed)) {
if (type !== '*') {
handles.add(type)
}
}

return [...base, ...forwards]
return [...handles]
}, [typesAllowed])
}
4 changes: 3 additions & 1 deletion src/main/frontend/app/routes/studio/canvas/flow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ const selector = (state: FlowState) => ({
function FlowCanvas({ showNodeContextMenu }: Readonly<{ showNodeContextMenu: (b: boolean) => void }>) {
const theme = useTheme()
const [loading, setLoading] = useState(false)
const { isEditing, setIsEditing, setParentId } = useNodeContextStore(
const { isEditing, setIsEditing, setParentId, setDraggedName } = useNodeContextStore(
useShallow((s) => ({
isEditing: s.isEditing,
setIsEditing: s.setIsEditing,
setParentId: s.setParentId,
setDraggedName: s.setDraggedName,
})),
)
const [showModal, setShowModal] = useState(false)
Expand Down Expand Up @@ -333,6 +334,7 @@ function FlowCanvas({ showNodeContextMenu }: Readonly<{ showNodeContextMenu: (b:

const onDrop = (event: React.DragEvent) => {
event.preventDefault()
setDraggedName(null)
setParentId(null)

const data = event.dataTransfer.getData('application/reactflow')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import useNodeContextStore from '~/stores/node-context-store'
import { useNodeContextMenu } from '~/routes/studio/canvas/flow'
import { useSettingsStore } from '~/routes/settings/settings-store'
import { useFrankDoc } from '~/providers/frankdoc-provider'
import type { Attribute } from '~/types/ff-doc.types'
import type { Attribute } from '@frankframework/ff-doc'

export type ExitNode = Node<{
subtype: string
type: string
name: string
attributes: Record<string, string>
}>

export default function ExitNodeComponent(properties: NodeProps<ExitNode>) {
Expand Down
Loading
Loading