|
1
|
"use client" |
|
2
|
|
|
3
|
import React, { Suspense } from "react" |
|
4
|
import { Workflow } from "types" |
|
5
|
import { Loading } from "@/components/Loading" |
|
6
|
import { WorkflowDiagramCanvas } from "./Canvas" |
|
7
|
import { WorkflowDiagramList } from "./List" |
|
8
|
|
|
9
|
export type WorkflowDiagramCommonOptionsProps = { |
|
10
|
hideLegend?: boolean |
|
11
|
} |
|
12
|
|
|
13
|
export type WorkflowDiagramCommonProps = { |
|
14
|
workflow: Workflow |
|
15
|
} & WorkflowDiagramCommonOptionsProps |
|
16
|
|
|
17
|
export type WorkflowDiagramType = "canvas" | "list" |
|
18
|
|
|
19
|
export type WorkflowDiagramProps = WorkflowDiagramCommonProps & { |
|
20
|
type?: WorkflowDiagramType |
|
21
|
} |
|
22
|
|
|
23
|
export const WorkflowDiagram = ({ |
|
24
|
type = "list", |
|
25
|
...props |
|
26
|
}: WorkflowDiagramProps) => { |
|
27
|
return ( |
|
28
|
<Suspense fallback={<Loading />}> |
|
29
|
{type === "canvas" && <WorkflowDiagramCanvas {...props} />} |
|
30
|
{type === "list" && <WorkflowDiagramList {...props} />} |
|
31
|
</Suspense> |
|
32
|
) |
|
33
|
} |