feat: var assigner node struct

This commit is contained in:
Joel
2024-02-22 11:42:20 +08:00
parent 2fdcf1756e
commit 6057ba0988
8 changed files with 56 additions and 8 deletions

View File

@ -22,6 +22,8 @@ import HttpNode from './http/node'
import HttpPanel from './http/panel'
import ToolNode from './tool/node'
import ToolPanel from './tool/panel'
import VariableAssignerNode from './variable-assigner/node'
import VariableAssignerPanel from './variable-assigner/panel'
export const NodeComponentMap: Record<string, ComponentType> = {
[BlockEnum.Start]: StartNode,
@ -35,6 +37,7 @@ export const NodeComponentMap: Record<string, ComponentType> = {
[BlockEnum.TemplateTransform]: TemplateTransformNode,
[BlockEnum.HttpRequest]: HttpNode,
[BlockEnum.Tool]: ToolNode,
[BlockEnum.VariableAssigner]: VariableAssignerNode,
}
export const PanelComponentMap: Record<string, ComponentType> = {
@ -49,4 +52,5 @@ export const PanelComponentMap: Record<string, ComponentType> = {
[BlockEnum.TemplateTransform]: TemplateTransformPanel,
[BlockEnum.HttpRequest]: HttpPanel,
[BlockEnum.Tool]: ToolPanel,
[BlockEnum.VariableAssigner]: VariableAssignerPanel,
}

View File

@ -0,0 +1,12 @@
import type { VariableAssignerNodeType } from './types'
export const mockData: VariableAssignerNodeType = {
title: 'Test',
desc: 'Test',
type: 'Test',
output_type: 'string',
variables: [
['aaa', 'name'],
['bbb', 'b', 'c'],
],
}

View File

@ -0,0 +1,16 @@
import type { FC } from 'react'
import { useTranslation } from 'react-i18next'
// import { mockData } from './mock'
const i18nPrefix = 'workflow.nodes.variableAssigner'
const Node: FC = () => {
const { t } = useTranslation()
// const { variables } = mockData
return (
<div className='px-3'>
<div className='leading-4 text-xs font-medium text-gray-500 uppercase'>{t(`${i18nPrefix}.title`)}</div>
</div>
)
}
export default Node

View File

@ -0,0 +1,9 @@
import type { FC } from 'react'
const Panel: FC = () => {
return (
<div>start panel inputs</div>
)
}
export default Panel

View File

@ -0,0 +1,6 @@
import type { CommonNodeType, ValueSelector } from '@/app/components/workflow/types'
export type VariableAssignerNodeType = CommonNodeType & {
output_type: string
variables: ValueSelector[]
}