Commit 344e30be authored by StyleZhang's avatar StyleZhang

node

parent 45ef4059
...@@ -105,9 +105,10 @@ const Item = ({ ...@@ -105,9 +105,10 @@ const Item = ({
provider_id: data.id, provider_id: data.id,
provider_type: data.type, provider_type: data.type,
tool_name: tool.name, tool_name: tool.name,
_icon: data.icon,
title: tool.label[language], title: tool.label[language],
desc: tool.description[language], _icon: data.icon,
_about: tool.description[language],
_author: data.author,
})} })}
> >
<div className='absolute left-[22px] w-[1px] h-8 bg-black/5' /> <div className='absolute left-[22px] w-[1px] h-8 bg-black/5' />
......
...@@ -30,6 +30,7 @@ export type ToolDefaultValue = { ...@@ -30,6 +30,7 @@ export type ToolDefaultValue = {
provider_type: string provider_type: string
tool_name: string tool_name: string
title: string title: string
desc: string
_icon: Collection['icon'] _icon: Collection['icon']
_about: string
_author: string
} }
...@@ -14,24 +14,28 @@ import EndNodeDefault from './nodes/end/default' ...@@ -14,24 +14,28 @@ import EndNodeDefault from './nodes/end/default'
export const NODES_INITIAL_DATA = { export const NODES_INITIAL_DATA = {
[BlockEnum.Start]: { [BlockEnum.Start]: {
_author: 'Dify',
type: BlockEnum.Start, type: BlockEnum.Start,
title: '', title: '',
desc: '', desc: '',
...StartNodeDefault.defaultValue, ...StartNodeDefault.defaultValue,
}, },
[BlockEnum.End]: { [BlockEnum.End]: {
_author: 'Dify',
type: BlockEnum.End, type: BlockEnum.End,
title: '', title: '',
desc: '', desc: '',
...EndNodeDefault.defaultValue, ...EndNodeDefault.defaultValue,
}, },
[BlockEnum.DirectAnswer]: { [BlockEnum.DirectAnswer]: {
_author: 'Dify',
type: BlockEnum.DirectAnswer, type: BlockEnum.DirectAnswer,
title: '', title: '',
desc: '', desc: '',
...DirectAnswerDefault.defaultValue, ...DirectAnswerDefault.defaultValue,
}, },
[BlockEnum.LLM]: { [BlockEnum.LLM]: {
_author: 'Dify',
type: BlockEnum.LLM, type: BlockEnum.LLM,
title: '', title: '',
desc: '', desc: '',
...@@ -39,6 +43,7 @@ export const NODES_INITIAL_DATA = { ...@@ -39,6 +43,7 @@ export const NODES_INITIAL_DATA = {
...LLMDefault.defaultValue, ...LLMDefault.defaultValue,
}, },
[BlockEnum.KnowledgeRetrieval]: { [BlockEnum.KnowledgeRetrieval]: {
_author: 'Dify',
type: BlockEnum.KnowledgeRetrieval, type: BlockEnum.KnowledgeRetrieval,
title: '', title: '',
desc: '', desc: '',
...@@ -48,6 +53,7 @@ export const NODES_INITIAL_DATA = { ...@@ -48,6 +53,7 @@ export const NODES_INITIAL_DATA = {
...KnowledgeRetrievalDefault.defaultValue, ...KnowledgeRetrievalDefault.defaultValue,
}, },
[BlockEnum.IfElse]: { [BlockEnum.IfElse]: {
_author: 'Dify',
type: BlockEnum.IfElse, type: BlockEnum.IfElse,
title: '', title: '',
desc: '', desc: '',
...@@ -55,6 +61,7 @@ export const NODES_INITIAL_DATA = { ...@@ -55,6 +61,7 @@ export const NODES_INITIAL_DATA = {
...IfElseDefault.defaultValue, ...IfElseDefault.defaultValue,
}, },
[BlockEnum.Code]: { [BlockEnum.Code]: {
_author: 'Dify',
type: BlockEnum.Code, type: BlockEnum.Code,
title: '', title: '',
desc: '', desc: '',
...@@ -65,6 +72,7 @@ export const NODES_INITIAL_DATA = { ...@@ -65,6 +72,7 @@ export const NODES_INITIAL_DATA = {
...CodeDefault.defaultValue, ...CodeDefault.defaultValue,
}, },
[BlockEnum.TemplateTransform]: { [BlockEnum.TemplateTransform]: {
_author: 'Dify',
type: BlockEnum.TemplateTransform, type: BlockEnum.TemplateTransform,
title: '', title: '',
desc: '', desc: '',
...@@ -73,6 +81,7 @@ export const NODES_INITIAL_DATA = { ...@@ -73,6 +81,7 @@ export const NODES_INITIAL_DATA = {
...TemplateTransformDefault.defaultValue, ...TemplateTransformDefault.defaultValue,
}, },
[BlockEnum.QuestionClassifier]: { [BlockEnum.QuestionClassifier]: {
_author: 'Dify',
type: BlockEnum.QuestionClassifier, type: BlockEnum.QuestionClassifier,
title: '', title: '',
desc: '', desc: '',
...@@ -81,6 +90,7 @@ export const NODES_INITIAL_DATA = { ...@@ -81,6 +90,7 @@ export const NODES_INITIAL_DATA = {
...QuestionClassifierDefault.defaultValue, ...QuestionClassifierDefault.defaultValue,
}, },
[BlockEnum.HttpRequest]: { [BlockEnum.HttpRequest]: {
_author: 'Dify',
type: BlockEnum.HttpRequest, type: BlockEnum.HttpRequest,
title: '', title: '',
desc: '', desc: '',
...@@ -88,6 +98,7 @@ export const NODES_INITIAL_DATA = { ...@@ -88,6 +98,7 @@ export const NODES_INITIAL_DATA = {
...HttpRequestDefault.defaultValue, ...HttpRequestDefault.defaultValue,
}, },
[BlockEnum.VariableAssigner]: { [BlockEnum.VariableAssigner]: {
_author: 'Dify',
type: BlockEnum.VariableAssigner, type: BlockEnum.VariableAssigner,
title: '', title: '',
desc: '', desc: '',
...@@ -106,3 +117,4 @@ export const NODES_INITIAL_DATA = { ...@@ -106,3 +117,4 @@ export const NODES_INITIAL_DATA = {
export const NODE_WIDTH = 220 export const NODE_WIDTH = 220
export const X_OFFSET = 64 export const X_OFFSET = 64
export const Y_OFFSET = 39 export const Y_OFFSET = 39
export const TREE_DEEPTH = 20
...@@ -202,7 +202,9 @@ const WorkflowWrap: FC<WorkflowProps> = ({ ...@@ -202,7 +202,9 @@ const WorkflowWrap: FC<WorkflowProps> = ({
if (isLoading) { if (isLoading) {
return ( return (
<Loading /> <div className='flex justify-center items-center relative w-full h-full bg-[#F0F2F7]'>
<Loading />
</div>
) )
} }
......
...@@ -11,18 +11,21 @@ import { ...@@ -11,18 +11,21 @@ import {
PortalToFollowElemContent, PortalToFollowElemContent,
PortalToFollowElemTrigger, PortalToFollowElemTrigger,
} from '@/app/components/base/portal-to-follow-elem' } from '@/app/components/base/portal-to-follow-elem'
import type { Node } from '@/app/components/workflow/types'
type PanelOperatorProps = { type PanelOperatorProps = {
nodeId: string id: string
data: Node['data']
} }
const PanelOperator = ({ const PanelOperator = ({
nodeId, id,
data,
}: PanelOperatorProps) => { }: PanelOperatorProps) => {
const edges = useEdges() const edges = useEdges()
const { handleNodeDelete } = useWorkflow() const { handleNodeDelete } = useWorkflow()
const [open, setOpen] = useState(false) const [open, setOpen] = useState(false)
const edge = edges.find(edge => edge.target === nodeId) const edge = edges.find(edge => edge.target === id)
return ( return (
<PortalToFollowElem <PortalToFollowElem
...@@ -49,7 +52,7 @@ const PanelOperator = ({ ...@@ -49,7 +52,7 @@ const PanelOperator = ({
<div className='w-[240px] border-[0.5px] border-gray-200 rounded-2xl shadow-xl bg-white'> <div className='w-[240px] border-[0.5px] border-gray-200 rounded-2xl shadow-xl bg-white'>
<div className='p-1'> <div className='p-1'>
<ChangeBlock <ChangeBlock
nodeId={nodeId} nodeId={id}
sourceHandle={edge?.sourceHandle || 'source'} sourceHandle={edge?.sourceHandle || 'source'}
/> />
<div className='flex items-center px-3 h-8 text-sm text-gray-700 rounded-lg cursor-pointer hover:bg-gray-50'>Help Link</div> <div className='flex items-center px-3 h-8 text-sm text-gray-700 rounded-lg cursor-pointer hover:bg-gray-50'>Help Link</div>
...@@ -58,7 +61,7 @@ const PanelOperator = ({ ...@@ -58,7 +61,7 @@ const PanelOperator = ({
<div className='p-1'> <div className='p-1'>
<div <div
className='flex items-center px-3 h-8 text-sm text-gray-700 rounded-lg cursor-pointer hover:bg-gray-50' className='flex items-center px-3 h-8 text-sm text-gray-700 rounded-lg cursor-pointer hover:bg-gray-50'
onClick={() => handleNodeDelete(nodeId)} onClick={() => handleNodeDelete(id)}
> >
Delete Delete
</div> </div>
...@@ -69,10 +72,10 @@ const PanelOperator = ({ ...@@ -69,10 +72,10 @@ const PanelOperator = ({
<div className='flex items-center mb-1 h-[22px] font-medium'> <div className='flex items-center mb-1 h-[22px] font-medium'>
ABOUT ABOUT
</div> </div>
<div className='text-gray-500 leading-[18px]'>A tool for performing a Google SERP search and extracting snippets and webpages.Input should be a search query.</div> <div className='text-gray-500 leading-[18px]'>{data._about}</div>
<div className='my-2 h-[0.5px] bg-black/5'></div> <div className='my-2 h-[0.5px] bg-black/5'></div>
<div className='leading-[18px]'> <div className='leading-[18px]'>
Created By Dify Created By {data._author}
</div> </div>
</div> </div>
</div> </div>
......
...@@ -34,7 +34,6 @@ const BasePanel: FC<BasePanelProps> = ({ ...@@ -34,7 +34,6 @@ const BasePanel: FC<BasePanelProps> = ({
data, data,
children, children,
}) => { }) => {
const type = data.type
const { const {
handleNodeSelect, handleNodeSelect,
handleNodeDataUpdate, handleNodeDataUpdate,
...@@ -75,7 +74,7 @@ const BasePanel: FC<BasePanelProps> = ({ ...@@ -75,7 +74,7 @@ const BasePanel: FC<BasePanelProps> = ({
</TooltipPlus> </TooltipPlus>
) )
} }
<PanelOperator nodeId={id} /> <PanelOperator id={id} data={data} />
<div className='mx-3 w-[1px] h-3.5 bg-gray-200' /> <div className='mx-3 w-[1px] h-3.5 bg-gray-200' />
<div <div
className='flex items-center justify-center w-6 h-6 cursor-pointer' className='flex items-center justify-center w-6 h-6 cursor-pointer'
......
...@@ -31,6 +31,8 @@ export type CommonNodeType<T = {}> = { ...@@ -31,6 +31,8 @@ export type CommonNodeType<T = {}> = {
_targetBranches?: Branch[] _targetBranches?: Branch[]
_isSingleRun?: boolean _isSingleRun?: boolean
_icon?: Collection['icon'] _icon?: Collection['icon']
_about?: string
_author?: string
title: string title: string
desc: string desc: string
type: BlockEnum type: BlockEnum
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment