refactor(web): share diagnostic process actions (#12358)
This commit is contained in:
1 parent
a1390ac655
commit
6088c8104c
3 files changed
+53
-66
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import { ProcessSignalActions } from "./ProcessSignalActions";
|
||||
import { RefreshIcon } from "~/components/ui/refresh-icon";
|
||||
import {
|
||||
AlertTriangleIcon,
|
||||
@@ -309,51 +310,6 @@ function ProcessNameCell({
|
||||
);
|
||||
}
|
||||
|
||||
function ProcessSignalActions({
|
||||
process,
|
||||
isSignaling,
|
||||
onSignal,
|
||||
}: {
|
||||
process: ServerProcessDiagnosticsEntry;
|
||||
isSignaling: boolean;
|
||||
onSignal: (pid: number, signal: ServerProcessSignal) => void;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex items-center justify-end gap-1.5">
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<button
|
||||
type="button"
|
||||
disabled={isSignaling}
|
||||
className="cursor-pointer text-[11px] font-medium text-muted-foreground underline-offset-2 hover:text-foreground hover:underline disabled:pointer-events-none disabled:opacity-50"
|
||||
onClick={() => onSignal(process.pid, "SIGINT")}
|
||||
>
|
||||
INT
|
||||
</button>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">Send SIGINT</TooltipPopup>
|
||||
</Tooltip>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<button
|
||||
type="button"
|
||||
disabled={isSignaling}
|
||||
className="cursor-pointer text-[11px] font-medium text-destructive underline-offset-2 hover:underline disabled:pointer-events-none disabled:opacity-50"
|
||||
onClick={() => onSignal(process.pid, "SIGKILL")}
|
||||
>
|
||||
KILL
|
||||
</button>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">Send SIGKILL</TooltipPopup>
|
||||
</Tooltip>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ProcessDiagnosticsTable({
|
||||
processes,
|
||||
signalingPid,
|
||||
@@ -469,9 +425,8 @@ function ProcessDiagnosticsTable({
|
||||
</td>
|
||||
<td className="p-2 align-middle sm:pr-4">
|
||||
<ProcessSignalActions
|
||||
process={process}
|
||||
isSignaling={signalingPid === process.pid}
|
||||
onSignal={onSignal}
|
||||
disabled={signalingPid === process.pid}
|
||||
onSignal={(signal) => onSignal(process.pid, signal)}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
import type { ServerProcessSignal } from "@t3tools/contracts";
|
||||
|
||||
import { InlineButton } from "../ui/button";
|
||||
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
|
||||
|
||||
/** Process ownership and confirmation stay with the diagnostics view. */
|
||||
export function ProcessSignalActions({
|
||||
disabled,
|
||||
onSignal,
|
||||
}: {
|
||||
disabled: boolean;
|
||||
onSignal: (signal: ServerProcessSignal) => void;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex items-center justify-end gap-1.5">
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<InlineButton
|
||||
disabled={disabled}
|
||||
aria-label="Send SIGINT"
|
||||
className="text-[11px] font-medium text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
|
||||
onClick={() => onSignal("SIGINT")}
|
||||
>
|
||||
INT
|
||||
</InlineButton>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">Send SIGINT</TooltipPopup>
|
||||
</Tooltip>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<InlineButton
|
||||
disabled={disabled}
|
||||
aria-label="Send SIGKILL"
|
||||
className="text-[11px] font-medium text-destructive underline-offset-2 hover:underline"
|
||||
onClick={() => onSignal("SIGKILL")}
|
||||
>
|
||||
KILL
|
||||
</InlineButton>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">Send SIGKILL</TooltipPopup>
|
||||
</Tooltip>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { ProcessSignalActions } from "./ProcessSignalActions";
|
||||
import { RefreshIcon } from "~/components/ui/refresh-icon";
|
||||
import {
|
||||
ActivityIcon,
|
||||
@@ -535,24 +536,7 @@ function ProcessActions({
|
||||
}
|
||||
const isSignaling = signalingKeys.has(processIdentityKey(process));
|
||||
return (
|
||||
<div className="flex items-center justify-end gap-1.5">
|
||||
<button
|
||||
type="button"
|
||||
disabled={isSignaling}
|
||||
className="cursor-pointer text-[10px] font-semibold text-muted-foreground hover:text-foreground disabled:opacity-50"
|
||||
onClick={() => onSignal(process, "SIGINT")}
|
||||
>
|
||||
INT
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
disabled={isSignaling}
|
||||
className="cursor-pointer text-[10px] font-semibold text-destructive hover:underline disabled:opacity-50"
|
||||
onClick={() => onSignal(process, "SIGKILL")}
|
||||
>
|
||||
KILL
|
||||
</button>
|
||||
</div>
|
||||
<ProcessSignalActions disabled={isSignaling} onSignal={(signal) => onSignal(process, signal)} />
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user