import type { NodeActionsMenuProps } from './types' import { ContextMenuGroup, ContextMenuItem, ContextMenuLinkItem, ContextMenuSeparator, } from '@langgenius/dify-ui/context-menu' import { useTranslation } from 'react-i18next' import { ChangeBlockMenuTrigger } from './change-block-menu-trigger' import { NODE_ACTIONS_MENU_DELETE_ITEM_CLASS_NAME, NODE_ACTIONS_MENU_ITEM_WITH_SHORTCUT_CLASS_NAME, NodeActionsMenuAbout, NodeActionsMenuItemContent, } from './shared' import { useNodeActionsMenuModel } from './use-node-actions-menu-model' export function NodeActionsContextMenuContent(props: NodeActionsMenuProps) { const { t } = useTranslation() const model = useNodeActionsMenuModel(props) const hasRunGroup = model.canRun || model.canChangeBlock const hasEditGroup = !model.nodesReadOnly && !model.isSingleton const hasDeleteGroup = !model.nodesReadOnly && !model.isUndeletable const singleRunActionLabel = model.isSingleRunning ? t(($) => $['debug.variableInspect.trigger.stop'], { ns: 'workflow' }) : t(($) => $['panel.runThisStep'], { ns: 'workflow' }) return ( <> {hasRunGroup && ( {model.canRun && ( {singleRunActionLabel} )} {model.canChangeBlock && ( )} )} {hasRunGroup && (hasEditGroup || hasDeleteGroup || model.workflowAppHref || model.helpLinkUri) && ( )} {hasEditGroup && ( {t(($) => $['common.copy'], { ns: 'workflow' })} {t(($) => $['common.duplicate'], { ns: 'workflow' })} )} {hasEditGroup && (hasDeleteGroup || model.workflowAppHref || model.helpLinkUri) && ( )} {hasDeleteGroup && ( {t(($) => $['operation.delete'], { ns: 'common' })} )} {hasDeleteGroup && (model.workflowAppHref || model.helpLinkUri) && } {model.workflowAppHref && ( {t(($) => $['panel.openWorkflow'], { ns: 'workflow' })} )} {model.workflowAppHref && model.helpLinkUri && } {model.helpLinkUri && ( {t(($) => $['panel.helpLink'], { ns: 'workflow' })} )} $['panel.about'], { ns: 'workflow' })} description={model.about.description} author={`${t(($) => $['panel.createdBy'], { ns: 'workflow' })} ${model.about.author}`} /> ) }