Skip to content

Commit 0139741

Browse files
2867 - typecheck. this probably needs to be looked into and changed!!!
1 parent 1167a26 commit 0139741

File tree

4 files changed

+38
-19
lines changed

4 files changed

+38
-19
lines changed

client/src/pages/platform/workflow-editor/utils/clusterElementsFieldChangeUtils.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ type FieldUpdateType = {
1212
interface CreateUpdatedElementProps {
1313
currentComponentDefinition: ComponentDefinition;
1414
currentOperationProperties?: Array<PropertyAllType>;
15-
element: ClusterElementItemType | NodeDataType;
15+
element:
16+
| ClusterElementItemType
17+
| NodeDataType
18+
| (Omit<NodeDataType, 'componentName' | 'workflowNodeName'> & {
19+
componentName?: string;
20+
workflowNodeName?: string;
21+
});
1622
fieldUpdate: FieldUpdateType;
1723
}
1824

@@ -59,7 +65,10 @@ interface UpdateClusterRootElementFieldProps {
5965
currentComponentDefinition: ComponentDefinition;
6066
currentOperationProperties?: Array<PropertyAllType>;
6167
fieldUpdate: FieldUpdateType;
62-
mainRootElement: NodeDataType;
68+
mainRootElement: Omit<NodeDataType, 'componentName' | 'workflowNodeName'> & {
69+
componentName?: string;
70+
workflowNodeName?: string;
71+
};
6372
}
6473

6574
export function updateClusterRootElementField({
@@ -78,9 +87,9 @@ export function updateClusterRootElementField({
7887
return {
7988
...mainRootElement,
8089
...updatedElementData,
81-
componentName: mainRootElement.componentName,
90+
...(mainRootElement.componentName ? {componentName: mainRootElement.componentName} : {}),
8291
name: mainRootElement.name,
83-
workflowNodeName: mainRootElement.workflowNodeName,
92+
...(mainRootElement.workflowNodeName ? {workflowNodeName: mainRootElement.workflowNodeName} : {}),
8493
};
8594
}
8695

client/src/pages/platform/workflow-editor/utils/handleComponentAddedSuccess.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ import useWorkflowNodeDetailsPanelStore from '@/pages/platform/workflow-editor/s
22
import {Workflow} from '@/shared/middleware/platform/configuration';
33
import {WorkflowNodeOutputKeys} from '@/shared/queries/platform/workflowNodeOutputs.queries';
44
import {environmentStore} from '@/shared/stores/useEnvironmentStore';
5-
import {NodeDataType} from '@/shared/types';
5+
import {ComponentType, NodeDataType} from '@/shared/types';
66
import {QueryClient} from '@tanstack/react-query';
77

88
interface HandleComponentAddedSuccessProps {
9-
nodeData: NodeDataType;
9+
nodeData: Omit<NodeDataType, 'componentName' | 'workflowNodeName'> & {
10+
componentName?: string;
11+
workflowNodeName?: string;
12+
};
1013
queryClient: QueryClient;
1114
workflow: Workflow;
1215
}
@@ -33,12 +36,12 @@ export default function handleComponentAddedSuccess({
3336

3437
if (useWorkflowNodeDetailsPanelStore.getState().workflowNodeDetailsPanelOpen) {
3538
if (currentNode?.trigger && nodeData.trigger) {
36-
setCurrentNode({...currentNode, ...nodeData});
37-
setCurrentComponent({...currentComponent, ...nodeData});
39+
setCurrentNode({...currentNode, ...nodeData} as NodeDataType);
40+
setCurrentComponent({...currentComponent, ...nodeData} as ComponentType);
3841
}
3942
} else if (!nodeData.clusterElements) {
40-
setCurrentNode({...nodeData, description: ''});
41-
setCurrentComponent({...nodeData, description: ''});
43+
setCurrentNode({...nodeData, description: ''} as NodeDataType);
44+
setCurrentComponent({...nodeData, description: ''} as ComponentType);
4245
setWorkflowNodeDetailsPanelOpen(true);
4346
}
4447
}

client/src/pages/platform/workflow-editor/utils/saveClusterElementFieldChange.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {ComponentDefinition, Workflow} from '@/shared/middleware/platform/configuration';
2-
import {ClusterElementsType, NodeDataType, PropertyAllType} from '@/shared/types';
2+
import {ClusterElementsType, ComponentType, NodeDataType, PropertyAllType} from '@/shared/types';
33
import {UseMutationResult} from '@tanstack/react-query';
44

55
import useWorkflowDataStore from '../stores/useWorkflowDataStore';
@@ -49,15 +49,15 @@ export default function saveClusterElementFieldChange({
4949
tasks: workflowDefinitionTasks,
5050
})
5151
: undefined;
52-
// const mainClusterRootTask = workflowDefinitionTasks?.find(
53-
// (task: {name: string}) => task.name === rootClusterElementNodeData?.workflowNodeName
54-
// );
5552

5653
if (!mainClusterRootTask) {
5754
return;
5855
}
5956

60-
let updatedMainRootData: NodeDataType;
57+
let updatedMainRootData: Omit<NodeDataType, 'componentName' | 'workflowNodeName'> & {
58+
componentName?: string;
59+
workflowNodeName?: string;
60+
};
6161
let updatedClusterElements: ClusterElementsType;
6262

6363
if (
@@ -104,7 +104,11 @@ export default function saveClusterElementFieldChange({
104104
invalidateWorkflowQueries,
105105
nodeData: updatedMainRootData,
106106
onSuccess: () => {
107-
let commonUpdates: NodeDataType = {
107+
let commonUpdates: Omit<NodeDataType, 'componentName' | 'workflowNodeName'> & {
108+
componentName?: string;
109+
name: string;
110+
workflowNodeName?: string;
111+
} = {
108112
componentName,
109113
name,
110114
workflowNodeName,
@@ -134,12 +138,12 @@ export default function saveClusterElementFieldChange({
134138
setCurrentNode({
135139
...currentNode,
136140
...commonUpdates,
137-
});
141+
} as NodeDataType);
138142

139143
setCurrentComponent({
140144
...currentComponent,
141145
...commonUpdates,
142-
});
146+
} as ComponentType);
143147

144148
if (rootClusterElementNodeData) {
145149
if (currentNode.clusterRoot && !currentNode.isNestedClusterRoot) {

client/src/pages/platform/workflow-editor/utils/saveWorkflowDefinition.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@ type UpdateWorkflowRequestType = {
1717
interface SaveWorkflowDefinitionProps {
1818
decorative?: boolean;
1919
invalidateWorkflowQueries: () => void;
20-
nodeData?: NodeDataType;
20+
nodeData?: Omit<NodeDataType, 'componentName' | 'workflowNodeName'> & {
21+
componentName?: string;
22+
workflowNodeName?: string;
23+
};
2124
nodeIndex?: number;
2225
onSuccess?: () => void;
2326
placeholderId?: string;

0 commit comments

Comments
 (0)