Skip to content

Commit f040dc8

Browse files
committed
lint fixes
Signed-off-by: Shoumi <[email protected]>
1 parent dc67def commit f040dc8

File tree

1 file changed

+40
-11
lines changed

1 file changed

+40
-11
lines changed

mcpgateway/static/admin.js

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3348,9 +3348,19 @@ async function testTool(toolId) {
33483348
input.className =
33493349
"mt-1 block w-full rounded-md border border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:bg-gray-900 text-gray-700 dark:text-gray-300 dark:border-gray-700 dark:focus:border-indigo-400 dark:focus:ring-indigo-400";
33503350

3351-
if (prop.items?.type === "number") {
3351+
const itemTypes = Array.isArray(prop.items?.anyOf)
3352+
? prop.items.anyOf.map((t) => t.type)
3353+
: [prop.items?.type];
3354+
3355+
if (
3356+
itemTypes.includes("number") ||
3357+
itemTypes.includes("integer")
3358+
) {
33523359
input.type = "number";
3353-
} else if (prop.items?.type === "boolean") {
3360+
input.step = itemTypes.includes("integer")
3361+
? "1"
3362+
: "any";
3363+
} else if (itemTypes.includes("boolean")) {
33543364
input.type = "checkbox";
33553365
input.value = "true";
33563366
input.checked = value === true || value === "true";
@@ -3390,9 +3400,16 @@ async function testTool(toolId) {
33903400
});
33913401

33923402
if (Array.isArray(prop.default)) {
3393-
prop.default.forEach((val) => {
3394-
arrayContainer.appendChild(createArrayInput(val));
3395-
});
3403+
if (prop.default.length > 0) {
3404+
prop.default.forEach((val) => {
3405+
arrayContainer.appendChild(
3406+
createArrayInput(val),
3407+
);
3408+
});
3409+
} else {
3410+
// Create one empty input for empty default arrays
3411+
arrayContainer.appendChild(createArrayInput());
3412+
}
33963413
} else {
33973414
arrayContainer.appendChild(createArrayInput());
33983415
}
@@ -3537,10 +3554,13 @@ async function runToolTest() {
35373554
// Convert values based on the items schema type
35383555
if (prop.items) {
35393556
const itemType = Array.isArray(prop.items.anyOf)
3540-
? prop.items.anyOf.map(t => t.type)
3557+
? prop.items.anyOf.map((t) => t.type)
35413558
: [prop.items.type];
35423559

3543-
if (itemType.includes("number") || itemType.includes("integer")) {
3560+
if (
3561+
itemType.includes("number") ||
3562+
itemType.includes("integer")
3563+
) {
35443564
value = inputValues.map((v) => {
35453565
const num = Number(v);
35463566
if (isNaN(num)) {
@@ -3549,17 +3569,26 @@ async function runToolTest() {
35493569
return num;
35503570
});
35513571
} else if (itemType.includes("boolean")) {
3552-
value = inputValues.map(v => v === "true" || v === true);
3572+
value = inputValues.map(
3573+
(v) => v === "true" || v === true,
3574+
);
35533575
} else if (itemType.includes("object")) {
35543576
value = inputValues.map((v) => {
35553577
try {
35563578
const parsed = JSON.parse(v);
3557-
if (typeof parsed !== "object" || Array.isArray(parsed)) {
3558-
throw new Error(`Value must be an object`);
3579+
if (
3580+
typeof parsed !== "object" ||
3581+
Array.isArray(parsed)
3582+
) {
3583+
throw new Error(
3584+
"Value must be an object",
3585+
);
35593586
}
35603587
return parsed;
35613588
} catch {
3562-
throw new Error(`Invalid object format for ${key}`);
3589+
throw new Error(
3590+
`Invalid object format for ${key}`,
3591+
);
35633592
}
35643593
});
35653594
} else {

0 commit comments

Comments
 (0)