import { useHostActions, useHosts, useTranslation, } from "@termix/plugin-sdk/frontend"; import type { QuickConnectConfig, QuickConnectType, WidgetEditFormProps, } from "../types.js"; import { quickConnectTargets } from "../quick-connect-targets.js"; export function QuickConnectEditForm({ config, onChange, }: WidgetEditFormProps) { const { t } = useTranslation(); const { hosts } = useHosts(); const targets = quickConnectTargets(useHostActions()); const toggleHost = (id: number) => { const current = config.hostIds; const ids = current.includes(id) ? current.filter((x) => x !== id) : [...current, id]; onChange({ ...config, hostIds: ids }); }; const toggleType = (type: QuickConnectType) => { const types = config.connectionTypes.includes(type) ? config.connectionTypes.filter((x) => x !== type) : [...config.connectionTypes, type]; onChange({ ...config, connectionTypes: types }); }; return (
{hosts.length === 0 && ( {t("homepage.noHosts")} )} {hosts.map((h) => { const id = Number(h.id); return ( ); })}

{t("homepage.hostGridAllHint")}

{targets.map(({ type, labelKey }) => ( ))}
{(["list", "grid"] as const).map((l) => ( ))}
); }