mirror of https://github.com/langgenius/dify.git
fix
This commit is contained in:
parent
74bf6cd186
commit
a5147a382d
|
|
@ -30,7 +30,9 @@ import {
|
|||
NODE_WIDTH_X_OFFSET,
|
||||
Y_OFFSET,
|
||||
} from './constants'
|
||||
import { getLayoutByDagre } from './utils'
|
||||
import {
|
||||
getLayoutByDagre,
|
||||
} from './utils'
|
||||
import { useStore } from './store'
|
||||
import type { ToolDefaultValue } from './block-selector/types'
|
||||
import { syncWorkflowDraft } from '@/service/workflow'
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import {
|
|||
useState,
|
||||
} from 'react'
|
||||
import Textarea from 'rc-textarea'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
type InputProps = {
|
||||
value: string
|
||||
|
|
@ -14,6 +15,8 @@ export const TitleInput = memo(({
|
|||
value,
|
||||
onChange,
|
||||
}: InputProps) => {
|
||||
const { t } = useTranslation()
|
||||
|
||||
return (
|
||||
<input
|
||||
value={value}
|
||||
|
|
@ -23,7 +26,7 @@ export const TitleInput = memo(({
|
|||
hover:bg-gray-50
|
||||
focus:border-gray-300 focus:shadow-xs focus:bg-white caret-[#295EFF]
|
||||
`}
|
||||
placeholder='Add title...'
|
||||
placeholder={t('workflow.common.addTitle') || ''}
|
||||
/>
|
||||
)
|
||||
})
|
||||
|
|
@ -33,6 +36,7 @@ export const DescriptionInput = memo(({
|
|||
value,
|
||||
onChange,
|
||||
}: InputProps) => {
|
||||
const { t } = useTranslation()
|
||||
const [focus, setFocus] = useState(false)
|
||||
const handleFocus = useCallback(() => {
|
||||
setFocus(true)
|
||||
|
|
@ -60,7 +64,7 @@ export const DescriptionInput = memo(({
|
|||
appearance-none outline-none resize-none
|
||||
placeholder:text-gray-400 caret-[#295EFF]
|
||||
`}
|
||||
placeholder='Add description...'
|
||||
placeholder={t('workflow.common.addDescription') || ''}
|
||||
autoSize
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ const BaseNode: FC<BaseNodeProps> = ({
|
|||
className={`
|
||||
group relative w-[240px] bg-[#fcfdff] shadow-xs
|
||||
border border-transparent rounded-[15px]
|
||||
hover:shadow-lg
|
||||
${!data._runningStatus && 'hover:shadow-lg'}
|
||||
${data._runningStatus === NodeRunningStatus.Running && '!border-primary-500'}
|
||||
${data._runningStatus === NodeRunningStatus.Succeeded && '!border-[#12B76A]'}
|
||||
${data._runningStatus === NodeRunningStatus.Failed && '!border-[#F04438]'}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ const BasePanel: FC<BasePanelProps> = ({
|
|||
handleNodeDataUpdate,
|
||||
} = useWorkflow()
|
||||
const handleTitleChange = useCallback((title: string) => {
|
||||
if (!title)
|
||||
return
|
||||
handleNodeDataUpdate({ id, data: { ...data, title } })
|
||||
}, [handleNodeDataUpdate, id, data])
|
||||
const handleDescriptionChange = useCallback((desc: string) => {
|
||||
|
|
|
|||
|
|
@ -171,6 +171,57 @@ export const canRunBySingle = (nodeType: BlockEnum) => {
|
|||
|| nodeType === BlockEnum.Tool
|
||||
}
|
||||
|
||||
export const getVariables = (currentNodeId: string) => {
|
||||
export const getTreeLeafNodes = (nodes: Node[], edges: Edge[]) => {
|
||||
const startNode = nodes.find(node => node.data.type === BlockEnum.Start)
|
||||
|
||||
if (!startNode)
|
||||
return []
|
||||
|
||||
const list: Node[] = []
|
||||
const preOrder = (root: Node, callback: (node: Node) => void) => {
|
||||
const outgoers = getOutgoers(root, nodes, edges)
|
||||
|
||||
if (outgoers.length) {
|
||||
outgoers.forEach((outgoer) => {
|
||||
preOrder(outgoer, callback)
|
||||
})
|
||||
}
|
||||
else {
|
||||
callback(root)
|
||||
}
|
||||
}
|
||||
preOrder(startNode, (node) => {
|
||||
list.push(node)
|
||||
})
|
||||
|
||||
return list
|
||||
}
|
||||
|
||||
export const getBeforeNodesInSameBranch = (nodeId: string, targetHandle: string, nodes: Node[], edges: Edge[]) => {
|
||||
const currentNode = nodes.find(node => node.id === nodeId)!
|
||||
const list: Node[] = []
|
||||
|
||||
const traverse = (root: Node, callback: (node: Node) => void) => {
|
||||
const connectedEdges = getConnectedEdges([root], edges)
|
||||
const sourceEdge = connectedEdges.filter(edge => edge.targetHandle === targetHandle)
|
||||
const sourceEdgeLength = sourceEdge.length
|
||||
|
||||
if (sourceEdgeLength === 1) {
|
||||
const before = nodes.find(node => node.id === sourceEdge[0].source)
|
||||
|
||||
if (before) {
|
||||
callback(before)
|
||||
traverse(before, callback)
|
||||
}
|
||||
}
|
||||
}
|
||||
traverse(currentNode, (node) => {
|
||||
list.push(node)
|
||||
})
|
||||
|
||||
const length = list.length
|
||||
if (length && list[length - 1].data.type === BlockEnum.Start)
|
||||
return list.reverse()
|
||||
|
||||
return []
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ const translation = {
|
|||
currentDraft: 'Current Draft',
|
||||
latestPublished: 'Latest Published',
|
||||
restore: 'Restore',
|
||||
addTitle: 'Add title...',
|
||||
addDescription: 'Add description...',
|
||||
},
|
||||
singleRun: {
|
||||
testRun: 'Test Run ',
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ const translation = {
|
|||
currentDraft: '当前草稿',
|
||||
latestPublished: '最新发布',
|
||||
restore: '恢复',
|
||||
addTitle: '添加标题...',
|
||||
addDescription: '添加描述...',
|
||||
},
|
||||
singleRun: {
|
||||
testRun: '测试运行 ',
|
||||
|
|
|
|||
Loading…
Reference in New Issue