chore: should hide change action when node is undeletable (#34592)

This commit is contained in:
非法操作
2026-04-10 19:29:29 +08:00
committed by GitHub
parent 66183c1f0a
commit 1b7d0bd4e6
2 changed files with 28 additions and 1 deletions

View File

@@ -222,6 +222,33 @@ describe('panel-operator details', () => {
expect(screen.getByRole('link', { name: 'workflow.panel.helpLink' })).toHaveAttribute('href', 'https://docs.example.com/node')
})
it('should hide change action when node is undeletable', () => {
mockUseNodeMetaData.mockReturnValueOnce({
isTypeFixed: false,
isSingleton: true,
isUndeletable: true,
description: 'Undeletable node',
author: 'Dify',
} as ReturnType<typeof useNodeMetaData>)
renderWorkflowFlowComponent(
<PanelOperatorPopup
id="node-4"
data={{ type: BlockEnum.Code, title: 'Undeletable node', desc: '' } as any}
onClosePopup={vi.fn()}
showHelpLink={false}
/>,
{
nodes: [],
edges: [],
},
)
expect(screen.getByText('workflow.panel.runThisStep')).toBeInTheDocument()
expect(screen.queryByText('workflow.panel.change')).not.toBeInTheDocument()
expect(screen.queryByText('common.operation.delete')).not.toBeInTheDocument()
})
it('should render workflow-tool and readonly popup variants', () => {
mockUseAllWorkflowTools.mockReturnValueOnce({
data: [{ id: 'workflow-tool', workflow_app_id: 'app-123' }],

View File

@@ -47,7 +47,7 @@ const PanelOperatorPopup = ({
const { nodesReadOnly } = useNodesReadOnly()
const edge = edges.find(edge => edge.target === id)
const nodeMetaData = useNodeMetaData({ id, data } as Node)
const showChangeBlock = !nodeMetaData.isTypeFixed && !nodesReadOnly
const showChangeBlock = !nodeMetaData.isTypeFixed && !nodeMetaData.isUndeletable && !nodesReadOnly
const isChildNode = !!(data.isInIteration || data.isInLoop)
const { data: workflowTools } = useAllWorkflowTools()