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" ;
@@ -36,7 +36,6 @@ const TaskNodeCard = () => {
3636 "remote-component-library-search" ,
3737 ) ;
3838 const isSubgraphNavigationEnabled = useBetaFlagValue ( "subgraph-navigation" ) ;
39- const isInAppEditorEnabled = useBetaFlagValue ( "in-app-component-editor" ) ;
4039 const { registerNode } = useNodesOverlay ( ) ;
4140 const taskNode = useTaskNode ( ) ;
4241 const {
@@ -52,7 +51,7 @@ const TaskNodeCard = () => {
5251 const nodeRef = useRef < HTMLDivElement | null > ( null ) ;
5352 const contentRef = useRef < HTMLDivElement > ( null ) ;
5453
55- const [ isEditDialogOpen , setIsEditDialogOpen ] = useState ( false ) ;
54+ const [ isYamlFullscreen , setIsYamlFullscreen ] = useState ( false ) ;
5655 const [ updateOverlayDialogOpen , setUpdateOverlayDialogOpen ] = useState <
5756 UpdateOverlayMessage [ "data" ] | undefined
5857 > ( ) ;
@@ -113,66 +112,64 @@ const TaskNodeCard = () => {
113112 }
114113 } , [ ] ) ;
115114
116- const handleEditComponent = useCallback ( ( ) => {
117- setIsEditDialogOpen ( true ) ;
118- } , [ ] ) ;
119-
120- const handleCloseEditDialog = useCallback ( ( ) => {
121- setIsEditDialogOpen ( false ) ;
122- } , [ ] ) ;
115+ const handleDuplicateTask = useCallback ( ( ) => {
116+ callbacks . onDuplicate ?.( ) ;
117+ } , [ callbacks ] ) ;
123118
124- const taskConfigMarkup = useMemo ( ( ) => {
125- const actions : Array < TooltipButtonProps > = [ ] ;
126-
127- if ( ! readOnly ) {
128- actions . push ( {
129- children : < Icon name = "Copy" size = "sm" /> ,
130- variant : "outline" ,
131- tooltip : "Duplicate Task" ,
132- onClick : callbacks . onDuplicate ,
133- } ) ;
134- }
135-
136- if ( ! readOnly && ! isCustomComponent ) {
137- actions . push ( {
138- children : < Icon name = "CircleFadingArrowUp" size = "sm" /> ,
139- variant : "outline" ,
140- tooltip : "Update Task from Source URL" ,
141- onClick : callbacks . onUpgrade ,
142- } ) ;
143- }
119+ const handleUpgradeTask = useCallback ( ( ) => {
120+ callbacks . onUpgrade ?.( ) ;
121+ } , [ callbacks ] ) ;
144122
145- if ( isSubgraphNode && taskId && isSubgraphNavigationEnabled ) {
146- actions . push ( {
147- children : < Icon name = "Workflow" size = "sm" /> ,
148- variant : "outline" ,
149- tooltip : `Enter Subgraph: ${ subgraphDescription } ` ,
150- onClick : ( ) => navigateToSubgraph ( taskId ) ,
151- } ) ;
152- }
153-
154- if ( isInAppEditorEnabled ) {
155- actions . push ( {
156- children : < Icon name = "FilePenLine" size = "sm" /> ,
157- variant : "outline" ,
158- tooltip : "Edit Component Definition" ,
159- onClick : handleEditComponent ,
160- } ) ;
123+ const handleEnterSubgraph = useCallback ( ( ) => {
124+ if ( taskId ) {
125+ navigateToSubgraph ( taskId ) ;
161126 }
127+ } , [ navigateToSubgraph , taskId ] ) ;
162128
163- return < TaskOverview taskNode = { taskNode } key = { nodeId } actions = { actions } /> ;
129+ const taskConfigMarkup = useMemo ( ( ) => {
130+ const customActions : Action [ ] = [
131+ {
132+ label : "Duplicate Task" ,
133+ icon : "Copy" ,
134+ hidden : readOnly ,
135+ onClick : handleDuplicateTask ,
136+ } ,
137+ {
138+ label : "Update Task from Source URL" ,
139+ icon : "CircleFadingArrowUp" ,
140+ hidden : readOnly || isCustomComponent ,
141+ onClick : handleUpgradeTask ,
142+ } ,
143+ {
144+ label : `Enter Subgraph: ${ subgraphDescription } ` ,
145+ icon : "Workflow" ,
146+ hidden : ! isSubgraphNode || ! isSubgraphNavigationEnabled ,
147+ onClick : handleEnterSubgraph ,
148+ } ,
149+ {
150+ label : "View YAML" ,
151+ icon : "FileCodeCorner" ,
152+ onClick : ( ) => setIsYamlFullscreen ( true ) ,
153+ } ,
154+ ] ;
155+
156+ return (
157+ < TaskOverview
158+ key = { nodeId }
159+ taskNode = { taskNode }
160+ customActions = { customActions }
161+ />
162+ ) ;
164163 } , [
165164 nodeId ,
166165 readOnly ,
167166 callbacks . onDuplicate ,
168167 callbacks . onUpgrade ,
169- isInAppEditorEnabled ,
170168 isCustomComponent ,
171169 isSubgraphNode ,
172170 taskId ,
173171 subgraphDescription ,
174172 navigateToSubgraph ,
175- handleEditComponent ,
176173 ] ) ;
177174
178175 const handleInputSectionClick = useCallback ( ( ) => {
@@ -248,6 +245,8 @@ const TaskNodeCard = () => {
248245 </ QuickTooltip >
249246 ) ;
250247
248+ const componentText = taskSpec . componentRef ?. text ;
249+
251250 return (
252251 < >
253252 < Card
@@ -333,10 +332,13 @@ const TaskNodeCard = () => {
333332 ) : null }
334333 </ CardContent >
335334 </ Card >
336- { isEditDialogOpen && (
337- < ComponentEditorDialog
338- text = { taskSpec . componentRef ?. text }
339- onClose = { handleCloseEditDialog }
335+ { isYamlFullscreen && componentText && (
336+ < CodeViewer
337+ code = { componentText }
338+ language = "yaml"
339+ filename = { name }
340+ isFullscreen = { isYamlFullscreen }
341+ onClose = { ( ) => setIsYamlFullscreen ( false ) }
340342 />
341343 ) }
342344 </ >
0 commit comments