|
3 | 3 | * SPDX-License-Identifier: Apache-2.0
|
4 | 4 | */
|
5 | 5 |
|
6 |
| -import { |
7 |
| - WorkspaceFlowState, |
8 |
| - Workflow, |
9 |
| - ReactFlowComponent, |
10 |
| - toTemplateFlows, |
11 |
| - validateWorkspaceFlow, |
12 |
| -} from '../../../../common'; |
| 6 | +import { Workflow, ReactFlowComponent } from '../../../../common'; |
13 | 7 |
|
14 |
| -export function saveWorkflow(workflow: Workflow, rfInstance: any): void { |
15 |
| - let curFlowState = rfInstance.toObject(); |
16 |
| - |
17 |
| - curFlowState = { |
18 |
| - ...curFlowState, |
19 |
| - nodes: processNodes(curFlowState.nodes), |
20 |
| - }; |
21 |
| - |
22 |
| - const isValid = validateWorkspaceFlow(curFlowState); |
23 |
| - if (isValid) { |
24 |
| - const updatedWorkflow = { |
25 |
| - ...workflow, |
26 |
| - workspaceFlowState: curFlowState, |
27 |
| - workflows: toTemplateFlows(curFlowState), |
28 |
| - } as Workflow; |
29 |
| - if (workflow.id) { |
30 |
| - // TODO: implement connection to update workflow API |
31 |
| - } else { |
32 |
| - // TODO: implement connection to create workflow API |
33 |
| - } |
| 8 | +export function saveWorkflow(workflow?: Workflow): void { |
| 9 | + if (workflow && workflow.id) { |
| 10 | + // TODO: implement connection to update workflow API |
34 | 11 | } else {
|
35 |
| - return; |
| 12 | + // TODO: implement connection to create workflow API |
36 | 13 | }
|
37 | 14 | }
|
38 | 15 |
|
39 | 16 | // Process the raw ReactFlow nodes to only persist the fields we need
|
40 |
| -function processNodes(nodes: ReactFlowComponent[]): ReactFlowComponent[] { |
| 17 | +export function processNodes( |
| 18 | + nodes: ReactFlowComponent[] |
| 19 | +): ReactFlowComponent[] { |
41 | 20 | return nodes
|
42 | 21 | .map((node: ReactFlowComponent) => {
|
43 | 22 | return Object.fromEntries(
|
|
0 commit comments