Commit a5147a38 authored by StyleZhang's avatar StyleZhang

fix

parent 74bf6cd1
...@@ -30,7 +30,9 @@ import { ...@@ -30,7 +30,9 @@ import {
NODE_WIDTH_X_OFFSET, NODE_WIDTH_X_OFFSET,
Y_OFFSET, Y_OFFSET,
} from './constants' } from './constants'
import { getLayoutByDagre } from './utils' import {
getLayoutByDagre,
} from './utils'
import { useStore } from './store' import { useStore } from './store'
import type { ToolDefaultValue } from './block-selector/types' import type { ToolDefaultValue } from './block-selector/types'
import { syncWorkflowDraft } from '@/service/workflow' import { syncWorkflowDraft } from '@/service/workflow'
......
...@@ -4,6 +4,7 @@ import { ...@@ -4,6 +4,7 @@ import {
useState, useState,
} from 'react' } from 'react'
import Textarea from 'rc-textarea' import Textarea from 'rc-textarea'
import { useTranslation } from 'react-i18next'
type InputProps = { type InputProps = {
value: string value: string
...@@ -14,6 +15,8 @@ export const TitleInput = memo(({ ...@@ -14,6 +15,8 @@ export const TitleInput = memo(({
value, value,
onChange, onChange,
}: InputProps) => { }: InputProps) => {
const { t } = useTranslation()
return ( return (
<input <input
value={value} value={value}
...@@ -23,7 +26,7 @@ export const TitleInput = memo(({ ...@@ -23,7 +26,7 @@ export const TitleInput = memo(({
hover:bg-gray-50 hover:bg-gray-50
focus:border-gray-300 focus:shadow-xs focus:bg-white caret-[#295EFF] 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(({ ...@@ -33,6 +36,7 @@ export const DescriptionInput = memo(({
value, value,
onChange, onChange,
}: InputProps) => { }: InputProps) => {
const { t } = useTranslation()
const [focus, setFocus] = useState(false) const [focus, setFocus] = useState(false)
const handleFocus = useCallback(() => { const handleFocus = useCallback(() => {
setFocus(true) setFocus(true)
...@@ -60,7 +64,7 @@ export const DescriptionInput = memo(({ ...@@ -60,7 +64,7 @@ export const DescriptionInput = memo(({
appearance-none outline-none resize-none appearance-none outline-none resize-none
placeholder:text-gray-400 caret-[#295EFF] placeholder:text-gray-400 caret-[#295EFF]
`} `}
placeholder='Add description...' placeholder={t('workflow.common.addDescription') || ''}
autoSize autoSize
/> />
</div> </div>
......
...@@ -43,7 +43,7 @@ const BaseNode: FC<BaseNodeProps> = ({ ...@@ -43,7 +43,7 @@ const BaseNode: FC<BaseNodeProps> = ({
className={` className={`
group relative w-[240px] bg-[#fcfdff] shadow-xs group relative w-[240px] bg-[#fcfdff] shadow-xs
border border-transparent rounded-[15px] border border-transparent rounded-[15px]
hover:shadow-lg ${!data._runningStatus && 'hover:shadow-lg'}
${data._runningStatus === NodeRunningStatus.Running && '!border-primary-500'} ${data._runningStatus === NodeRunningStatus.Running && '!border-primary-500'}
${data._runningStatus === NodeRunningStatus.Succeeded && '!border-[#12B76A]'} ${data._runningStatus === NodeRunningStatus.Succeeded && '!border-[#12B76A]'}
${data._runningStatus === NodeRunningStatus.Failed && '!border-[#F04438]'} ${data._runningStatus === NodeRunningStatus.Failed && '!border-[#F04438]'}
......
...@@ -41,6 +41,8 @@ const BasePanel: FC<BasePanelProps> = ({ ...@@ -41,6 +41,8 @@ const BasePanel: FC<BasePanelProps> = ({
handleNodeDataUpdate, handleNodeDataUpdate,
} = useWorkflow() } = useWorkflow()
const handleTitleChange = useCallback((title: string) => { const handleTitleChange = useCallback((title: string) => {
if (!title)
return
handleNodeDataUpdate({ id, data: { ...data, title } }) handleNodeDataUpdate({ id, data: { ...data, title } })
}, [handleNodeDataUpdate, id, data]) }, [handleNodeDataUpdate, id, data])
const handleDescriptionChange = useCallback((desc: string) => { const handleDescriptionChange = useCallback((desc: string) => {
......
...@@ -171,6 +171,57 @@ export const canRunBySingle = (nodeType: BlockEnum) => { ...@@ -171,6 +171,57 @@ export const canRunBySingle = (nodeType: BlockEnum) => {
|| nodeType === BlockEnum.Tool || 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 = { ...@@ -21,6 +21,8 @@ const translation = {
currentDraft: 'Current Draft', currentDraft: 'Current Draft',
latestPublished: 'Latest Published', latestPublished: 'Latest Published',
restore: 'Restore', restore: 'Restore',
addTitle: 'Add title...',
addDescription: 'Add description...',
}, },
singleRun: { singleRun: {
testRun: 'Test Run ', testRun: 'Test Run ',
......
...@@ -21,6 +21,8 @@ const translation = { ...@@ -21,6 +21,8 @@ const translation = {
currentDraft: '当前草稿', currentDraft: '当前草稿',
latestPublished: '最新发布', latestPublished: '最新发布',
restore: '恢复', restore: '恢复',
addTitle: '添加标题...',
addDescription: '添加描述...',
}, },
singleRun: { singleRun: {
testRun: '测试运行 ', testRun: '测试运行 ',
......
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