chore: remove block code

This commit is contained in:
Joel
2026-03-23 16:32:48 +08:00
parent a659296dc7
commit 2cbc8da9cb
29 changed files with 64 additions and 1734 deletions

View File

@ -41,14 +41,13 @@ const PanelOperatorPopup = ({
handleNodesDuplicate,
handleNodeSelect,
handleNodesCopy,
handleUngroup,
} = useNodesInteractions()
const { handleNodeDataUpdate } = useNodeDataUpdate()
const { handleSyncWorkflowDraft } = useNodesSyncDraft()
const { nodesReadOnly } = useNodesReadOnly()
const edge = edges.find(edge => edge.target === id)
const nodeMetaData = useNodeMetaData({ id, data } as Node)
const showChangeBlock = !nodeMetaData.isTypeFixed && !nodesReadOnly && data.type !== BlockEnum.Group
const showChangeBlock = !nodeMetaData.isTypeFixed && !nodesReadOnly
const isChildNode = !!(data.isInIteration || data.isInLoop)
const { data: workflowTools } = useAllWorkflowTools()
@ -62,25 +61,6 @@ const PanelOperatorPopup = ({
return (
<div className="w-[240px] rounded-lg border-[0.5px] border-components-panel-border bg-components-panel-bg shadow-xl">
{
!nodesReadOnly && data.type === BlockEnum.Group && (
<>
<div className="p-1">
<div
className="flex h-8 cursor-pointer items-center justify-between rounded-lg px-3 text-sm text-text-secondary hover:bg-state-base-hover"
onClick={() => {
onClosePopup()
handleUngroup(id)
}}
>
{t('panel.ungroup', { ns: 'workflow' })}
<ShortcutsName keys={['ctrl', 'shift', 'g']} />
</div>
</div>
<div className="h-px bg-divider-regular"></div>
</>
)
}
{
(showChangeBlock || canRunBySingle(data.type, isChildNode)) && (
<>

View File

@ -651,7 +651,7 @@ const BasePanel: FC<BasePanelProps> = ({
)
}
{
!needsToolAuth && !currentDataSource && !currentTriggerPlugin && data.type !== BlockEnum.Group && (
!needsToolAuth && !currentDataSource && !currentTriggerPlugin && (
<div className="flex items-center justify-between pl-4 pr-3">
<Tab
value={tabType}
@ -660,9 +660,9 @@ const BasePanel: FC<BasePanelProps> = ({
</div>
)
}
{data.type !== BlockEnum.Group && <Split />}
<Split />
</div>
{(tabType === TabType.settings || data.type === BlockEnum.Group) && (
{tabType === TabType.settings && (
<div className="flex flex-1 flex-col overflow-y-auto">
<div>
{cloneElement(children as any, {

View File

@ -67,7 +67,6 @@ const singleRunFormParamsHooks: Record<BlockEnum, any> = {
[BlockEnum.VariableAggregator]: useVariableAggregatorSingleRunFormParams,
[BlockEnum.Assigner]: useVariableAssignerSingleRunFormParams,
[BlockEnum.KnowledgeBase]: useKnowledgeBaseSingleRunFormParams,
[BlockEnum.Group]: undefined,
[BlockEnum.VariableAssigner]: undefined,
[BlockEnum.End]: undefined,
[BlockEnum.Answer]: undefined,
@ -119,7 +118,6 @@ const getDataForCheckMoreHooks: Record<BlockEnum, any> = {
[BlockEnum.DataSource]: undefined,
[BlockEnum.DataSourceEmpty]: undefined,
[BlockEnum.KnowledgeBase]: undefined,
[BlockEnum.Group]: undefined,
[BlockEnum.TriggerWebhook]: undefined,
[BlockEnum.TriggerSchedule]: undefined,
[BlockEnum.TriggerPlugin]: useTriggerPluginGetDataForCheckMore,

View File

@ -300,7 +300,7 @@ const BaseNode: FC<BaseNodeProps> = ({
)
}
{
data.type !== BlockEnum.IfElse && data.type !== BlockEnum.QuestionClassifier && data.type !== BlockEnum.Group && data.type !== BlockEnum.HumanInput && !data._isCandidate && (
data.type !== BlockEnum.IfElse && data.type !== BlockEnum.QuestionClassifier && data.type !== BlockEnum.HumanInput && !data._isCandidate && (
<NodeSourceHandle
id={id}
data={data}

View File

@ -18,8 +18,6 @@ import EndNode from './end/node'
import EndPanel from './end/panel'
import FileUploadNode from './file-upload/node'
import FileUploadPanel from './file-upload/panel'
import GroupNode from './group/node'
import GroupPanel from './group/panel'
import HttpNode from './http/node'
import HttpPanel from './http/panel'
import HumanInputNode from './human-input/node'
@ -86,7 +84,6 @@ export const NodeComponentMap: Record<string, ComponentType<any>> = {
[BlockEnum.TriggerPlugin]: TriggerPluginNode,
[BlockEnum.Command]: CommandNode,
[BlockEnum.FileUpload]: FileUploadNode,
[BlockEnum.Group]: GroupNode,
}
export const PanelComponentMap: Record<string, ComponentType<any>> = {
@ -118,5 +115,4 @@ export const PanelComponentMap: Record<string, ComponentType<any>> = {
[BlockEnum.TriggerPlugin]: TriggerPluginPanel,
[BlockEnum.Command]: CommandPanel,
[BlockEnum.FileUpload]: FileUploadPanel,
[BlockEnum.Group]: GroupPanel,
}

View File

@ -1,26 +0,0 @@
import type { NodeDefault } from '../../types'
import type { GroupNodeData } from './types'
import { BlockEnum } from '@/app/components/workflow/types'
import { genNodeMetaData } from '@/app/components/workflow/utils'
const metaData = genNodeMetaData({
sort: 100,
type: BlockEnum.Group,
})
const nodeDefault: NodeDefault<GroupNodeData> = {
metaData,
defaultValue: {
members: [],
handlers: [],
headNodeIds: [],
leafNodeIds: [],
},
checkValid() {
return {
isValid: true,
}
},
}
export default nodeDefault

View File

@ -1,94 +0,0 @@
import type { GroupHandler, GroupMember, GroupNodeData } from './types'
import type { BlockEnum, NodeProps } from '@/app/components/workflow/types'
import { RiArrowRightSLine } from '@remixicon/react'
import { memo, useMemo } from 'react'
import BlockIcon from '@/app/components/workflow/block-icon'
import { cn } from '@/utils/classnames'
import { NodeSourceHandle } from '../_base/components/node-handle'
const MAX_MEMBER_ICONS = 12
const GroupNode = (props: NodeProps<GroupNodeData>) => {
const { data } = props
// show the explicitly passed members first; otherwise use the _children information to fill the type
const members: GroupMember[] = useMemo(() => (
data.members?.length
? data.members
: data._children?.length
? data._children.map(child => ({
id: child.nodeId,
type: child.nodeType as BlockEnum,
label: child.nodeType,
}))
: []
), [data._children, data.members])
const handlers: GroupHandler[] = useMemo(() => (
data.handlers?.length
? data.handlers
: members.length
? members.map(member => ({
id: `${member.id}-source`,
label: member.label || member.id,
nodeId: member.id,
sourceHandle: 'source',
}))
: []
), [data.handlers, members])
return (
<div className="space-y-2 px-3 pb-3">
{members.length > 0 && (
<div className="flex items-center gap-1 overflow-hidden">
<div className="flex flex-wrap items-center gap-1 overflow-hidden">
{members.slice(0, MAX_MEMBER_ICONS).map(member => (
<div
key={member.id}
className="flex h-7 items-center rounded-full bg-components-input-bg-normal px-1.5 shadow-xs"
>
<BlockIcon
type={member.type}
size="xs"
className="!shadow-none"
/>
</div>
))}
{members.length > MAX_MEMBER_ICONS && (
<div className="rounded-full bg-components-input-bg-normal px-2 py-1 text-text-tertiary system-xs-medium">
+
{members.length - MAX_MEMBER_ICONS}
</div>
)}
</div>
<RiArrowRightSLine className="ml-auto h-4 w-4 shrink-0 text-text-tertiary" />
</div>
)}
{handlers.length > 0 && (
<div className="space-y-1">
{handlers.map(handler => (
<div
key={handler.id}
className={cn(
'relative',
'uppercase system-sm-semibold',
'flex h-9 items-center rounded-md bg-components-panel-on-panel-item-bg px-3 text-text-primary shadow-xs',
)}
>
{handler.label || handler.id}
<NodeSourceHandle
{...props}
handleId={handler.id}
handleClassName="!top-1/2 !-translate-y-1/2 !-right-[21px]"
/>
</div>
))}
</div>
)}
</div>
)
}
GroupNode.displayName = 'GroupNode'
export default memo(GroupNode)

View File

@ -1,9 +0,0 @@
import { memo } from 'react'
const GroupPanel = () => {
return null
}
GroupPanel.displayName = 'GroupPanel'
export default memo(GroupPanel)

View File

@ -1,21 +0,0 @@
import type { BlockEnum, CommonNodeType } from '../../types'
export type GroupMember = {
id: string
type: BlockEnum
label?: string
}
export type GroupHandler = {
id: string
label?: string
nodeId?: string // leaf node id for multi-branch nodes
sourceHandle?: string // original sourceHandle (e.g., case_id for if-else)
}
export type GroupNodeData = CommonNodeType<{
members?: GroupMember[]
handlers?: GroupHandler[]
headNodeIds?: string[] // nodes that receive input from outside the group
leafNodeIds?: string[] // nodes that send output to outside the group
}>