11import { useNavigate } from "@tanstack/react-router" ;
22import { useCallback , useEffect , useMemo , useRef , useState } from "react" ;
33
4- import type { TooltipButtonProps } from "@/components/shared/Buttons/TooltipButton " ;
5- import { ComponentEditorDialog } from "@/components/shared/ComponentEditor/ComponentEditorDialog " ;
4+ import { CodeViewer } from "@/components/shared/CodeViewer " ;
5+ import type { Action } from "@/components/shared/ContextPanel/Blocks/ActionBlock " ;
66import { PublishedComponentBadge } from "@/components/shared/ManageComponent/PublishedComponentBadge" ;
77import { trimDigest } from "@/components/shared/ManageComponent/utils/digest" ;
88import { useBetaFlagValue } from "@/components/shared/Settings/useBetaFlags" ;
@@ -38,7 +38,6 @@ const TaskNodeCard = () => {
3838 "remote-component-library-search" ,
3939 ) ;
4040 const isSubgraphNavigationEnabled = useBetaFlagValue ( "subgraph-navigation" ) ;
41- const isInAppEditorEnabled = useBetaFlagValue ( "in-app-component-editor" ) ;
4241 const { registerNode } = useNodesOverlay ( ) ;
4342 const taskNode = useTaskNode ( ) ;
4443 const {
@@ -55,7 +54,7 @@ const TaskNodeCard = () => {
5554 const nodeRef = useRef < HTMLDivElement | null > ( null ) ;
5655 const contentRef = useRef < HTMLDivElement > ( null ) ;
5756
58- const [ isEditDialogOpen , setIsEditDialogOpen ] = useState ( false ) ;
57+ const [ isYamlFullscreen , setIsYamlFullscreen ] = useState ( false ) ;
5958 const [ updateOverlayDialogOpen , setUpdateOverlayDialogOpen ] = useState <
6059 UpdateOverlayMessage [ "data" ] | undefined
6160 > ( ) ;
@@ -128,69 +127,63 @@ const TaskNodeCard = () => {
128127 }
129128 } , [ ] ) ;
130129
131- const handleEditComponent = useCallback ( ( ) => {
132- setIsEditDialogOpen ( true ) ;
133- } , [ ] ) ;
134-
135- const handleCloseEditDialog = useCallback ( ( ) => {
136- setIsEditDialogOpen ( false ) ;
137- } , [ ] ) ;
138-
139- const { onDuplicate, onUpgrade } = callbacks ;
140-
141- const taskConfigMarkup = useMemo ( ( ) => {
142- const actions : Array < TooltipButtonProps > = [ ] ;
143-
144- if ( ! readOnly ) {
145- actions . push ( {
146- children : < Icon name = "Copy" size = "sm" /> ,
147- variant : "outline" ,
148- tooltip : "Duplicate Task" ,
149- onClick : onDuplicate ,
150- } ) ;
151- }
130+ const handleDuplicateTask = useCallback ( ( ) => {
131+ callbacks . onDuplicate ?.( ) ;
132+ } , [ callbacks ] ) ;
152133
153- if ( ! readOnly && ! isCustomComponent ) {
154- actions . push ( {
155- children : < Icon name = "CircleFadingArrowUp" size = "sm" /> ,
156- variant : "outline" ,
157- tooltip : "Update Task from Source URL" ,
158- onClick : onUpgrade ,
159- } ) ;
160- }
161-
162- if ( isSubgraphNode && taskId && isSubgraphNavigationEnabled ) {
163- actions . push ( {
164- children : < Icon name = "Workflow" size = "sm" /> ,
165- variant : "outline" ,
166- tooltip : `Enter Subgraph: ${ subgraphDescription } ` ,
167- onClick : ( ) => navigateToSubgraph ( taskId ) ,
168- } ) ;
169- }
134+ const handleUpgradeTask = useCallback ( ( ) => {
135+ callbacks . onUpgrade ?.( ) ;
136+ } , [ callbacks ] ) ;
170137
171- if ( isInAppEditorEnabled ) {
172- actions . push ( {
173- children : < Icon name = "FilePenLine" size = "sm" /> ,
174- variant : "outline" ,
175- tooltip : "Edit Component Definition" ,
176- onClick : handleEditComponent ,
177- } ) ;
138+ const handleEnterSubgraph = useCallback ( ( ) => {
139+ if ( taskId ) {
140+ navigateToSubgraph ( taskId ) ;
178141 }
142+ } , [ navigateToSubgraph , taskId ] ) ;
179143
180- return < TaskOverview taskNode = { taskNode } key = { nodeId } actions = { actions } /> ;
144+ const taskConfigMarkup = useMemo ( ( ) => {
145+ const customActions : Action [ ] = [
146+ {
147+ label : "Duplicate Task" ,
148+ icon : "Copy" ,
149+ hidden : readOnly ,
150+ onClick : handleDuplicateTask ,
151+ } ,
152+ {
153+ label : "Update Task from Source URL" ,
154+ icon : "CircleFadingArrowUp" ,
155+ hidden : readOnly || isCustomComponent ,
156+ onClick : handleUpgradeTask ,
157+ } ,
158+ {
159+ label : `Enter Subgraph: ${ subgraphDescription } ` ,
160+ icon : "Workflow" ,
161+ hidden : ! isSubgraphNode || ! isSubgraphNavigationEnabled ,
162+ onClick : handleEnterSubgraph ,
163+ } ,
164+ {
165+ label : "View YAML" ,
166+ icon : "FileCodeCorner" ,
167+ onClick : ( ) => setIsYamlFullscreen ( true ) ,
168+ } ,
169+ ] ;
170+
171+ return (
172+ < TaskOverview
173+ key = { nodeId }
174+ taskNode = { taskNode }
175+ customActions = { customActions }
176+ />
177+ ) ;
181178 } , [
182179 taskNode ,
183180 nodeId ,
184181 readOnly ,
185- isInAppEditorEnabled ,
186182 isCustomComponent ,
187183 isSubgraphNode ,
188184 taskId ,
189185 subgraphDescription ,
190186 navigateToSubgraph ,
191- handleEditComponent ,
192- onDuplicate ,
193- onUpgrade ,
194187 isSubgraphNavigationEnabled ,
195188 ] ) ;
196189
@@ -272,6 +265,8 @@ const TaskNodeCard = () => {
272265 </ QuickTooltip >
273266 ) ;
274267
268+ const componentText = taskSpec . componentRef ?. text ;
269+
275270 return (
276271 < >
277272 < Card
@@ -361,10 +356,13 @@ const TaskNodeCard = () => {
361356 ) : null }
362357 </ CardContent >
363358 </ Card >
364- { isEditDialogOpen && (
365- < ComponentEditorDialog
366- text = { taskSpec . componentRef ?. text }
367- onClose = { handleCloseEditDialog }
359+ { isYamlFullscreen && componentText && (
360+ < CodeViewer
361+ code = { componentText }
362+ language = "yaml"
363+ filename = { name }
364+ isFullscreen = { isYamlFullscreen }
365+ onClose = { ( ) => setIsYamlFullscreen ( false ) }
368366 />
369367 ) }
370368 </ >
0 commit comments