Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 2 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,12 @@ import type { ElementProperty } from '@frankframework/doc-library-core'

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

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

if ('*' in typesAllowed) {
handles.add('custom')
}

for (const type of Object.keys(typesAllowed)) {
if (type !== '*') {
handles.add(type)
}
handles.add(type === '*' ? 'custom' : type)
}

return [...handles]
Expand Down
2 changes: 1 addition & 1 deletion src/main/frontend/app/routes/studio/canvas/flow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@
logApiError('Failed to save XML', error as Error)
setIdle()
}
}, [])

Check warning on line 394 in src/main/frontend/app/routes/studio/canvas/flow.tsx

View workflow job for this annotation

GitHub Actions / Build & Run All Tests

React Hook useCallback has missing dependencies: 'setIdle', 'setSaved', and 'setSaving'. Either include them or remove the dependency array

const autosaveEnabled = useSettingsStore((s) => s.general.autoSave.enabled)
const autosaveDelay = useSettingsStore((s) => s.general.autoSave.delayMs)
Expand Down Expand Up @@ -1301,7 +1301,7 @@
setParentId(null)
}

function addNodeAtPosition(

Check warning on line 1304 in src/main/frontend/app/routes/studio/canvas/flow.tsx

View workflow job for this annotation

GitHub Actions / Build & Run All Tests

Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed
position: { x: number; y: number },
elementName: string,
sourceInfo?: { nodeId: string | null; handleId: string | null; handleType: 'source' | 'target' | null },
Expand Down Expand Up @@ -1332,7 +1332,7 @@
subtype: elementName,
type: elementType,
name: ``,
sourceHandles: [{ type: 'success', index: 1 }],
sourceHandles: [],
children: [],
},
type: nodeType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ export default function HandleMenu({
return createPortal(
<div
ref={menuRef}
className="nodrag bg-background border-border absolute rounded border shadow-md"
className="nodrag bg-background border-border absolute z-5 rounded border shadow-md"
style={{
left: `${position.x + 10}px`,
top: `${position.y - 5}px`,
}}
>
<div className="w-70">
<div className="border-border text-foreground-muted mt-[1px] flex h-10 items-center border-b p-2 text-xs font-semibold tracking-wide uppercase">
<div className="border-border text-foreground-muted mt-px flex h-10 items-center border-b p-2 text-xs font-semibold tracking-wide uppercase">
{title}
</div>
<ul className="w-full">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export function CustomHandle(properties: Readonly<HandleProperties>) {
const [menuPosition, setMenuPosition] = useState<{ x: number; y: number }>({ x: 0, y: 0 })

const handleClick = (event: React.MouseEvent) => {
if (typesAllowedListIsEmpty()) return
const { clientX, clientY } = event
setMenuPosition({
x: clientX,
Expand All @@ -51,6 +52,13 @@ export function CustomHandle(properties: Readonly<HandleProperties>) {
setIsMenuOpen(!isMenuOpen) // Toggle menu visibility
}

function typesAllowedListIsEmpty() {
return (
properties.typesAllowed === undefined ||
(properties.typesAllowed && Object.keys(properties.typesAllowed).length <= 0)
)
}

const handleMenuClick = (newType: string) => {
properties.onChangeType(newType) // Change the handle type
setIsMenuOpen(false) // Close the menu after selection
Expand Down
Loading
Loading