import {
HOST_PROTOCOL_SECRET_KEPT,
useTranslation,
} from "@termix/plugin-sdk/frontend";
import {
FakeSwitch,
Input,
PasswordInput,
SectionCard,
Select2,
SettingRow,
} from "@termix/plugin-sdk/ui";
import {
Activity,
Copy,
Globe,
Monitor,
Network,
Server,
Settings,
Shield,
Terminal,
Zap,
Cpu,
} from "lucide-react";
import type { RemoteDesktopForm, RemoteFormSetField } from "./remote-form";
type HostEditorForm = RemoteDesktopForm;
type HostEditorSetField = RemoteFormSetField;
type GuacFieldSetter = (key: string, value: unknown) => void;
function DocsLinkAction({ href, label }: { href: string; label: string }) {
return (
{label}
);
}
export function HostEditorRdpTab({
form,
setField,
setGuacField,
host,
credentials,
}: {
form: HostEditorForm;
setField: HostEditorSetField;
setGuacField: GuacFieldSetter;
host?: { macAddress?: string | null } | null;
credentials?: { id: string; name: string; username: string }[];
}) {
const { t } = useTranslation();
return (
<>
}
action={
}
>
}
>
}
>
{(
[
"direct",
...(credentials && credentials.length > 0
? (["credential"] as const)
: []),
"none",
] as const
).map((m) => (
))}
{form.rdpAuthType === "none" ? (
{t("hosts.guac.authTypeNoneDesc")}
) : (
{form.rdpAuthType === "credential" &&
credentials &&
credentials.length > 0 ? (
setField("rdpCredentialId", e.target.value)
}
className="flex h-9 w-full border border-border bg-background px-3 py-1 text-xs outline-none focus:ring-1 focus:ring-ring"
>
{credentials.map((c) => (
))}
) : (
<>
setField("rdpUser", e.target.value)}
/>
{
if (form.rdpPassword === HOST_PROTOCOL_SECRET_KEPT)
setField("rdpPassword", "");
}}
onChange={(e) => setField("rdpPassword", e.target.value)}
/>
>
)}
setField("domain", e.target.value)}
/>
)}
}
>
setField("security", e.target.value)}
>
setField("ignoreCert", v)}
/>
}
>
setGuacField("color-depth", e.target.value)}
>
setGuacField("dpi", e.target.value)}
className="[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none"
/>
setGuacField("resize-method", e.target.value)}
>
setGuacField("force-lossless", v)}
/>
}
>
setGuacField("disable-audio", v)}
/>
setGuacField("enable-audio-input", v)}
/>
}
>
setGuacField("enable-wallpaper", v)}
/>
setGuacField("enable-theming", v)}
/>
setGuacField("enable-font-smoothing", v)}
/>
setGuacField("enable-full-window-drag", v)}
/>
setGuacField("enable-desktop-composition", v)}
/>
setGuacField("enable-menu-animations", v)}
/>
setGuacField("disable-bitmap-caching", v)}
/>
setGuacField("disable-offscreen-caching", v)}
/>
setGuacField("disable-glyph-caching", v)}
/>
setGuacField("enable-gfx", v)}
/>
}
>
setGuacField("enable-printing", v)}
/>
setGuacField("enable-drive", v)}
/>
setGuacField("create-drive-path", v)}
/>
setGuacField("disable-download", v)}
/>
setGuacField("disable-upload", v)}
/>
setGuacField("enable-touch", v)}
/>
}
>
}
>
}
>
}
>
setGuacField("normalize-clipboard", e.target.value)
}
>
setGuacField("disable-copy", v)}
/>
setGuacField("disable-paste", v)}
/>
}
action={
}
>
setGuacField("create-recording-path", v)}
/>
setGuacField("recording-exclude-output", v)}
/>
setGuacField("recording-exclude-mouse", v)}
/>
setGuacField("recording-include-keys", v)}
/>
}
action={
}
>
setGuacField("wol-send-packet", v)}
/>
>
);
}
export function HostEditorVncTab({
form,
setField,
setGuacField,
host,
credentials,
}: {
form: HostEditorForm;
setField: HostEditorSetField;
setGuacField: GuacFieldSetter;
host?: { macAddress?: string | null } | null;
credentials?: { id: string; name: string; username: string }[];
}) {
const { t } = useTranslation();
return (
<>
}
action={
}
>
}
>
}
>
{credentials && credentials.length > 0 && (
{(["direct", "credential"] as const).map((m) => (
))}
)}
{form.vncAuthType === "credential" &&
credentials &&
credentials.length > 0 ? (
setField("vncCredentialId", e.target.value)}
className="flex h-9 w-full border border-border bg-background px-3 py-1 text-xs outline-none focus:ring-1 focus:ring-ring"
>
{credentials.map((c) => (
))}
) : (
)}
}
>
setGuacField("color-depth", e.target.value)}
>
setGuacField("resize-method", e.target.value)}
>
setGuacField("force-lossless", v)}
/>
}
>
setGuacField("disable-audio", v)}
/>
}
>
setGuacField("cursor", e.target.value)}
>
setGuacField("server-layout", e.target.value)}
>
setGuacField("swap-red-blue", v)}
/>
setGuacField("read-only", v)}
/>
}
>
setGuacField("normalize-clipboard", e.target.value)
}
>
setGuacField("disable-copy", v)}
/>
setGuacField("disable-paste", v)}
/>
}
action={
}
>
setGuacField("create-recording-path", v)}
/>
setGuacField("recording-exclude-output", v)}
/>
setGuacField("recording-exclude-mouse", v)}
/>
setGuacField("recording-include-keys", v)}
/>
}
action={
}
>
setGuacField("wol-send-packet", v)}
/>
>
);
}
export function HostEditorTelnetTab({
form,
setField,
setGuacField,
credentials,
}: {
form: HostEditorForm;
setField: HostEditorSetField;
setGuacField: GuacFieldSetter;
credentials?: { id: string; name: string; username: string }[];
}) {
const { t } = useTranslation();
return (
<>
}
action={
}
>
}
>
}
>
{credentials && credentials.length > 0 && (
{(["direct", "credential"] as const).map((m) => (
))}
)}
{form.telnetAuthType === "credential" &&
credentials &&
credentials.length > 0 ? (
setField("telnetCredentialId", e.target.value)}
className="flex h-9 w-full border border-border bg-background px-3 py-1 text-xs outline-none focus:ring-1 focus:ring-ring"
>
{credentials.map((c) => (
))}
) : (
)}
}
>
}
>
}
action={
}
>
setGuacField("create-recording-path", v)}
/>
setGuacField("recording-exclude-output", v)}
/>
setGuacField("recording-include-keys", v)}
/>
>
);
}