Skip to content

Commit 8a559fb

Browse files
committed
Clear test tool output before closing modal.
Signed-off-by: Madhav Kandukuri <[email protected]>
1 parent 6b83a81 commit 8a559fb

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

mcpgateway/static/admin.js

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,21 +1610,20 @@ async function runToolTest() {
16101610
.then((response) => response.json())
16111611
.then((result) => {
16121612
const resultStr = JSON.stringify(result, null, 2);
1613-
// If the CodeMirror editor exists, update its value; otherwise, create one.
1614-
if (toolTestResultEditor) {
1615-
toolTestResultEditor.setValue(resultStr);
1616-
} else {
1617-
toolTestResultEditor = window.CodeMirror(
1618-
document.getElementById("tool-test-result"),
1619-
{
1620-
value: resultStr,
1621-
mode: "application/json",
1622-
theme: "monokai",
1623-
readOnly: true,
1624-
lineNumbers: true,
1625-
},
1626-
);
1627-
}
1613+
1614+
const container = document.getElementById("tool-test-result");
1615+
container.innerHTML = ''; // clear any old editor
1616+
1617+
toolTestResultEditor = window.CodeMirror(
1618+
document.getElementById("tool-test-result"),
1619+
{
1620+
value: resultStr,
1621+
mode: "application/json",
1622+
theme: "monokai",
1623+
readOnly: true,
1624+
lineNumbers: true,
1625+
},
1626+
);
16281627
})
16291628
.catch((error) => {
16301629
document.getElementById("tool-test-result").innerText = "Error: " + error;
@@ -1636,8 +1635,17 @@ function openModal(modalId) {
16361635
document.getElementById(modalId).classList.remove("hidden");
16371636
}
16381637

1639-
function closeModal(modalId) {
1640-
document.getElementById(modalId).classList.add("hidden");
1638+
function closeModal(modalId, clearId=null) {
1639+
// document.getElementById(modalId).classList.add('hidden');
1640+
const modal = document.getElementById(modalId);
1641+
1642+
if (clearId) {
1643+
// Look up by id string
1644+
const resultEl = document.getElementById(clearId);
1645+
if (resultEl) resultEl.innerHTML = '';
1646+
}
1647+
1648+
modal.classList.add('hidden');
16411649
}
16421650

16431651
const integrationRequestMap = {

mcpgateway/templates/admin.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1726,7 +1726,7 @@ <h3 class="text-lg font-medium text-gray-900">Tool Details</h3>
17261726
<div class="bg-gray-50 px-4 py-3 sm:px-6 sm:flex sm:flex-row-reverse">
17271727
<button
17281728
type="button"
1729-
onclick="closeModal('tool-test-modal')"
1729+
onclick="closeModal('tool-test-modal', 'tool-test-result')"
17301730
class="mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 sm:mt-0 sm:ml-3 sm:w-auto sm:text-sm"
17311731
>
17321732
Close

0 commit comments

Comments
 (0)