import { memo, useState, } from 'react' import { useTranslation } from 'react-i18next' import { useEdges, useNodes, } from 'reactflow' import { RiCloseLine, RiListCheck3, } from '@remixicon/react' import BlockIcon from '../block-icon' import { useChecklist, useNodesInteractions, } from '../hooks' import type { ChecklistItem } from '../hooks/use-checklist' import type { CommonEdgeType, CommonNodeType, } from '../types' import cn from '@/utils/classnames' import { PortalToFollowElem, PortalToFollowElemContent, PortalToFollowElemTrigger, } from '@/app/components/base/portal-to-follow-elem' import { ChecklistSquare, } from '@/app/components/base/icons/src/vender/line/general' import { Warning } from '@/app/components/base/icons/src/vender/line/alertsAndFeedback' import { IconR } from '@/app/components/base/icons/src/vender/line/arrows' import type { BlockEnum } from '../types' type WorkflowChecklistProps = { disabled: boolean } const WorkflowChecklist = ({ disabled, }: WorkflowChecklistProps) => { const { t } = useTranslation() const [open, setOpen] = useState(false) const nodes = useNodes() const edges = useEdges() const needWarningNodes = useChecklist(nodes, edges) const { handleNodeSelect } = useNodesInteractions() const handleChecklistItemClick = (item: ChecklistItem) => { if (!item.canNavigate) return handleNodeSelect(item.id) setOpen(false) } return ( !disabled && setOpen(v => !v)}>
{ !!needWarningNodes.length && (
{needWarningNodes.length}
) }
{t('workflow.panel.checklist')}{needWarningNodes.length ? `(${needWarningNodes.length})` : ''}
setOpen(false)} >
{ !!needWarningNodes.length && ( <>
{t('workflow.panel.checklistTip')}
{ needWarningNodes.map(node => (
handleChecklistItemClick(node)} >
{node.title} { node.canNavigate && (
{t('workflow.panel.goTo')}
) }
{ node.unConnected && (
{t('workflow.common.needConnectTip')}
) } { node.errorMessage && (
{node.errorMessage}
) }
)) }
) } { !needWarningNodes.length && (
{t('workflow.panel.checklistResolved')}
) }
) } export default memo(WorkflowChecklist)