2025-10-14 13:30:54 +08:00
|
|
|
import { BaseNode } from '@/interfaces/database/agent';
|
2025-09-08 18:59:51 +08:00
|
|
|
import { NodeProps, Position } from '@xyflow/react';
|
|
|
|
|
import { memo } from 'react';
|
2025-10-14 13:30:54 +08:00
|
|
|
import { useTranslation } from 'react-i18next';
|
2025-09-08 18:59:51 +08:00
|
|
|
import { NodeHandleId } from '../../constant';
|
2025-10-14 13:30:54 +08:00
|
|
|
import { ParserFormSchemaType } from '../../form/parser-form';
|
|
|
|
|
import { LabelCard } from './card';
|
2025-09-08 18:59:51 +08:00
|
|
|
import { CommonHandle } from './handle';
|
|
|
|
|
import { LeftHandleStyle, RightHandleStyle } from './handle-icon';
|
|
|
|
|
import NodeHeader from './node-header';
|
|
|
|
|
import { NodeWrapper } from './node-wrapper';
|
|
|
|
|
|
|
|
|
|
function ParserNode({
|
|
|
|
|
id,
|
|
|
|
|
data,
|
|
|
|
|
isConnectable = true,
|
|
|
|
|
selected,
|
2025-10-14 13:30:54 +08:00
|
|
|
}: NodeProps<BaseNode<ParserFormSchemaType>>) {
|
|
|
|
|
const { t } = useTranslation();
|
2025-09-08 18:59:51 +08:00
|
|
|
return (
|
2025-10-09 12:36:19 +08:00
|
|
|
<NodeWrapper selected={selected}>
|
|
|
|
|
<CommonHandle
|
|
|
|
|
id={NodeHandleId.End}
|
|
|
|
|
type="target"
|
|
|
|
|
position={Position.Left}
|
|
|
|
|
isConnectable={isConnectable}
|
|
|
|
|
style={LeftHandleStyle}
|
|
|
|
|
nodeId={id}
|
|
|
|
|
></CommonHandle>
|
|
|
|
|
<CommonHandle
|
|
|
|
|
type="source"
|
|
|
|
|
position={Position.Right}
|
|
|
|
|
isConnectable={isConnectable}
|
|
|
|
|
id={NodeHandleId.Start}
|
|
|
|
|
style={RightHandleStyle}
|
|
|
|
|
nodeId={id}
|
|
|
|
|
isConnectableEnd={false}
|
|
|
|
|
></CommonHandle>
|
|
|
|
|
<NodeHeader id={id} name={data.name} label={data.label}></NodeHeader>
|
2025-10-14 13:30:54 +08:00
|
|
|
<section className="space-y-2">
|
|
|
|
|
{data.form?.setups.map((x, idx) => (
|
|
|
|
|
<LabelCard
|
|
|
|
|
key={idx}
|
2025-10-14 14:55:47 +08:00
|
|
|
className="flex justify- flex-col text-text-primary gap-1"
|
2025-10-14 13:30:54 +08:00
|
|
|
>
|
|
|
|
|
<span className="text-text-secondary">Parser {idx + 1}</span>
|
|
|
|
|
{t(`dataflow.fileFormatOptions.${x.fileFormat}`)}
|
|
|
|
|
</LabelCard>
|
|
|
|
|
))}
|
|
|
|
|
</section>
|
2025-10-09 12:36:19 +08:00
|
|
|
</NodeWrapper>
|
2025-09-08 18:59:51 +08:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default memo(ParserNode);
|