import type { ReactNode } from "react"; import { useTranslation } from "react-i18next"; import { Input } from "@kandev/ui/input"; import { Label } from "@kandev/ui/label"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@kandev/ui/select"; import type { SSHIdentitySource } from "@/lib/types/http-ssh"; import type { SSHExecutorConfig } from "./ssh-connection-card"; type FieldOnChange = ( key: K, value: SSHExecutorConfig[K], ) => void; type SSHConnectionFormProps = { form: SSHExecutorConfig; baseline: SSHExecutorConfig; onChange: FieldOnChange; }; function fieldIsDirty( form: SSHExecutorConfig, baseline: SSHExecutorConfig, key: K, fallback: NonNullable, ): boolean { return (form[key] ?? fallback) !== (baseline[key] ?? fallback); } export function SSHConnectionForm({ form, baseline, onChange }: SSHConnectionFormProps) { const { t } = useTranslation(); return (
onChange("name", value)} /> onChange("host_alias", value)} /> onChange("host", value)} /> onChange("port", parseInt(value, 10) || 22)} /> onChange("user", value)} /> onChange("identity_source", value)} /> {form.identity_source === "file" && ( onChange("identity_file", value)} /> )} onChange("proxy_jump", value)} />
); } type TextFieldProps = { id: string; testId: string; label: string; hint?: string; placeholder?: string; type?: string; value: string; isDirty: boolean; onChange: (value: string) => void; }; function TextField({ id, testId, label, hint, placeholder, type, value, isDirty, onChange, }: TextFieldProps) { return ( onChange(event.target.value)} /> ); } function IdentitySourceField({ value, isDirty, onChange, }: { value: SSHIdentitySource; isDirty: boolean; onChange: (value: SSHIdentitySource) => void; }) { const { t } = useTranslation(); return ( ); } function FieldShell({ id, label, hint, children, }: { id: string; label: string; hint?: string; children: ReactNode; }) { return (
{children} {hint &&

{hint}

}
); }