mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-27 03:10:47 +00:00
fix(vault): keep Mosh/ET exclusive when restoring group transport
This commit is contained in:
1 parent
900cd19cbb
commit
021477e836
2 files changed
+38
-1
No files matched your search
@@ -73,7 +73,17 @@ export const HostDetailsAdvancedSections: React.FC<HostDetailsAdvancedSectionsPr
|
||||
{t("vault.groups.details.inherited")}
|
||||
</Badge>
|
||||
) : (
|
||||
<HostDetailsOverrideReset size="sm" label={t("common.useGroup")} onClick={() => update(key, undefined)} />
|
||||
<HostDetailsOverrideReset size="sm" label={t("common.useGroup")} onClick={() => {
|
||||
if ((key === "moshEnabled" || key === "etEnabled") && effectiveGroupDefaults[key] === true) {
|
||||
setForm(prev => ({
|
||||
...prev,
|
||||
[key]: undefined,
|
||||
[key === "moshEnabled" ? "etEnabled" : "moshEnabled"]: false,
|
||||
}));
|
||||
} else {
|
||||
update(key, undefined);
|
||||
}
|
||||
}} />
|
||||
);
|
||||
};
|
||||
const inheritedStartupCommandRunMode = effectiveGroupDefaults?.startupCommandRunMode ?? "paste";
|
||||
|
||||
@@ -5,6 +5,7 @@ import { act, create, type ReactTestInstance, type ReactTestRenderer } from "rea
|
||||
import { I18nProvider } from "../application/i18n/I18nProvider";
|
||||
import { applyGroupDefaults } from "../domain/groupConfig";
|
||||
import type { GroupConfig, Host } from "../domain/models";
|
||||
import { resolveEffectiveTerminalProtocol } from "../domain/terminalProtocol";
|
||||
import HostDetailsPanel from "./HostDetailsPanel";
|
||||
import { ChainPanel } from "./host-details/ChainPanel";
|
||||
import { HostDetailsOverrideReset } from "./host-details/HostDetailsOverrideReset";
|
||||
@@ -111,6 +112,32 @@ for (const [key, label] of [["moshEnabled", "Mosh"], ["etEnabled", "EternalTermi
|
||||
assertInherited(row());
|
||||
});
|
||||
});
|
||||
|
||||
test(`Host Details restores inherited ${label} and disables the competing transport`, async () => {
|
||||
const competingKey = key === "moshEnabled" ? "etEnabled" : "moshEnabled";
|
||||
const competingLabel = key === "moshEnabled" ? "EternalTerminal" : "Mosh";
|
||||
const group = { [key]: true };
|
||||
await withPanel(group, async ({ root, save }) => {
|
||||
const row = () => setting(root, label);
|
||||
assert.equal(row().findByType(Switch).props.checked, false);
|
||||
assert.equal(setting(root, competingLabel).findByType(Switch).props.checked, true);
|
||||
|
||||
const reset = row().findByType(HostDetailsOverrideReset);
|
||||
assert.equal(reset.props.label, "Use group");
|
||||
await act(async () => { reset.props.onClick(); });
|
||||
const inherited = await save();
|
||||
assert.equal(inherited[key], undefined);
|
||||
assert.equal(inherited[competingKey], false);
|
||||
assert.equal(row().findByType(Switch).props.checked, true);
|
||||
assertInherited(row());
|
||||
assert.equal(setting(root, competingLabel).findByType(Switch).props.checked, false);
|
||||
|
||||
const effective = applyGroupDefaults(inherited, group);
|
||||
assert.equal(effective[key], true);
|
||||
assert.equal(effective[competingKey], false);
|
||||
assert.equal(resolveEffectiveTerminalProtocol(effective), key === "moshEnabled" ? "mosh" : "et");
|
||||
}, { ...host, [key]: false, [competingKey]: true });
|
||||
});
|
||||
}
|
||||
|
||||
test("Host Details device type override can return to the group", async () => {
|
||||
|
||||
Reference in new issue
Block a user