mirror of
https://github.com/tale/headplane.git
synced 2026-08-21 18:26:38 +00:00
Add key expiry disable/enable toggle (#554)
This commit is contained in:
@@ -28,6 +28,7 @@ interface Props {
|
||||
isDisabled?: boolean;
|
||||
existingTags?: string[];
|
||||
supportsNodeOwnerChange: boolean;
|
||||
supportsDisablingKeyExpiry: boolean;
|
||||
}
|
||||
|
||||
export default function MachineRow({
|
||||
@@ -38,6 +39,7 @@ export default function MachineRow({
|
||||
isDisabled,
|
||||
existingTags,
|
||||
supportsNodeOwnerChange,
|
||||
supportsDisablingKeyExpiry,
|
||||
}: Props) {
|
||||
const uiTags = useMemo(() => uiTagsForNode(node, isAgent), [node, isAgent]);
|
||||
|
||||
@@ -144,6 +146,7 @@ export default function MachineRow({
|
||||
node={node}
|
||||
users={users}
|
||||
supportsNodeOwnerChange={supportsNodeOwnerChange}
|
||||
supportsDisablingKeyExpiry={supportsDisablingKeyExpiry}
|
||||
/>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { Cog, Ellipsis, SquareTerminal } from "lucide-react";
|
||||
import { useState } from "react";
|
||||
import { useSubmit } from "react-router";
|
||||
|
||||
import Button from "~/components/button";
|
||||
import { Menu, MenuContent, MenuItem, MenuSeparator, MenuTrigger } from "~/components/menu";
|
||||
import type { User } from "~/types";
|
||||
import cn from "~/utils/cn";
|
||||
import { PopulatedNode } from "~/utils/node-info";
|
||||
import { isNoExpiry, type PopulatedNode } from "~/utils/node-info";
|
||||
|
||||
import Delete from "../dialogs/delete";
|
||||
import Expire from "../dialogs/expire";
|
||||
@@ -22,6 +23,7 @@ interface MenuProps {
|
||||
isDisabled?: boolean;
|
||||
existingTags?: string[];
|
||||
supportsNodeOwnerChange: boolean;
|
||||
supportsDisablingKeyExpiry: boolean;
|
||||
}
|
||||
|
||||
type Modal = "rename" | "expire" | "remove" | "routes" | "move" | "tags" | null;
|
||||
@@ -34,7 +36,9 @@ export default function MachineMenu({
|
||||
isDisabled,
|
||||
existingTags,
|
||||
supportsNodeOwnerChange,
|
||||
supportsDisablingKeyExpiry,
|
||||
}: MenuProps) {
|
||||
const submit = useSubmit();
|
||||
const [modal, setModal] = useState<Modal>(null);
|
||||
const supportsTailscaleSSH = node.hostInfo?.sshHostKeys && node.hostInfo?.sshHostKeys.length > 0;
|
||||
|
||||
@@ -156,15 +160,33 @@ export default function MachineMenu({
|
||||
</MenuTrigger>
|
||||
<MenuContent>
|
||||
<MenuItem onClick={() => setModal("rename")}>Edit machine name</MenuItem>
|
||||
{supportsDisablingKeyExpiry && (
|
||||
<MenuItem
|
||||
onClick={() =>
|
||||
submit(
|
||||
{
|
||||
action_id: "toggle_expiry",
|
||||
node_id: node.id,
|
||||
disableExpiry: !isNoExpiry(node.expiry),
|
||||
},
|
||||
{ method: "post" },
|
||||
)
|
||||
}
|
||||
>
|
||||
{isNoExpiry(node.expiry) ? "Enable" : "Disable"} key expiry
|
||||
</MenuItem>
|
||||
)}
|
||||
<MenuItem onClick={() => setModal("routes")}>Edit route settings</MenuItem>
|
||||
<MenuItem onClick={() => setModal("tags")}>Edit ACL tags</MenuItem>
|
||||
{supportsNodeOwnerChange && (
|
||||
<MenuItem onClick={() => setModal("move")}>Change owner</MenuItem>
|
||||
)}
|
||||
<MenuSeparator />
|
||||
<MenuItem variant="danger" disabled={node.expired} onClick={() => setModal("expire")}>
|
||||
Expire
|
||||
</MenuItem>
|
||||
{!isNoExpiry(node.expiry) && (
|
||||
<MenuItem variant="danger" disabled={node.expired} onClick={() => setModal("expire")}>
|
||||
Expire
|
||||
</MenuItem>
|
||||
)}
|
||||
<MenuItem variant="danger" onClick={() => setModal("remove")}>
|
||||
Remove
|
||||
</MenuItem>
|
||||
|
||||
Reference in New Issue
Block a user