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 { 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 { AlertTriangle } from '@/app/components/base/icons/src/vender/line/alertsAndFeedback' 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() 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 => (
{ handleNodeSelect(node.id) setOpen(false) }} >
{node.title}
{ node.unConnected && (
{t('workflow.common.needConnectTip')}
) } { node.errorMessage && (
{node.errorMessage}
) }
)) }
) } { !needWarningNodes.length && (
{t('workflow.panel.checklistResolved')}
) }
) } export default memo(WorkflowChecklist)