fix(web-ui): render Accounts schema node properly (#35380)

Co-authored-by: stakeswky <64798754+stakeswky@users.noreply.github.com>
Co-authored-by: liuxiaopai-ai <73659136+liuxiaopai-ai@users.noreply.github.com>
Co-authored-by: Tak Hoffman <781889+Takhoffman@users.noreply.github.com>
This commit is contained in:
不做了睡大觉
2026-03-05 13:50:18 +08:00
committed by GitHub
parent d9b69a6145
commit 8891e1e48d
3 changed files with 24 additions and 4 deletions

View File

@@ -427,17 +427,35 @@ describe("config form renderer", () => {
expect(analysis.unsupportedPaths).not.toContain("channels");
});
it("flags additionalProperties true", () => {
it("treats additionalProperties true as editable map fields", () => {
const schema = {
type: "object",
properties: {
extra: {
accounts: {
type: "object",
additionalProperties: true,
},
},
};
const analysis = analyzeConfigSchema(schema);
expect(analysis.unsupportedPaths).toContain("extra");
expect(analysis.unsupportedPaths).not.toContain("accounts");
const onPatch = vi.fn();
const container = document.createElement("div");
render(
renderConfigForm({
schema: analysis.schema,
uiHints: {},
unsupportedPaths: analysis.unsupportedPaths,
value: { accounts: { default: { enabled: true } } },
onPatch,
}),
container,
);
const removeButton = container.querySelector(".cfg-map__item-remove");
expect(removeButton).not.toBeNull();
removeButton?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
expect(onPatch).toHaveBeenCalledWith(["accounts"], {});
});
});

View File

@@ -79,7 +79,8 @@ function normalizeSchemaNode(
normalized.properties = normalizedProps;
if (schema.additionalProperties === true) {
unsupported.add(pathLabel);
// Treat `true` as an untyped map schema so dynamic object keys can still be edited.
normalized.additionalProperties = {};
} else if (schema.additionalProperties === false) {
normalized.additionalProperties = false;
} else if (schema.additionalProperties && typeof schema.additionalProperties === "object") {