@@ -14,6 +14,7 @@ import {
1414 TriggerDefinitionApi ,
1515 WorkflowConnection ,
1616 WorkflowNodeOutput ,
17+ WorkflowTask ,
1718} from '@/shared/middleware/platform/configuration' ;
1819import { useDeleteWorkflowNodeTestOutputMutation } from '@/shared/mutations/platform/workflowNodeTestOutputs.mutations' ;
1920import {
@@ -33,6 +34,7 @@ import {useGetWorkflowTestConfigurationConnectionsQuery} from '@/shared/queries/
3334import {
3435 ComponentPropertiesType ,
3536 DataPillType ,
37+ NodeDataType ,
3638 PropertyAllType ,
3739 UpdateWorkflowMutationType ,
3840 WorkflowDefinitionType ,
@@ -50,6 +52,7 @@ import getAllTaskNames from '../utils/getAllTaskNames';
5052import getDataPillsFromProperties from '../utils/getDataPillsFromProperties' ;
5153import getParametersWithDefaultValues from '../utils/getParametersWithDefaultValues' ;
5254import saveWorkflowDefinition from '../utils/saveWorkflowDefinition' ;
55+ import updateConditionSubtask from '../utils/updateRootConditionNode' ;
5356import CurrentOperationSelect from './CurrentOperationSelect' ;
5457import ConnectionTab from './node-details-tabs/ConnectionTab' ;
5558import DescriptionTab from './node-details-tabs/DescriptionTab' ;
@@ -96,7 +99,7 @@ const WorkflowNodeDetailsPanel = ({
9699 const { currentComponent, currentNode, setCurrentComponent, setCurrentNode, workflowNodeDetailsPanelOpen} =
97100 useWorkflowNodeDetailsPanelStore ( ) ;
98101
99- const { componentActions, setDataPills, workflow} = useWorkflowDataStore ( ) ;
102+ const { componentActions, nodes , setDataPills, workflow} = useWorkflowDataStore ( ) ;
100103
101104 const { data : currentComponentDefinition } = useGetComponentDefinitionQuery (
102105 {
@@ -269,19 +272,72 @@ const WorkflowNodeDetailsPanel = ({
269272
270273 const { componentName, description, label, workflowNodeName} = currentComponent ;
271274
275+ let nodeData = {
276+ componentName,
277+ description,
278+ label,
279+ name : workflowNodeName || currentNode ?. name || '' ,
280+ operationName : newOperationName ,
281+ parameters : getParametersWithDefaultValues ( {
282+ properties : operationData . properties as Array < PropertyAllType > ,
283+ } ) ,
284+ trigger : currentNode ?. trigger ,
285+ type : `${ componentName } /v${ currentComponentDefinition . version } /${ newOperationName } ` ,
286+ } ;
287+
288+ if ( currentNode ?. conditionData ) {
289+ const parentConditionNode = nodes . find (
290+ ( node ) => node . data . name === currentNode ?. conditionData ?. conditionId
291+ ) ;
292+
293+ if ( ! parentConditionNode ) {
294+ return ;
295+ }
296+
297+ const conditionCase = currentNode . conditionData . conditionCase ;
298+ const conditionParameters : Array < WorkflowTask > = parentConditionNode . data . parameters [ conditionCase ] ;
299+
300+ if ( conditionParameters ) {
301+ const nodeIndex = conditionParameters . findIndex ( ( subtask ) => subtask . name === currentNode . name ) ;
302+
303+ if ( nodeIndex !== - 1 ) {
304+ conditionParameters [ nodeIndex ] = {
305+ ...conditionParameters [ nodeIndex ] ,
306+ type : `${ componentName } /v${ currentComponentDefinition . version } /${ newOperationName } ` ,
307+ } ;
308+
309+ if ( ! workflow . definition ) {
310+ return ;
311+ }
312+
313+ const tasks = JSON . parse ( workflow . definition ) . tasks ;
314+
315+ const updatedParentConditionTask = workflow . tasks ?. find (
316+ ( task ) => task . name === currentNode . conditionData ?. conditionId
317+ ) ;
318+
319+ if ( ! updatedParentConditionTask ) {
320+ return ;
321+ }
322+
323+ const updatedRootConditionNode = updateConditionSubtask ( {
324+ conditionCase,
325+ conditionId : currentNode . conditionData . conditionId ,
326+ nodeIndex,
327+ nodes,
328+ tasks,
329+ updatedParentConditionNodeData : parentConditionNode . data ,
330+ updatedParentConditionTask,
331+ workflow,
332+ } ) ;
333+
334+ nodeData = updatedRootConditionNode . data ?? ( updatedRootConditionNode as NodeDataType ) ;
335+ }
336+ }
337+ }
338+
272339 saveWorkflowDefinition ( {
273- nodeData : {
274- componentName,
275- description,
276- label,
277- name : workflowNodeName || currentNode ?. name || '' ,
278- operationName : newOperationName ,
279- parameters : getParametersWithDefaultValues ( {
280- properties : operationData . properties as Array < PropertyAllType > ,
281- } ) ,
282- trigger : currentNode ?. trigger ,
283- type : `${ componentName } /v${ currentComponentDefinition . version } /${ newOperationName } ` ,
284- } ,
340+ nodeData,
285341 onSuccess : ( ) => {
286342 setCurrentComponent ( {
287343 ...currentComponent ,
@@ -295,6 +351,7 @@ const WorkflowNodeDetailsPanel = ({
295351 } ) ;
296352 } ,
297353 queryClient,
354+ subtask : ! ! currentNode ?. conditionData ,
298355 updateWorkflowMutation,
299356 workflow,
300357 } ) ;
0 commit comments