Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ProcessSignalActions.tsx

59 lines1.4 KB

1import type { ServerProcessSignal } from "@t3tools/contracts";
2import { T, useGT, Var } from "gt-react";
3​
4import { InlineButton } from "../ui/button";
5import { SharedTooltipTrigger } from "../ui/shared-tooltip";
6​
7const SIGNAL_SHORT_NAMES = { SIGINT: "INT", SIGKILL: "KILL" } as const;
8​
9export function ProcessSignalActions({
10 disabled,
11 onSignal,
12}: {
13 disabled: boolean;
14 onSignal: (signal: ServerProcessSignal) => void;
15}) {
16 const gt = useGT();
17 return (
18 <div className="flex items-center justify-end gap-1.5">
19 <SharedTooltipTrigger
20 render={
21 <InlineButton
22 disabled={disabled}
23 aria-label={gt("Send {signal}", { signal: "SIGINT" })}
24 tone="muted"
25 onClick={() => onSignal("SIGINT")}
26 >
27 {SIGNAL_SHORT_NAMES.SIGINT}
28 </InlineButton>
29 }
30 label={
31 <>
32 <T>
33 Send <Var>{"SIGINT"}</Var>
34 </T>
35 </>
36 }
37 />
38 <SharedTooltipTrigger
39 render={
40 <InlineButton
41 disabled={disabled}
42 aria-label={gt("Send {signal}", { signal: "SIGKILL" })}
43 tone="destructive"
44 onClick={() => onSignal("SIGKILL")}
45 >
46 {SIGNAL_SHORT_NAMES.SIGKILL}
47 </InlineButton>
48 }
49 label={
50 <>
51 <T>
52 Send <Var>{"SIGKILL"}</Var>
53 </T>
54 </>
55 }
56 />
57 </div>
58 );