feat(workflow): remove unused trigger status logic and simplify entry node status handling

This commit is contained in:
zhsama 2025-10-23 18:19:06 +08:00
parent efe68d5aa6
commit 4ae23ed0f9
2 changed files with 3 additions and 23 deletions

View File

@ -13,23 +13,19 @@ type EntryNodeContainerProps = {
const EntryNodeContainer: FC<EntryNodeContainerProps> = ({
children,
status = 'enabled',
customLabel,
nodeType = 'trigger',
}) => {
const { t } = useTranslation()
const statusConfig = useMemo(() => {
const isDisabled = status === 'disabled'
const translationKey = nodeType === 'start' ? 'entryNodeStatus' : 'triggerStatus'
return {
label: customLabel || (isDisabled ? t(`workflow.${translationKey}.disabled`) : t(`workflow.${translationKey}.enabled`)),
dotClasses: isDisabled
? 'bg-components-badge-status-light-disabled-bg border-components-badge-status-light-disabled-border-inner'
: 'bg-components-badge-status-light-success-bg border-components-badge-status-light-success-border-inner',
label: customLabel || t(`workflow.${translationKey}.enabled`),
dotClasses: 'bg-components-badge-status-light-success-bg border-components-badge-status-light-success-border-inner',
}
}, [status, customLabel, nodeType, t])
}, [customLabel, nodeType, t])
return (
<div className="w-fit min-w-[242px] rounded-2xl bg-workflow-block-wrapper-bg-1 px-0 pb-0 pt-0.5">

View File

@ -5,7 +5,6 @@ import type {
import {
cloneElement,
memo,
useCallback,
useEffect,
useMemo,
useRef,
@ -50,8 +49,6 @@ import BlockIcon from '@/app/components/workflow/block-icon'
import Tooltip from '@/app/components/base/tooltip'
import useInspectVarsCrud from '../../hooks/use-inspect-vars-crud'
import { ToolTypeEnum } from '../../block-selector/types'
import { useTriggerStatusStore } from '../../store/trigger-status'
import { isTriggerNode } from '../../types'
type NodeChildProps = {
id: string
@ -73,13 +70,6 @@ const BaseNode: FC<BaseNodeProps> = ({
const nodeRef = useRef<HTMLDivElement>(null)
const { nodesReadOnly } = useNodesReadOnly()
// Subscribe to trigger status for this specific node ID (reactive)
// Use useCallback to optimize selector and prevent unnecessary re-renders
const triggerStatusSelector = useCallback((state: any) =>
isTriggerNode(data.type) ? (state.triggerStatuses[id] || 'disabled') : 'enabled',
[id, data.type],
)
const triggerStatus = useTriggerStatusStore(triggerStatusSelector)
const { handleNodeIterationChildSizeChange } = useNodeIterationInteractions()
const { handleNodeLoopChildSizeChange } = useNodeLoopInteractions()
const toolIcon = useToolIcon(data)
@ -355,14 +345,8 @@ const BaseNode: FC<BaseNodeProps> = ({
const isEntryNode = TRIGGER_NODE_TYPES.includes(data.type as any) || data.type === BlockEnum.Start
const isStartNode = data.type === BlockEnum.Start
// Determine node status dynamically
const nodeStatus = isStartNode
? 'enabled' // Start nodes are always enabled (green)
: triggerStatus // Use reactive trigger status
return isEntryNode ? (
<EntryNodeContainer
status={nodeStatus}
nodeType={isStartNode ? 'start' : 'trigger'}
>
{nodeContent}