fix(plugin-workflow): fix manual node drawer (#1653)
This commit is contained in:
parent
6f12e97f52
commit
7a4f2a011b
@ -97,6 +97,9 @@ export function useNodeContext() {
|
|||||||
|
|
||||||
export function useAvailableUpstreams(node) {
|
export function useAvailableUpstreams(node) {
|
||||||
const stack: any[] = [];
|
const stack: any[] = [];
|
||||||
|
if (!node) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
for (let current = node.upstream; current; current = current.upstream) {
|
for (let current = node.upstream; current; current = current.upstream) {
|
||||||
stack.push(current);
|
stack.push(current);
|
||||||
}
|
}
|
||||||
|
@ -379,7 +379,7 @@ function useFlowRecordFromBlock(opts) {
|
|||||||
|
|
||||||
function FlowContextProvider(props) {
|
function FlowContextProvider(props) {
|
||||||
const api = useAPIClient();
|
const api = useAPIClient();
|
||||||
const { node, executionId } = useRecord();
|
const { id, node, executionId } = useRecord();
|
||||||
const [flowContext, setFlowContext] = useState<any>(null);
|
const [flowContext, setFlowContext] = useState<any>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -393,7 +393,7 @@ function FlowContextProvider(props) {
|
|||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
const {
|
const {
|
||||||
workflow: { nodes = [], ...workflow } = {},
|
workflow: { nodes = [], ...workflow } = {},
|
||||||
...execution
|
execution
|
||||||
} = data?.data ?? {};
|
} = data?.data ?? {};
|
||||||
linkNodes(nodes);
|
linkNodes(nodes);
|
||||||
setFlowContext({
|
setFlowContext({
|
||||||
@ -402,14 +402,14 @@ function FlowContextProvider(props) {
|
|||||||
execution
|
execution
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, [executionId]);
|
}, [id]);
|
||||||
|
|
||||||
if (!flowContext) {
|
if (!flowContext) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const nodes = useAvailableUpstreams(flowContext.nodes.find(item => item.id === node.id));
|
const upstreams = useAvailableUpstreams(flowContext.nodes.find(item => item.id === node.id));
|
||||||
const nodeComponents = nodes.reduce((components, { type }) => Object.assign(components, instructions.get(type).components), {});
|
const nodeComponents = upstreams.reduce((components, { type }) => Object.assign(components, instructions.get(type).components), {});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FlowContext.Provider value={flowContext}>
|
<FlowContext.Provider value={flowContext}>
|
||||||
|
Loading…
Reference in New Issue
Block a user