fix(plugin-workflow): fix manual node drawer (#1653)

This commit is contained in:
Junyi 2023-04-06 11:23:57 +07:00 committed by GitHub
parent 6f12e97f52
commit 7a4f2a011b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -97,6 +97,9 @@ export function useNodeContext() {
export function useAvailableUpstreams(node) {
const stack: any[] = [];
if (!node) {
return [];
}
for (let current = node.upstream; current; current = current.upstream) {
stack.push(current);
}

View File

@ -379,7 +379,7 @@ function useFlowRecordFromBlock(opts) {
function FlowContextProvider(props) {
const api = useAPIClient();
const { node, executionId } = useRecord();
const { id, node, executionId } = useRecord();
const [flowContext, setFlowContext] = useState<any>(null);
useEffect(() => {
@ -393,7 +393,7 @@ function FlowContextProvider(props) {
.then(({ data }) => {
const {
workflow: { nodes = [], ...workflow } = {},
...execution
execution
} = data?.data ?? {};
linkNodes(nodes);
setFlowContext({
@ -402,14 +402,14 @@ function FlowContextProvider(props) {
execution
});
});
}, [executionId]);
}, [id]);
if (!flowContext) {
return null;
}
const nodes = useAvailableUpstreams(flowContext.nodes.find(item => item.id === node.id));
const nodeComponents = nodes.reduce((components, { type }) => Object.assign(components, instructions.get(type).components), {});
const upstreams = useAvailableUpstreams(flowContext.nodes.find(item => item.id === node.id));
const nodeComponents = upstreams.reduce((components, { type }) => Object.assign(components, instructions.get(type).components), {});
return (
<FlowContext.Provider value={flowContext}>