Skip to content

Commit 1f5b202

Browse files
committed
1859 - DescriptionTab improvements - handling for Condition and its children
1 parent 5622cb4 commit 1f5b202

File tree

2 files changed

+78
-56
lines changed

2 files changed

+78
-56
lines changed

client/src/pages/platform/workflow-editor/components/WorkflowNodeDetailsPanel.tsx

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,7 @@ import {
3030
import {WorkflowNodeDynamicPropertyKeys} from '@/shared/queries/platform/workflowNodeDynamicProperties.queries';
3131
import {WorkflowNodeOptionKeys} from '@/shared/queries/platform/workflowNodeOptions.queries';
3232
import {useGetWorkflowTestConfigurationConnectionsQuery} from '@/shared/queries/platform/workflowTestConfigurations.queries';
33-
import {
34-
ComponentPropertiesType,
35-
DataPillType,
36-
NodeDataType,
37-
PropertyAllType,
38-
UpdateWorkflowMutationType,
39-
} from '@/shared/types';
33+
import {ComponentPropertiesType, NodeDataType, PropertyAllType, UpdateWorkflowMutationType} from '@/shared/types';
4034
import {Cross2Icon, InfoCircledIcon} from '@radix-ui/react-icons';
4135
import {TooltipPortal} from '@radix-ui/react-tooltip';
4236
import {useQueryClient} from '@tanstack/react-query';
@@ -362,6 +356,11 @@ const WorkflowNodeDetailsPanel = ({
362356
useWorkflowNodeDetailsPanelStore.getState().reset();
363357
};
364358

359+
const nodeDefinition = currentComponentDefinition || currentTaskDispatcherDefinition || currentTriggerDefinition;
360+
361+
const currentTaskDataOperations =
362+
(currentTaskData as ComponentDefinition)?.actions ?? (currentTaskData as ComponentDefinition)?.triggers;
363+
365364
// Set currentOperationProperties depending if the current node is a trigger or an action
366365
useEffect(() => {
367366
if (currentNodeDefinition?.properties) {
@@ -534,33 +533,31 @@ const WorkflowNodeDetailsPanel = ({
534533
</header>
535534

536535
<main className="flex h-full flex-col">
537-
{operationDataMissing && (
536+
{!!currentTaskDataOperations?.length && operationDataMissing && (
538537
<div className="flex flex-col border-b border-muted p-4">
539538
<span className="text-sm leading-6">Actions</span>
540539

541540
<Skeleton className="h-9 w-full" />
542541
</div>
543542
)}
544543

545-
{(!!(currentTaskData as ComponentDefinition).actions?.length ||
546-
!!(currentTaskData as ComponentDefinition).triggers?.length) &&
547-
!operationDataMissing && (
548-
<CurrentOperationSelect
549-
description={
550-
currentNode?.trigger
551-
? currentTriggerDefinition?.description
552-
: currentActionDefinition?.description
553-
}
554-
handleValueChange={handleOperationSelectChange}
555-
operations={
556-
(currentNode?.trigger
557-
? currentComponentDefinition?.triggers
558-
: currentComponentDefinition?.actions)!
559-
}
560-
triggerSelect={currentNode?.trigger}
561-
value={currentOperationName}
562-
/>
563-
)}
544+
{currentTaskDataOperations && !operationDataMissing && (
545+
<CurrentOperationSelect
546+
description={
547+
currentNode?.trigger
548+
? currentTriggerDefinition?.description
549+
: currentActionDefinition?.description
550+
}
551+
handleValueChange={handleOperationSelectChange}
552+
operations={
553+
(currentNode?.trigger
554+
? currentComponentDefinition?.triggers
555+
: currentComponentDefinition?.actions)!
556+
}
557+
triggerSelect={currentNode?.trigger}
558+
value={currentOperationName}
559+
/>
560+
)}
564561

565562
{tabDataExists && (
566563
<div className="flex justify-center">
@@ -596,12 +593,28 @@ const WorkflowNodeDetailsPanel = ({
596593
<div className="relative h-full overflow-y-scroll">
597594
{currentTaskData && (
598595
<div className="absolute left-0 top-0 size-full">
599-
{activeTab === 'description' && (
600-
<DescriptionTab
601-
key={`${currentNode?.workflowNodeName}_description`}
602-
updateWorkflowMutation={updateWorkflowMutation}
603-
/>
604-
)}
596+
{activeTab === 'description' &&
597+
(nodeDefinition ? (
598+
<DescriptionTab
599+
key={`${currentNode?.workflowNodeName}_description`}
600+
nodeDefinition={nodeDefinition}
601+
updateWorkflowMutation={updateWorkflowMutation}
602+
/>
603+
) : (
604+
<div className="flex flex-col gap-y-4 p-4">
605+
<div className="flex flex-col gap-y-2">
606+
<Skeleton className="h-6 w-1/4" />
607+
608+
<Skeleton className="h-8 w-full" />
609+
</div>
610+
611+
<div className="flex flex-col gap-y-2">
612+
<Skeleton className="h-6 w-1/4" />
613+
614+
<Skeleton className="h-24 w-full" />
615+
</div>
616+
</div>
617+
))}
605618

606619
{activeTab === 'dataStreamComponents' && <DataStreamComponentsTab />}
607620

client/src/pages/platform/workflow-editor/components/node-details-tabs/DescriptionTab.tsx

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,40 @@ import {Textarea} from '@/components/ui/textarea';
44
import useWorkflowDataStore from '@/pages/platform/workflow-editor/stores/useWorkflowDataStore';
55
import useWorkflowNodeDetailsPanelStore from '@/pages/platform/workflow-editor/stores/useWorkflowNodeDetailsPanelStore';
66
import {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';
813
import {useQueryClient} from '@tanstack/react-query';
914
import {ChangeEvent} from 'react';
1015
import {useDebouncedCallback} from 'use-debounce';
1116

1217
import saveWorkflowDefinition from '../../utils/saveWorkflowDefinition';
1318
import 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

Comments
 (0)