({ nodes, edges, mode, onNodeClick }: ValidationDockProps)
| 41 | } |
| 42 | |
| 43 | export function ValidationDock({ nodes, edges, mode, onNodeClick }: ValidationDockProps) { |
| 44 | const { getComponent } = useComponentStore(); |
| 45 | const [isExpanded, setIsExpanded] = useState(false); |
| 46 | const [isMobileSheetOpen, setIsMobileSheetOpen] = useState(false); |
| 47 | const isMobile = useIsMobile(); |
| 48 | |
| 49 | // Only show validation in design mode |
| 50 | const isDesignMode = mode === 'design'; |
| 51 | |
| 52 | const secrets = useSecretStore((state: SecretStore) => state.secrets); |
| 53 | |
| 54 | const validationIssues = useMemo<ValidationIssue[]>(() => { |
| 55 | if (!isDesignMode) return []; |
| 56 | |
| 57 | const issues: ValidationIssue[] = []; |
| 58 | |
| 59 | nodes.forEach((node) => { |
| 60 | const nodeData = node.data as any; |
| 61 | const componentRef = nodeData.componentId ?? nodeData.componentSlug; |
| 62 | const component = getComponent(componentRef); |
| 63 | |
| 64 | if (!component) return; |
| 65 | |
| 66 | // Get validation warnings using the existing utility |
| 67 | // FrontendNodeData extends NodeData, so this cast is safe |
| 68 | const warnings = getNodeValidationWarnings( |
| 69 | node as Node<FrontendNodeData>, |
| 70 | edges, |
| 71 | component, |
| 72 | secrets, |
| 73 | ); |
| 74 | |
| 75 | warnings.forEach((warning: string) => { |
| 76 | issues.push({ |
| 77 | nodeId: node.id, |
| 78 | nodeLabel: nodeData.label || component.name || node.id, |
| 79 | message: warning, |
| 80 | }); |
| 81 | }); |
| 82 | }); |
| 83 | |
| 84 | return issues; |
| 85 | }, [nodes, edges, getComponent, isDesignMode, secrets]); |
| 86 | |
| 87 | const totalIssues = validationIssues.length; |
| 88 | const hasIssues = totalIssues > 0; |
| 89 | const shouldCollapse = totalIssues > COLLAPSE_THRESHOLD; |
| 90 | |
| 91 | // Don't show dock if not in design mode |
| 92 | if (!isDesignMode) { |
| 93 | return null; |
| 94 | } |
| 95 | |
| 96 | // Handle node click in mobile view - close sheet after clicking |
| 97 | const handleMobileNodeClick = (nodeId: string) => { |
| 98 | onNodeClick(nodeId); |
| 99 | setIsMobileSheetOpen(false); |
| 100 | }; |
nothing calls this directly
no test coverage detected