dify/web/app/components/workflow/nodes/_base/node.helpers.tsx
Stephen Zhou a84c2d36a3
style: format with vp fmt (#38803)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-07-12 15:57:46 +00:00

36 lines
1.4 KiB
TypeScript

import type { NodeProps } from '@/app/components/workflow/types'
import { BlockEnum, isTriggerNode, NodeRunningStatus } from '@/app/components/workflow/types'
export const getNodeStatusBorders = (
runningStatus: NodeRunningStatus | undefined,
hasVarValue: boolean,
showSelectedBorder: boolean,
) => {
return {
showRunningBorder:
(runningStatus === NodeRunningStatus.Running || runningStatus === NodeRunningStatus.Paused) &&
!showSelectedBorder,
showSuccessBorder:
(runningStatus === NodeRunningStatus.Succeeded || (hasVarValue && !runningStatus)) &&
!showSelectedBorder,
showFailedBorder: runningStatus === NodeRunningStatus.Failed && !showSelectedBorder,
showExceptionBorder: runningStatus === NodeRunningStatus.Exception && !showSelectedBorder,
}
}
export const getLoopIndexTextKey = (runningStatus: NodeRunningStatus | undefined) => {
if (runningStatus === NodeRunningStatus.Running) return 'nodes.loop.currentLoopCount'
if (runningStatus === NodeRunningStatus.Succeeded || runningStatus === NodeRunningStatus.Failed)
return 'nodes.loop.totalLoopCount'
return undefined
}
export const isEntryWorkflowNode = (type: NodeProps['data']['type']) => {
return isTriggerNode(type) || type === BlockEnum.Start || type === BlockEnum.StartPlaceholder
}
export const isContainerNode = (type: NodeProps['data']['type']) => {
return type === BlockEnum.Iteration || type === BlockEnum.Loop
}