From 9fffa9a99692be01aac0665fb5d459054e8eb224 Mon Sep 17 00:00:00 2001 From: lyzno1 Date: Fri, 24 Oct 2025 10:20:38 +0800 Subject: [PATCH] refactor(workflow): clean up entry node status and colocate store types --- .../workflow/__tests__/trigger-status-sync.test.tsx | 2 +- .../nodes/_base/components/entry-node-container.tsx | 13 +++---------- .../workflow/store/__tests__/trigger-status.test.ts | 2 +- web/app/components/workflow/store/trigger-status.ts | 3 ++- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/web/app/components/workflow/__tests__/trigger-status-sync.test.tsx b/web/app/components/workflow/__tests__/trigger-status-sync.test.tsx index de541ff922..dc208047cb 100644 --- a/web/app/components/workflow/__tests__/trigger-status-sync.test.tsx +++ b/web/app/components/workflow/__tests__/trigger-status-sync.test.tsx @@ -2,7 +2,7 @@ import React, { useCallback } from 'react' import { act, render } from '@testing-library/react' import { useTriggerStatusStore } from '../store/trigger-status' import { isTriggerNode } from '../types' -import type { EntryNodeStatus } from '../nodes/_base/components/entry-node-container' +import type { EntryNodeStatus } from '../store/trigger-status' // Mock the isTriggerNode function jest.mock('../types', () => ({ diff --git a/web/app/components/workflow/nodes/_base/components/entry-node-container.tsx b/web/app/components/workflow/nodes/_base/components/entry-node-container.tsx index d458599184..5ba5c21a39 100644 --- a/web/app/components/workflow/nodes/_base/components/entry-node-container.tsx +++ b/web/app/components/workflow/nodes/_base/components/entry-node-container.tsx @@ -2,11 +2,8 @@ import type { FC, ReactNode } from 'react' import { useMemo } from 'react' import { useTranslation } from 'react-i18next' -export type EntryNodeStatus = 'enabled' | 'disabled' - type EntryNodeContainerProps = { children: ReactNode - status?: EntryNodeStatus customLabel?: string nodeType?: 'start' | 'trigger' } @@ -18,20 +15,16 @@ const EntryNodeContainer: FC = ({ }) => { const { t } = useTranslation() - const statusConfig = useMemo(() => { + const label = useMemo(() => { const translationKey = nodeType === 'start' ? 'entryNodeStatus' : 'triggerStatus' - - return { - label: customLabel || t(`workflow.${translationKey}.enabled`), - dotClasses: 'bg-components-badge-status-light-success-bg border-components-badge-status-light-success-border-inner', - } + return customLabel || t(`workflow.${translationKey}.enabled`) }, [customLabel, nodeType, t]) return (
- {statusConfig.label} + {label}
{children} diff --git a/web/app/components/workflow/store/__tests__/trigger-status.test.ts b/web/app/components/workflow/store/__tests__/trigger-status.test.ts index c793def4ae..d7e1284487 100644 --- a/web/app/components/workflow/store/__tests__/trigger-status.test.ts +++ b/web/app/components/workflow/store/__tests__/trigger-status.test.ts @@ -1,6 +1,6 @@ import { act, renderHook } from '@testing-library/react' import { useTriggerStatusStore } from '../trigger-status' -import type { EntryNodeStatus } from '../../nodes/_base/components/entry-node-container' +import type { EntryNodeStatus } from '../trigger-status' describe('useTriggerStatusStore', () => { beforeEach(() => { diff --git a/web/app/components/workflow/store/trigger-status.ts b/web/app/components/workflow/store/trigger-status.ts index cfd86f1576..2f472c79b9 100644 --- a/web/app/components/workflow/store/trigger-status.ts +++ b/web/app/components/workflow/store/trigger-status.ts @@ -1,6 +1,7 @@ import { create } from 'zustand' import { subscribeWithSelector } from 'zustand/middleware' -import type { EntryNodeStatus } from '../nodes/_base/components/entry-node-container' + +export type EntryNodeStatus = 'enabled' | 'disabled' type TriggerStatusState = { // Map of nodeId to trigger status