@@ -4,34 +4,40 @@ import {Textarea} from '@/components/ui/textarea';
44import useWorkflowDataStore from '@/pages/platform/workflow-editor/stores/useWorkflowDataStore' ;
55import useWorkflowNodeDetailsPanelStore from '@/pages/platform/workflow-editor/stores/useWorkflowNodeDetailsPanelStore' ;
66import { WorkflowTask } from '@/shared/middleware/automation/configuration' ;
7- import { ComponentType , NodeDataType , UpdateWorkflowMutationType } from '@/shared/types' ;
7+ import {
8+ ComponentDefinition ,
9+ TaskDispatcherDefinition ,
10+ TriggerDefinition ,
11+ } from '@/shared/middleware/platform/configuration' ;
12+ import { NodeDataType , UpdateWorkflowMutationType } from '@/shared/types' ;
813import { useQueryClient } from '@tanstack/react-query' ;
914import { ChangeEvent } from 'react' ;
1015import { useDebouncedCallback } from 'use-debounce' ;
1116
1217import saveWorkflowDefinition from '../../utils/saveWorkflowDefinition' ;
1318import updateRootConditionNode from '../../utils/updateRootConditionNode' ;
1419
15- const DescriptionTab = ( { updateWorkflowMutation} : { updateWorkflowMutation : UpdateWorkflowMutationType } ) => {
20+ const DescriptionTab = ( {
21+ nodeDefinition,
22+ updateWorkflowMutation,
23+ } : {
24+ nodeDefinition : ComponentDefinition | TaskDispatcherDefinition | TriggerDefinition ;
25+ updateWorkflowMutation : UpdateWorkflowMutationType ;
26+ } ) => {
1627 const { nodes, workflow} = useWorkflowDataStore ( ) ;
1728 const { currentComponent, currentNode, setCurrentComponent, setCurrentNode} = useWorkflowNodeDetailsPanelStore ( ) ;
1829
1930 const queryClient = useQueryClient ( ) ;
2031
21- const componentData : ComponentType = {
22- ...currentComponent ! ,
23- workflowNodeName : currentNode ! . workflowNodeName ,
24- } ;
25-
2632 const updateNodeData = ( value : string , field : 'label' | 'description' ) : NodeDataType | undefined => {
27- if ( ! currentComponent || ! currentNode ) {
33+ if ( ! currentNode ) {
2834 return ;
2935 }
3036
3137 let nodeData = {
32- ...currentComponent ! ,
38+ ...currentNode ! ,
3339 [ field ] : value ,
34- name : currentComponent . workflowNodeName ,
40+ name : currentNode . workflowNodeName ,
3541 } ;
3642
3743 if ( currentNode . conditionData ) {
@@ -79,8 +85,6 @@ const DescriptionTab = ({updateWorkflowMutation}: {updateWorkflowMutation: Updat
7985 updatedParentConditionTask,
8086 workflow,
8187 } ) ;
82-
83- console . log ( 'nodeData' , nodeData ) ;
8488 }
8589 }
8690 }
@@ -89,28 +93,30 @@ const DescriptionTab = ({updateWorkflowMutation}: {updateWorkflowMutation: Updat
8993 } ;
9094
9195 const handleLabelChange = useDebouncedCallback ( ( event : ChangeEvent < HTMLInputElement > ) => {
92- if ( ! currentComponent || ! currentNode ) {
96+ if ( ! currentNode ) {
9397 return ;
9498 }
9599
96100 let nodeData : NodeDataType = {
97- ...currentComponent ! ,
101+ ...currentNode ,
98102 label : event . target . value ,
99- name : currentComponent . workflowNodeName ,
103+ name : currentNode . workflowNodeName ,
104+ version : 'version' in nodeDefinition ? nodeDefinition . version : 1 ,
100105 } ;
101106
102107 if ( currentNode . conditionData ) {
103108 nodeData = updateNodeData ( event . target . value , 'label' ) ?? nodeData ;
104109 }
105110
106- console . log ( 'currentNode before save: ' , currentNode ) ;
107111 saveWorkflowDefinition ( {
108112 decorative : true ,
109113 nodeData,
110114 onSuccess : ( ) => {
111115 setCurrentComponent ( {
112116 ...currentComponent ,
117+ componentName : currentNode . componentName ,
113118 label : event . target . value ,
119+ workflowNodeName : currentNode . workflowNodeName ,
114120 } ) ;
115121
116122 setCurrentNode ( {
@@ -125,14 +131,15 @@ const DescriptionTab = ({updateWorkflowMutation}: {updateWorkflowMutation: Updat
125131 } , 200 ) ;
126132
127133 const handleNotesChange = useDebouncedCallback ( ( event : ChangeEvent < HTMLTextAreaElement > ) => {
128- if ( ! currentComponent || ! currentNode ) {
134+ if ( ! currentNode ) {
129135 return ;
130136 }
131137
132138 let nodeData : NodeDataType = {
133- ...componentData ,
139+ ...currentNode ,
134140 description : event . target . value ,
135- name : currentComponent . workflowNodeName ,
141+ name : currentNode . workflowNodeName ,
142+ version : 'version' in nodeDefinition ? nodeDefinition . version : 1 ,
136143 } ;
137144
138145 if ( currentNode . conditionData ) {
@@ -145,7 +152,9 @@ const DescriptionTab = ({updateWorkflowMutation}: {updateWorkflowMutation: Updat
145152 onSuccess : ( ) => {
146153 setCurrentComponent ( {
147154 ...currentComponent ,
155+ componentName : currentNode . componentName ,
148156 description : event . target . value ,
157+ workflowNodeName : currentNode . workflowNodeName ,
149158 } ) ;
150159
151160 setCurrentNode ( {
@@ -165,8 +174,8 @@ const DescriptionTab = ({updateWorkflowMutation}: {updateWorkflowMutation: Updat
165174 < Label > Title</ Label >
166175
167176 < Input
168- defaultValue = { currentComponent ?. label }
169- key = { `${ currentComponent ?. componentName } _nodeTitle` }
177+ defaultValue = { currentNode ?. label }
178+ key = { `${ currentNode ?. componentName } _nodeTitle` }
170179 name = "nodeTitle"
171180 onChange = { handleLabelChange }
172181 />
@@ -176,8 +185,8 @@ const DescriptionTab = ({updateWorkflowMutation}: {updateWorkflowMutation: Updat
176185 < Label > Notes</ Label >
177186
178187 < Textarea
179- defaultValue = { currentComponent ?. description || '' }
180- key = { `${ currentComponent ?. componentName } _nodeNotes` }
188+ defaultValue = { currentNode ?. description || '' }
189+ key = { `${ currentNode ?. componentName } _nodeNotes` }
181190 name = "nodeNotes"
182191 onChange = { handleNotesChange }
183192 placeholder = "Write some notes for yourself..."
0 commit comments