@@ -7,6 +7,7 @@ import { toast } from "sonner";
77
88import { useAuth } from "@/components/auth-context" ;
99import { InsetLoading } from "@/components/inset-loading" ;
10+ import { EditMetadataDialog } from "@/components/workflow/edit-metadata-dialog" ;
1011import { EmailTriggerDialog } from "@/components/workflow/email-trigger-dialog" ;
1112import { ExecutionEmailDialog } from "@/components/workflow/execution-email-dialog" ;
1213import { ExecutionFormDialog } from "@/components/workflow/execution-form-dialog" ;
@@ -34,6 +35,8 @@ import {
3435import { useObjectService } from "@/services/object-service" ;
3536import { useNodeTypes } from "@/services/type-service" ;
3637import {
38+ getWorkflow ,
39+ updateWorkflow ,
3740 upsertCronTrigger ,
3841 useCronTrigger ,
3942 useWorkflowExecution ,
@@ -53,6 +56,11 @@ export function EditorPage() {
5356 useState ( false ) ;
5457 const [ isEmailTriggerDialogOpen , setIsEmailTriggerDialogOpen ] =
5558 useState ( false ) ;
59+ const [ isEditMetadataDialogOpen , setIsEditMetadataDialogOpen ] =
60+ useState ( false ) ;
61+ const [ localWorkflowName , setLocalWorkflowName ] = useState < string > ( "" ) ;
62+ const [ localWorkflowDescription , setLocalWorkflowDescription ] =
63+ useState < string > ( ) ;
5664
5765 // Fetch all node types initially (no filter)
5866 const { nodeTypes, nodeTypesError, isNodeTypesLoading } = useNodeTypes (
@@ -220,12 +228,20 @@ export function EditorPage() {
220228 submitEmailFormData,
221229 } = useWorkflowExecution ( orgHandle , wsExecuteWorkflow ) ;
222230
231+ // Sync local workflow name from metadata
232+ useEffect ( ( ) => {
233+ if ( workflowMetadata ?. name && ! localWorkflowName ) {
234+ setLocalWorkflowName ( workflowMetadata . name ) ;
235+ setLocalWorkflowDescription ( ( workflowMetadata as any ) . description ) ;
236+ }
237+ } , [ workflowMetadata , localWorkflowName ] ) ;
238+
223239 usePageBreadcrumbs (
224240 [
225241 { label : "Workflows" , to : getOrgUrl ( "workflows" ) } ,
226- { label : workflowMetadata ?. name || "Workflow" } ,
242+ { label : localWorkflowName || workflowMetadata ?. name || "Workflow" } ,
227243 ] ,
228- [ workflowMetadata ?. name ]
244+ [ localWorkflowName , workflowMetadata ?. name ]
229245 ) ;
230246
231247 const validateConnection = useCallback (
@@ -280,6 +296,42 @@ export function EditorPage() {
280296 }
281297 } ;
282298
299+ const handleEditMetadata = useCallback ( ( e : React . MouseEvent ) => {
300+ e . preventDefault ( ) ;
301+ e . stopPropagation ( ) ;
302+ setIsEditMetadataDialogOpen ( true ) ;
303+ } , [ ] ) ;
304+
305+ const handleSaveMetadata = useCallback (
306+ async ( name : string , description ?: string ) => {
307+ if ( ! id || ! orgHandle || ! workflowMetadata ) return ;
308+
309+ try {
310+ const fullWorkflow = await getWorkflow ( id , orgHandle ) ;
311+ await updateWorkflow (
312+ id ,
313+ {
314+ name,
315+ description,
316+ type : fullWorkflow . type ,
317+ nodes : fullWorkflow . nodes ,
318+ edges : fullWorkflow . edges ,
319+ } ,
320+ orgHandle
321+ ) ;
322+ toast . success ( "Workflow metadata updated" ) ;
323+
324+ // Update local state for display
325+ setLocalWorkflowName ( name ) ;
326+ setLocalWorkflowDescription ( description ) ;
327+ } catch ( error ) {
328+ console . error ( "Error updating workflow metadata:" , error ) ;
329+ toast . error ( "Failed to update workflow metadata" ) ;
330+ }
331+ } ,
332+ [ id , orgHandle , workflowMetadata ]
333+ ) ;
334+
283335 const handleDeployWorkflow = useCallback (
284336 async ( e : React . MouseEvent ) => {
285337 e . preventDefault ( ) ;
@@ -382,6 +434,7 @@ export function EditorPage() {
382434 validateConnection = { validateConnection }
383435 executeWorkflow = { editorExecuteWorkflow }
384436 onDeployWorkflow = { handleDeployWorkflow }
437+ onEditMetadata = { handleEditMetadata }
385438 createObjectUrl = { createObjectUrl }
386439 />
387440 </ div >
@@ -449,6 +502,15 @@ export function EditorPage() {
449502 workflowName = { workflowMetadata ?. name }
450503 />
451504 ) }
505+ { workflowMetadata && (
506+ < EditMetadataDialog
507+ open = { isEditMetadataDialogOpen }
508+ onOpenChange = { setIsEditMetadataDialogOpen }
509+ initialName = { localWorkflowName || workflowMetadata . name }
510+ initialDescription = { localWorkflowDescription }
511+ onSave = { handleSaveMetadata }
512+ />
513+ ) }
452514 </ div >
453515 </ ReactFlowProvider >
454516 ) ;
0 commit comments