File size: 1,436 Bytes
cd6f98e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
40
41
42
43
44
45
46
47
48
49
import clsx from "clsx";
import React from "react";
import { FaPause, FaPlay, FaStop, FaUndo } from "react-icons/fa";
import { ImSpinner2 } from "react-icons/im";

import type { AgentLifecycle } from "../../services/agent/agent-run-model";
import Button from "../Button";

type AgentControlsProps = {
  disablePlay: boolean;
  lifecycle: AgentLifecycle;
  handlePlay: () => void;
  handlePause: () => void;
  handleStop: () => void;
};
const AgentControls = ({
  lifecycle,
  disablePlay,
  handlePlay,
  handlePause,
  handleStop,
}: AgentControlsProps) => {
  return (
    <div className="flex gap-2">
      <Button ping={!disablePlay} disabled={disablePlay} onClick={handlePlay}>
        {lifecycle === "running" && <ImSpinner2 className="animate-spin" />}
        {lifecycle === "stopped" && <FaUndo />}
        {!["running", "stopped"].includes(lifecycle || "") && <FaPlay />}
      </Button>
      <Button
        disabled={lifecycle !== "running"}
        onClick={handlePause}
        enabledClassName={clsx("bg-yellow-600 hover:bg-yellow-400")}
      >
        {lifecycle === "pausing" ? <ImSpinner2 className="animate-spin" /> : <FaPause />}
      </Button>
      <Button
        disabled={lifecycle === "offline" || lifecycle == "stopped"}
        onClick={handleStop}
        enabledClassName={clsx("bg-red-600 hover:bg-red-400")}
      >
        <FaStop />
      </Button>
    </div>
  );
};

export default AgentControls;