11'use client'
22
3- import { useState , useRef } from 'react'
4- import { Upload , FileText , Plus , AlertCircle , CheckCircle } from 'lucide-react'
3+ import { useRef , useState } from 'react'
4+ import { AlertCircle , CheckCircle , FileText , Plus , Upload } from 'lucide-react'
5+ import { useParams , useRouter } from 'next/navigation'
6+ import { Alert , AlertDescription } from '@/components/ui/alert'
57import { Button } from '@/components/ui/button'
6- import {
7- DropdownMenu ,
8- DropdownMenuContent ,
9- DropdownMenuItem ,
10- DropdownMenuTrigger ,
11- } from '@/components/ui/dropdown-menu'
128import {
139 Dialog ,
1410 DialogContent ,
@@ -17,16 +13,19 @@ import {
1713 DialogHeader ,
1814 DialogTitle ,
1915} from '@/components/ui/dialog'
16+ import {
17+ DropdownMenu ,
18+ DropdownMenuContent ,
19+ DropdownMenuItem ,
20+ DropdownMenuTrigger ,
21+ } from '@/components/ui/dropdown-menu'
2022import { Textarea } from '@/components/ui/textarea'
2123import { Tooltip , TooltipContent , TooltipTrigger } from '@/components/ui/tooltip'
22- import { Alert , AlertDescription } from '@/components/ui/alert'
2324import { createLogger } from '@/lib/logs/console-logger'
24- import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
2525import { useCollaborativeWorkflow } from '@/hooks/use-collaborative-workflow'
26+ import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
2627import { useSubBlockStore } from '@/stores/workflows/subblock/store'
2728import { importWorkflowFromYaml , parseWorkflowYaml } from '@/stores/workflows/yaml/importer'
28- import { useRouter } from 'next/navigation'
29- import { useParams } from 'next/navigation'
3029
3130const logger = createLogger ( 'ImportControls' )
3231
@@ -44,12 +43,12 @@ export function ImportControls({ disabled = false }: ImportControlsProps) {
4443 warnings : string [ ]
4544 summary ?: string
4645 } | null > ( null )
47-
46+
4847 const fileInputRef = useRef < HTMLInputElement > ( null )
4948 const router = useRouter ( )
5049 const params = useParams ( )
5150 const workspaceId = params . workspaceId as string
52-
51+
5352 // Stores and hooks
5453 const { createWorkflow } = useWorkflowRegistry ( )
5554 const { collaborativeAddBlock, collaborativeAddEdge } = useCollaborativeWorkflow ( )
@@ -67,8 +66,10 @@ export function ImportControls({ disabled = false }: ImportControlsProps) {
6766 logger . error ( 'Failed to read file:' , error )
6867 setImportResult ( {
6968 success : false ,
70- errors : [ `Failed to read file: ${ error instanceof Error ? error . message : 'Unknown error' } ` ] ,
71- warnings : [ ]
69+ errors : [
70+ `Failed to read file: ${ error instanceof Error ? error . message : 'Unknown error' } ` ,
71+ ] ,
72+ warnings : [ ] ,
7273 } )
7374 }
7475
@@ -83,7 +84,7 @@ export function ImportControls({ disabled = false }: ImportControlsProps) {
8384 setImportResult ( {
8485 success : false ,
8586 errors : [ 'YAML content is required' ] ,
86- warnings : [ ]
87+ warnings : [ ] ,
8788 } )
8889 return
8990 }
@@ -94,12 +95,12 @@ export function ImportControls({ disabled = false }: ImportControlsProps) {
9495 try {
9596 // First validate the YAML without importing
9697 const { data : yamlWorkflow , errors : parseErrors } = parseWorkflowYaml ( yamlContent )
97-
98+
9899 if ( ! yamlWorkflow || parseErrors . length > 0 ) {
99100 setImportResult ( {
100101 success : false ,
101102 errors : parseErrors ,
102- warnings : [ ]
103+ warnings : [ ] ,
103104 } )
104105 return
105106 }
@@ -116,9 +117,9 @@ export function ImportControls({ disabled = false }: ImportControlsProps) {
116117 router . push ( `/workspace/${ workspaceId } /w/${ newWorkflowId } ` )
117118
118119 // Small delay to ensure navigation and workflow initialization
119- await new Promise ( resolve => setTimeout ( resolve , 1000 ) )
120+ await new Promise ( ( resolve ) => setTimeout ( resolve , 1000 ) )
120121
121- // Import the YAML into the new workflow
122+ // Import the YAML into the new workflow
122123 const result = await importWorkflowFromYaml ( yamlContent , {
123124 addBlock : collaborativeAddBlock ,
124125 addEdge : collaborativeAddEdge ,
@@ -133,7 +134,7 @@ export function ImportControls({ disabled = false }: ImportControlsProps) {
133134 // This will be called after navigation, so we need to get blocks from the store
134135 const { useWorkflowStore } = require ( '@/stores/workflows/workflow/store' )
135136 return useWorkflowStore . getState ( ) . blocks
136- }
137+ } ,
137138 } )
138139
139140 setImportResult ( result )
@@ -146,13 +147,12 @@ export function ImportControls({ disabled = false }: ImportControlsProps) {
146147 setImportResult ( null )
147148 } , 2000 )
148149 }
149-
150150 } catch ( error ) {
151151 logger . error ( 'Failed to import YAML workflow:' , error )
152152 setImportResult ( {
153153 success : false ,
154154 errors : [ `Import failed: ${ error instanceof Error ? error . message : 'Unknown error' } ` ] ,
155- warnings : [ ]
155+ warnings : [ ] ,
156156 } )
157157 } finally {
158158 setIsImporting ( false )
@@ -198,10 +198,12 @@ export function ImportControls({ disabled = false }: ImportControlsProps) {
198198 < Upload className = 'h-4 w-4' />
199199 < div className = 'flex flex-col' >
200200 < span > Upload YAML File</ span >
201- < span className = 'text-muted-foreground text-xs' > Import from .yaml or .yml file</ span >
201+ < span className = 'text-muted-foreground text-xs' >
202+ Import from .yaml or .yml file
203+ </ span >
202204 </ div >
203205 </ DropdownMenuItem >
204-
206+
205207 < DropdownMenuItem
206208 onClick = { handleOpenYamlDialog }
207209 disabled = { isDisabled }
@@ -236,11 +238,12 @@ export function ImportControls({ disabled = false }: ImportControlsProps) {
236238
237239 { /* YAML Import Dialog */ }
238240 < Dialog open = { showYamlDialog } onOpenChange = { setShowYamlDialog } >
239- < DialogContent className = 'max-w-4xl max-h-[80vh] flex flex-col' >
241+ < DialogContent className = 'flex max-h-[80vh] max-w-4xl flex-col' >
240242 < DialogHeader >
241243 < DialogTitle > Import Workflow from YAML</ DialogTitle >
242244 < DialogDescription >
243- Paste your workflow YAML content below. This will create a new workflow with the blocks and connections defined in the YAML.
245+ Paste your workflow YAML content below. This will create a new workflow with the
246+ blocks and connections defined in the YAML.
244247 </ DialogDescription >
245248 </ DialogHeader >
246249
@@ -284,10 +287,12 @@ blocks:
284287 ) }
285288 { importResult . warnings . length > 0 && (
286289 < div className = 'mt-2' >
287- < div className = 'text-sm font-medium' > Warnings:</ div >
290+ < div className = 'font-medium text-sm ' > Warnings:</ div >
288291 < ul className = 'mt-1 space-y-1 text-sm' >
289292 { importResult . warnings . map ( ( warning , index ) => (
290- < li key = { index } className = 'text-yellow-700' > • { warning } </ li >
293+ < li key = { index } className = 'text-yellow-700' >
294+ • { warning }
295+ </ li >
291296 ) ) }
292297 </ ul >
293298 </ div >
@@ -321,15 +326,12 @@ blocks:
321326 >
322327 Cancel
323328 </ Button >
324- < Button
325- onClick = { handleYamlImport }
326- disabled = { isImporting || ! yamlContent . trim ( ) }
327- >
329+ < Button onClick = { handleYamlImport } disabled = { isImporting || ! yamlContent . trim ( ) } >
328330 { isImporting ? 'Importing...' : 'Import Workflow' }
329331 </ Button >
330332 </ DialogFooter >
331333 </ DialogContent >
332334 </ Dialog >
333335 </ >
334336 )
335- }
337+ }
0 commit comments