refactor: nodes as builder pattern
This commit is contained in:
42
frontend/src/components/nodes/config/descriptor.tsx
Normal file
42
frontend/src/components/nodes/config/descriptor.tsx
Normal file
@@ -0,0 +1,42 @@
|
||||
import React from 'react'
|
||||
import { ScrollText } from 'lucide-react'
|
||||
import { createNodeTypeBuilder } from '@/lib/nodeTypeBuilder'
|
||||
import { NODE_HELP } from '@/lib/nodeHelp'
|
||||
import { getResolvedContentForConfig } from './renderingLogic'
|
||||
import type { NodeTypeDescriptor } from '@/lib/nodeRegistry'
|
||||
import ConfigNode from './ConfigNode'
|
||||
|
||||
const ICON_CLASS = 'mr-2 h-4 w-4'
|
||||
|
||||
export function getConfigNodeDescriptor(): NodeTypeDescriptor {
|
||||
return createNodeTypeBuilder(
|
||||
'config',
|
||||
ConfigNode,
|
||||
{ width: 320, height: 320 },
|
||||
{ configType: 'plantuml', content: '@startuml\n\n@enduml\n', title: '' }
|
||||
)
|
||||
.idPrefix('cfg_')
|
||||
.withInputOutput(true, true)
|
||||
.classification('psyche')
|
||||
.allowedSourceTypes(['config', 'variable', 'function', 'data'])
|
||||
.allowedTargetTypes(['config', 'render', 'agent'])
|
||||
.help(NODE_HELP.config)
|
||||
.menu('Config', <ScrollText className={ICON_CLASS} />)
|
||||
.getDefaultData((newId) => ({
|
||||
configType: 'plantuml',
|
||||
content: '@startuml\n\n@enduml\n',
|
||||
title: newId ?? '',
|
||||
}))
|
||||
.getResetData((nodeId) => ({
|
||||
configType: 'plantuml',
|
||||
content: '@startuml\n\n@enduml\n',
|
||||
title: nodeId ?? '',
|
||||
}))
|
||||
.connectionLabel('adding input')
|
||||
.withFullscreen()
|
||||
.sourceRenderingLogic({
|
||||
defaultUpdateMode: 'auto',
|
||||
getResolvedContent: getResolvedContentForConfig,
|
||||
})
|
||||
.build()
|
||||
}
|
||||
Reference in New Issue
Block a user