mirror of
https://github.com/tale/headplane.git
synced 2026-08-22 10:46:38 +00:00
8c508e0602
The user-actions handler already supported `rename_user` and `delete_user` (both keyed by headscale_user_id), but the Unlinked Headscale Users table had no menu to invoke them. That left admins with no UI path to remove or rename Headscale users that have no Headplane counterpart — e.g. users created via the Headscale CLI before an OIDC migration. Wire the existing dialogs into a new HeadscaleUserMenu rendered in the row's actions column. OIDC-managed users still can't be renamed (Headscale rejects it), so the Rename item hides for those. Closes #525 Amp-Thread-ID: https://ampcode.com/threads/T-019e7ae4-6862-760c-a3e7-239350eab71d Co-authored-by: Amp <amp@ampcode.com>
63 lines
2.1 KiB
TypeScript
63 lines
2.1 KiB
TypeScript
import { CircleUser } from "lucide-react";
|
|
|
|
import StatusCircle from "~/components/status-circle";
|
|
import cn from "~/utils/cn";
|
|
|
|
import type { UnlinkedHeadscaleUser } from "../overview";
|
|
import HeadscaleUserMenu from "./headscale-user-menu";
|
|
|
|
interface HeadscaleUserRowProps {
|
|
user: UnlinkedHeadscaleUser;
|
|
writable?: boolean;
|
|
}
|
|
|
|
export default function HeadscaleUserRow({ user, writable }: HeadscaleUserRowProps) {
|
|
const isOnline = user.machines.some((machine) => machine.online);
|
|
const lastSeen = user.machines.reduce(
|
|
(acc, machine) => Math.max(acc, new Date(machine.lastSeen).getTime()),
|
|
0,
|
|
);
|
|
|
|
return (
|
|
<tr className="group hover:bg-mist-50 dark:hover:bg-mist-950" key={user.id}>
|
|
<td className="py-2 pl-0.5">
|
|
<div className="flex items-center">
|
|
{user.profilePicUrl ? (
|
|
<img
|
|
alt={user.name || user.displayName}
|
|
className="h-10 w-10 rounded-full"
|
|
src={user.profilePicUrl}
|
|
/>
|
|
) : (
|
|
<CircleUser className="h-10 w-10" />
|
|
)}
|
|
<div className="ml-4">
|
|
<p className="leading-snug font-semibold">{user.name || user.displayName}</p>
|
|
{user.email && <p className="text-sm opacity-50">{user.email}</p>}
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td className="py-2 pl-0.5">
|
|
<p className="text-sm text-mist-600 dark:text-mist-300" suppressHydrationWarning>
|
|
{new Date(user.createdAt).toLocaleDateString()}
|
|
</p>
|
|
</td>
|
|
<td className="py-2 pl-0.5">
|
|
{user.machines.length > 0 ? (
|
|
<span
|
|
className={cn("flex items-center gap-x-1 text-sm", "text-mist-600 dark:text-mist-300")}
|
|
>
|
|
<StatusCircle className="h-4 w-4" isOnline={isOnline} />
|
|
<p suppressHydrationWarning>
|
|
{isOnline ? "Connected" : new Date(lastSeen).toLocaleString()}
|
|
</p>
|
|
</span>
|
|
) : (
|
|
<p className="text-sm text-mist-600 dark:text-mist-300">No machines</p>
|
|
)}
|
|
</td>
|
|
<td className="py-2 pr-0.5">{writable ? <HeadscaleUserMenu user={user} /> : null}</td>
|
|
</tr>
|
|
);
|
|
}
|