Skip to content

Commit 182cde8

Browse files
authored
support multiline text input in test tool panel (#650)
Signed-off-by: Keval Mahajan <[email protected]>
1 parent 6b4ff13 commit 182cde8

File tree

1 file changed

+29
-24
lines changed

1 file changed

+29
-24
lines changed

mcpgateway/static/admin.js

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3417,39 +3417,44 @@ async function testTool(toolId) {
34173417
fieldDiv.appendChild(arrayContainer);
34183418
fieldDiv.appendChild(addBtn);
34193419
} else {
3420-
// Input field with validation
3421-
const input = document.createElement("input");
3422-
input.name = keyValidation.value;
3423-
input.required =
3424-
schema.required && schema.required.includes(key);
3425-
input.className =
3426-
"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";
3427-
// Add validation based on type
3428-
if (prop.type === "text") {
3429-
input.type = "text";
3430-
} else if (
3431-
prop.type === "number" ||
3432-
prop.type === "integer"
3433-
) {
3434-
input.type = "number";
3435-
} else if (prop.type === "boolean") {
3436-
input.type = "checkbox";
3437-
input.className =
3438-
"mt-1 h-4 w-4 text-indigo-600 dark:text-indigo-200 border border-gray-300 rounded";
3420+
// Input field with validation (with multiline support)
3421+
let fieldInput;
3422+
const isTextType = prop.type === "text";
3423+
if (isTextType) {
3424+
fieldInput = document.createElement("textarea");
3425+
fieldInput.rows = 4;
34393426
} else {
3440-
input.type = "text";
3427+
fieldInput = document.createElement("input");
3428+
if (prop.type === "number" || prop.type === "integer") {
3429+
fieldInput.type = "number";
3430+
} else if (prop.type === "boolean") {
3431+
fieldInput.type = "checkbox";
3432+
} else {
3433+
fieldInput = document.createElement("textarea");
3434+
fieldInput.rows = 1;
3435+
}
34413436
}
34423437

3438+
fieldInput.name = keyValidation.value;
3439+
fieldInput.required =
3440+
schema.required && schema.required.includes(key);
3441+
fieldInput.className =
3442+
prop.type === "boolean"
3443+
? "mt-1 h-4 w-4 text-indigo-600 dark:text-indigo-200 border border-gray-300 rounded"
3444+
: "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";
3445+
34433446
// Set default values here
34443447
if (prop.default !== undefined) {
3445-
if (input.type === "checkbox") {
3446-
input.checked = prop.default === true;
3448+
if (fieldInput.type === "checkbox") {
3449+
fieldInput.checked = prop.default === true;
3450+
} else if (isTextType) {
3451+
fieldInput.value = prop.default;
34473452
} else {
3448-
input.value = prop.default;
3453+
fieldInput.value = prop.default;
34493454
}
34503455
}
34513456

3452-
fieldDiv.appendChild(input);
3457+
fieldDiv.appendChild(fieldInput);
34533458
}
34543459

34553460
container.appendChild(fieldDiv);

0 commit comments

Comments
 (0)