2023-04-25 13:12:14 +08:00
|
|
|
import React from 'react';
|
2022-10-30 11:54:14 +08:00
|
|
|
import { cx } from '@emotion/css';
|
2023-04-25 13:12:14 +08:00
|
|
|
import { branchClass } from './style';
|
|
|
|
import { AddButton } from './AddButton';
|
2022-10-30 11:54:14 +08:00
|
|
|
import { Node } from './nodes';
|
|
|
|
|
|
|
|
export function Branch({
|
|
|
|
from = null,
|
|
|
|
entry = null,
|
|
|
|
branchIndex = null,
|
2023-04-25 13:12:14 +08:00
|
|
|
controller = null,
|
2023-02-20 11:52:06 +08:00
|
|
|
}: {
|
|
|
|
from?: any;
|
|
|
|
entry?: any;
|
|
|
|
branchIndex?: number | null;
|
2023-04-25 13:12:14 +08:00
|
|
|
controller?: any;
|
2022-10-30 11:54:14 +08:00
|
|
|
}) {
|
2023-02-20 11:52:06 +08:00
|
|
|
const list: any[] = [];
|
2022-10-30 11:54:14 +08:00
|
|
|
for (let node = entry; node; node = node.downstream) {
|
|
|
|
list.push(node);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={cx(branchClass)}>
|
|
|
|
<div className="workflow-branch-lines" />
|
|
|
|
{controller}
|
|
|
|
<AddButton upstream={from} branchIndex={branchIndex} />
|
|
|
|
<div className="workflow-node-list">
|
2023-04-25 13:12:14 +08:00
|
|
|
{list.map((item) => (
|
|
|
|
<Node data={item} key={item.id} />
|
|
|
|
))}
|
2022-10-30 11:54:14 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|