- {activeTab === 'description' && (
-
- )}
+ {activeTab === 'description' &&
+ (nodeDefinition ? (
+
+ ) : (
+
+ ))}
{activeTab === 'dataStreamComponents' &&
}
diff --git a/client/src/pages/platform/workflow-editor/components/node-details-tabs/DescriptionTab.tsx b/client/src/pages/platform/workflow-editor/components/node-details-tabs/DescriptionTab.tsx
index 4492b3538a7..5738f91c5b2 100644
--- a/client/src/pages/platform/workflow-editor/components/node-details-tabs/DescriptionTab.tsx
+++ b/client/src/pages/platform/workflow-editor/components/node-details-tabs/DescriptionTab.tsx
@@ -3,37 +3,127 @@ import {Label} from '@/components/ui/label';
import {Textarea} from '@/components/ui/textarea';
import useWorkflowDataStore from '@/pages/platform/workflow-editor/stores/useWorkflowDataStore';
import useWorkflowNodeDetailsPanelStore from '@/pages/platform/workflow-editor/stores/useWorkflowNodeDetailsPanelStore';
-import {ComponentType, UpdateWorkflowMutationType} from '@/shared/types';
+import {WorkflowTask} from '@/shared/middleware/automation/configuration';
+import {
+ ComponentDefinition,
+ TaskDispatcherDefinition,
+ TriggerDefinition,
+} from '@/shared/middleware/platform/configuration';
+import {NodeDataType, UpdateWorkflowMutationType} from '@/shared/types';
import {useQueryClient} from '@tanstack/react-query';
import {ChangeEvent} from 'react';
import {useDebouncedCallback} from 'use-debounce';
import saveWorkflowDefinition from '../../utils/saveWorkflowDefinition';
+import updateRootConditionNode from '../../utils/updateRootConditionNode';
-const DescriptionTab = ({updateWorkflowMutation}: {updateWorkflowMutation: UpdateWorkflowMutationType}) => {
- const {workflow} = useWorkflowDataStore();
- const {currentComponent, currentNode, setCurrentComponent} = useWorkflowNodeDetailsPanelStore();
+const DescriptionTab = ({
+ nodeDefinition,
+ updateWorkflowMutation,
+}: {
+ nodeDefinition: ComponentDefinition | TaskDispatcherDefinition | TriggerDefinition;
+ updateWorkflowMutation: UpdateWorkflowMutationType;
+}) => {
+ const {nodes, workflow} = useWorkflowDataStore();
+ const {currentComponent, currentNode, setCurrentComponent, setCurrentNode} = useWorkflowNodeDetailsPanelStore();
const queryClient = useQueryClient();
- const componentData: ComponentType = {
- ...currentComponent!,
- workflowNodeName: currentNode!.workflowNodeName,
+ const updateNodeData = (value: string, field: 'label' | 'description'): NodeDataType | undefined => {
+ if (!currentNode) {
+ return;
+ }
+
+ let nodeData = {
+ ...currentNode!,
+ [field]: value,
+ name: currentNode.workflowNodeName,
+ };
+
+ if (currentNode.conditionData) {
+ const parentConditionNode = nodes.find(
+ (node) => node.data.name === currentNode?.conditionData?.conditionId
+ );
+
+ if (!parentConditionNode) {
+ return;
+ }
+
+ const conditionCase = currentNode.conditionData.conditionCase;
+ const conditionParameters: Array
= parentConditionNode.data.parameters[conditionCase];
+
+ if (conditionParameters) {
+ const taskIndex = conditionParameters.findIndex((subtask) => subtask.name === currentNode.name);
+
+ if (taskIndex !== -1) {
+ conditionParameters[taskIndex] = {
+ ...conditionParameters[taskIndex],
+ [field]: value,
+ };
+
+ if (!workflow.definition) {
+ return;
+ }
+
+ const tasks = JSON.parse(workflow.definition).tasks;
+
+ const updatedParentConditionTask = workflow.tasks?.find(
+ (task) => task.name === currentNode.conditionData?.conditionId
+ );
+
+ if (!updatedParentConditionTask) {
+ return;
+ }
+
+ nodeData = updateRootConditionNode({
+ conditionCase,
+ conditionId: currentNode.conditionData.conditionId,
+ nodeIndex: taskIndex,
+ nodes,
+ tasks,
+ updatedParentConditionNodeData: parentConditionNode.data,
+ updatedParentConditionTask,
+ workflow,
+ });
+ }
+ }
+ }
+
+ return nodeData;
};
const handleLabelChange = useDebouncedCallback((event: ChangeEvent) => {
- if (!currentComponent || !currentNode) {
+ if (!currentNode) {
return;
}
+ let nodeData: NodeDataType = {
+ ...currentNode,
+ label: event.target.value,
+ name: currentNode.workflowNodeName,
+ version: 'version' in nodeDefinition ? nodeDefinition.version : 1,
+ };
+
+ if (currentNode.conditionData) {
+ nodeData = updateNodeData(event.target.value, 'label') ?? nodeData;
+ }
+
saveWorkflowDefinition({
decorative: true,
- nodeData: {...currentComponent!, label: event.target.value, name: currentComponent.workflowNodeName},
- onSuccess: () =>
+ nodeData,
+ onSuccess: () => {
setCurrentComponent({
...currentComponent,
+ componentName: currentNode.componentName,
+ label: event.target.value,
+ workflowNodeName: currentNode.workflowNodeName,
+ });
+
+ setCurrentNode({
+ ...currentNode,
label: event.target.value,
- }),
+ });
+ },
queryClient,
updateWorkflowMutation,
workflow,
@@ -41,18 +131,37 @@ const DescriptionTab = ({updateWorkflowMutation}: {updateWorkflowMutation: Updat
}, 200);
const handleNotesChange = useDebouncedCallback((event: ChangeEvent) => {
- if (!currentComponent || !currentNode) {
+ if (!currentNode) {
return;
}
+ let nodeData: NodeDataType = {
+ ...currentNode,
+ description: event.target.value,
+ name: currentNode.workflowNodeName,
+ version: 'version' in nodeDefinition ? nodeDefinition.version : 1,
+ };
+
+ if (currentNode.conditionData) {
+ nodeData = updateNodeData(event.target.value, 'description') ?? nodeData;
+ }
+
saveWorkflowDefinition({
decorative: true,
- nodeData: {...componentData, description: event.target.value, name: currentComponent.workflowNodeName},
- onSuccess: () =>
+ nodeData,
+ onSuccess: () => {
setCurrentComponent({
...currentComponent,
+ componentName: currentNode.componentName,
+ description: event.target.value,
+ workflowNodeName: currentNode.workflowNodeName,
+ });
+
+ setCurrentNode({
+ ...currentNode,
description: event.target.value,
- }),
+ });
+ },
queryClient,
updateWorkflowMutation,
workflow,
@@ -65,8 +174,8 @@ const DescriptionTab = ({updateWorkflowMutation}: {updateWorkflowMutation: Updat
@@ -76,8 +185,8 @@ const DescriptionTab = ({updateWorkflowMutation}: {updateWorkflowMutation: Updat