mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-29 22:55:24 +00:00
fix: load and save plugin host settings in the editor and tighten settings row spacing
This commit is contained in:
1 parent
1a6f9ffad6
commit
3028ab1176
6 files changed
+66
-10
No files matched your search
@@ -153,17 +153,23 @@ export function HostEditor({
|
||||
const savePluginHostSettings = async (
|
||||
hostId: number,
|
||||
values: Record<string, Record<string, unknown>> | undefined,
|
||||
) => {
|
||||
if (!values || !Number.isInteger(hostId)) return;
|
||||
): Promise<Record<string, Record<string, unknown>>> => {
|
||||
const saved: Record<string, Record<string, unknown>> = {};
|
||||
if (!values || !Number.isInteger(hostId)) return saved;
|
||||
|
||||
for (const [pluginId, fields] of Object.entries(values)) {
|
||||
if (!fields || Object.keys(fields).length === 0) continue;
|
||||
try {
|
||||
await updatePluginHostSettings(pluginId, hostId, fields);
|
||||
saved[pluginId] = await updatePluginHostSettings(
|
||||
pluginId,
|
||||
hostId,
|
||||
fields,
|
||||
);
|
||||
} catch {
|
||||
toast.error(t("settings.pluginSettingsSaveFailed"));
|
||||
}
|
||||
}
|
||||
return saved;
|
||||
};
|
||||
|
||||
const handleSave = async () => {
|
||||
@@ -186,12 +192,20 @@ export function HostEditor({
|
||||
// After the host: a new one has no id to scope settings to until it
|
||||
// exists. A failure here must not claim the host itself failed to save.
|
||||
const pluginValues = withProtocolSettings(form.pluginSettings, protocols);
|
||||
await savePluginHostSettings(
|
||||
const savedPluginValues = await savePluginHostSettings(
|
||||
Number(saved.id),
|
||||
host
|
||||
? pluginValues
|
||||
: withNewHostDefaults(pluginValues ?? {}, hostSettingPlugins),
|
||||
);
|
||||
// The host was read back before these were written.
|
||||
saved = {
|
||||
...saved,
|
||||
pluginSettings: {
|
||||
...(saved.pluginSettings ?? {}),
|
||||
...savedPluginValues,
|
||||
},
|
||||
};
|
||||
|
||||
toast.success(host ? t("hosts.hostUpdated") : t("hosts.hostCreated"));
|
||||
onSave(saved);
|
||||
|
||||
@@ -79,6 +79,7 @@ export function sshHostToHost(h: SSHHostWithStatus): Host {
|
||||
h.sshPort ??
|
||||
(h.connectionType === "ssh" || !h.connectionType ? h.port : 22),
|
||||
protocolAuth: h.protocolAuth ?? {},
|
||||
pluginSettings: h.pluginSettings ?? {},
|
||||
jumpHosts: (parseJson<HostJumpHost[]>(h.jumpHosts) ?? []).map((j) => ({
|
||||
hostId: String(j.hostId ?? j.hostid ?? j),
|
||||
})),
|
||||
|
||||
Reference in new issue
Block a user