@@ -376,12 +378,6 @@ export const HostDetailsAdvancedSections: React.FC update("showLineTimestamps", !form.showLineTimestamps)}
/>
- update("disableDynamicTabTitle", !form.disableDynamicTabTitle)}
- />
>
-);
+ );
+};
diff --git a/components/HostDetailsConnectionSections.tsx b/components/HostDetailsConnectionSections.tsx
index 20e862fdc..742e77ceb 100644
--- a/components/HostDetailsConnectionSections.tsx
+++ b/components/HostDetailsConnectionSections.tsx
@@ -1,7 +1,6 @@
import React from "react";
-import { ChevronDown, Eye, EyeOff, FileKey, FolderLock, FolderOpen, Key, KeyRound, MapPin, Plus, Shield, Trash2, User, X } from "lucide-react";
+import { ChevronDown, Eye, EyeOff, FileKey, FolderLock, FolderOpen, Key, KeyRound, MapPin, Plus, Shapes, Shield, Trash2, User, X } from "lucide-react";
import type { Host } from "../types";
-import { DistroAvatar } from "./DistroAvatar";
import { HostIconPicker } from "./HostIconPicker";
import { Button } from "./ui/button";
import { Combobox } from "./ui/combobox";
@@ -51,23 +50,12 @@ export const HostDetailsConnectionSections: React.FC}
title={t("hostDetails.section.address")}
>
-
-
- update("hostname", e.target.value)}
- className="h-10 flex-1"
- />
-
+ update("hostname", e.target.value)}
+ className="h-10 w-full"
+ />
}
+ icon={}
title={t("hostDetails.icon.sectionTitle")}
hint={t("hostDetails.icon.desc")}
>
value ? Number(value) : undefined;
@@ -74,7 +86,74 @@ export const resolveDetailsTelnetPassword = (
? groupDefaults.telnetPassword
: host.password ?? groupDefaults?.password ?? "";
+export const prepareTelnetCredentialsForSave = (host: Host): Host =>
+ host.telnetIdentityId
+ ? {
+ ...host,
+ telnetUsername: undefined,
+ telnetPassword: undefined,
+ }
+ : host;
+
export const LINUX_DISTRO_OPTION_IDS = [
...LINUX_DISTRO_OPTIONS,
+ ...POSIX_PLATFORM_OPTIONS,
...NETWORK_DEVICE_OPTIONS,
];
+
+export type ProxySaveValidationError =
+ | "required"
+ | "port"
+ | "missingSaved"
+ | "missingIdentity"
+ | "incompleteIdentity"
+ | "unreadableIdentity";
+
+export const validateProxyConfigForSave = ({
+ proxyConfig,
+ proxyProfileId,
+ proxyProfiles,
+ identities,
+}: {
+ proxyConfig?: ProxyConfig;
+ proxyProfileId?: string;
+ proxyProfiles?: ProxyProfile[];
+ identities?: Identity[];
+}): ProxySaveValidationError | null => {
+ const selectedProxyProfile = findProxyProfile(proxyProfileId, proxyProfiles ?? []);
+ if (proxyProfileId && !selectedProxyProfile) return "missingSaved";
+
+ const normalizedProxyConfig = normalizeManualProxyConfig(proxyConfig);
+ if (normalizedProxyConfig && !isCompleteProxyConfig(normalizedProxyConfig)) {
+ return normalizedProxyConfig.host ? "port" : "required";
+ }
+
+ const effectiveProxyConfig = selectedProxyProfile?.config ?? proxyConfig;
+ if (hasMissingProxyIdentity(effectiveProxyConfig, identities ?? [])) {
+ return "missingIdentity";
+ }
+ if (hasIncompleteProxyIdentity(effectiveProxyConfig, identities ?? [])) {
+ return "incompleteIdentity";
+ }
+ if (hasUnreadableProxyCredential(effectiveProxyConfig, identities ?? [])) {
+ return "unreadableIdentity";
+ }
+
+ return null;
+};
+
+export const prepareProxyConfigForSave = (params: {
+ proxyConfig?: ProxyConfig;
+ proxyProfileId?: string;
+ proxyProfiles?: ProxyProfile[];
+ identities?: Identity[];
+}): {
+ error?: ProxySaveValidationError;
+ normalizedProxyConfig?: ProxyConfig;
+} => {
+ const error = validateProxyConfigForSave(params);
+ if (error) return { error };
+ return {
+ normalizedProxyConfig: normalizeManualProxyConfig(params.proxyConfig),
+ };
+};
diff --git a/components/HostDetailsPanel.proxyProfile.test.tsx b/components/HostDetailsPanel.proxyProfile.test.tsx
index 57f0163e4..e189ea032 100644
--- a/components/HostDetailsPanel.proxyProfile.test.tsx
+++ b/components/HostDetailsPanel.proxyProfile.test.tsx
@@ -4,11 +4,14 @@ import React from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { I18nProvider } from "../application/i18n/I18nProvider.tsx";
-import type { Host } from "../types.ts";
+import type { Host, Identity } from "../types.ts";
import HostDetailsPanel, { parseOptionalPortInput } from "./HostDetailsPanel.tsx";
import {
+ prepareProxyConfigForSave,
+ prepareTelnetCredentialsForSave,
resolvePrimaryProtocolSavePort,
resolvePrimaryProtocolSwitchPort,
+ validateProxyConfigForSave,
} from "./HostDetailsPanel.helpers.ts";
import { TooltipProvider } from "./ui/tooltip.tsx";
@@ -26,7 +29,10 @@ const hostWithMissingProxyProfile: Host = {
createdAt: 1,
};
-const renderHostDetails = (initialData: Host = hostWithMissingProxyProfile) =>
+const renderHostDetails = (
+ initialData: Host = hostWithMissingProxyProfile,
+ options: { identities?: Identity[] } = {},
+) =>
renderToStaticMarkup(
React.createElement(
I18nProvider,
@@ -37,7 +43,7 @@ const renderHostDetails = (initialData: Host = hostWithMissingProxyProfile) =>
React.createElement(HostDetailsPanel, {
initialData,
availableKeys: [],
- identities: [],
+ identities: options.identities ?? [],
proxyProfiles: [],
groups: [],
managedSources: [],
@@ -108,6 +114,72 @@ test("HostDetailsPanel keeps explicitly cleared telnet credentials empty", () =>
assert.doesNotMatch(markup, /placeholder="Telnet Password"[^>]*value="ssh-password"/);
});
+test("HostDetailsPanel shows a selected telnet identity instead of manual telnet fields", () => {
+ const markup = renderHostDetails(
+ {
+ ...hostWithMissingProxyProfile,
+ protocol: "telnet",
+ telnetEnabled: true,
+ identityId: "ssh-identity",
+ telnetIdentityId: "telnet-identity",
+ telnetUsername: undefined,
+ telnetPassword: undefined,
+ proxyProfileId: undefined,
+ },
+ {
+ identities: [{
+ id: "ssh-identity",
+ label: "SSH login",
+ username: "ssh-user",
+ authMethod: "password",
+ password: "ssh-password",
+ created: 1,
+ }, {
+ id: "telnet-identity",
+ label: "Telnet login",
+ username: "telnet-user",
+ authMethod: "password",
+ password: "telnet-password",
+ created: 2,
+ }],
+ },
+ );
+
+ assert.match(markup, /telnet-user - Telnet login/);
+ assert.doesNotMatch(markup, /placeholder="Telnet Username"/);
+ assert.doesNotMatch(markup, /placeholder="Telnet Password"/);
+});
+
+test("prepareTelnetCredentialsForSave preserves selected telnet identity and clears manual telnet fields", () => {
+ const saved = prepareTelnetCredentialsForSave({
+ ...hostWithMissingProxyProfile,
+ protocol: "telnet",
+ telnetEnabled: true,
+ identityId: "ssh-identity",
+ telnetIdentityId: "telnet-identity",
+ telnetUsername: "stale-telnet-user",
+ telnetPassword: "stale-telnet-password",
+ proxyProfileId: undefined,
+ });
+
+ assert.equal(saved.identityId, "ssh-identity");
+ assert.equal(saved.telnetIdentityId, "telnet-identity");
+ assert.equal(saved.telnetUsername, undefined);
+ assert.equal(saved.telnetPassword, undefined);
+});
+
+test("HostDetailsPanel disables save when hostname is whitespace only", () => {
+ const markup = renderHostDetails({
+ ...hostWithMissingProxyProfile,
+ hostname: " ",
+ proxyProfileId: undefined,
+ });
+
+ assert.match(markup, /
-