File size: 1,140 Bytes
1acafa4
2303095
1acafa4
2303095
 
d57a1c0
 
 
 
 
 
 
2303095
 
 
 
 
 
 
 
d57a1c0
 
 
 
 
 
2303095
 
 
 
 
 
 
 
 
 
 
 
d57a1c0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import React, { useContext } from 'react';
import { Handle, Position } from 'reactflow';
import { WorkflowContext } from './App'; // Import context from App.js
import './RunNode.css';

const RunNode = ({ data, isConnectable, id }) => {
  const { handleRunFromNode, isRunning } = useContext(WorkflowContext); // Get the specific run function and running state

  // Run only this specific workflow branch
  const runThisWorkflow = () => {
    handleRunFromNode(id);
  };

  return (
    <div className="run-node">
      <div className="run-node-header">
        <strong>Run Workflow</strong>
      </div>
      <div className="run-node-content">
        <p>Connect this node to the start of your flow and click the button to begin.</p>
        <button 
          onClick={runThisWorkflow} 
          className="run-button"
          disabled={isRunning}
        >
          {isRunning ? '⏳ Running...' : '▶ Run Flow'}
        </button>
      </div>
      <Handle
        type="source"
        position={Position.Right}
        id="source-trigger"
        isConnectable={isConnectable}
      />
    </div>
  );
};

export default RunNode;