Skip to content

Commit 004ccbb

Browse files
committed
Feat: Add per-tool reset button and improve responsive layout for tool headers
1 parent df0c4a5 commit 004ccbb

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

public/style.css

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,11 +596,13 @@ footer { /* Basic footer style */
596596

597597
.tool-entry .tool-header .tool-enable-label,
598598
.tool-entry .tool-header h3,
599-
.tool-entry .tool-header .tool-exposed-name {
599+
.tool-entry .tool-header .tool-exposed-name,
600+
.tool-entry .tool-header .reset-tool-overrides-button { /* Added reset button here */
600601
width: 100%; /* Make each item take full width in column layout */
601602
margin-left: 0;
602603
margin-right: 0;
603604
padding-right: 0; /* Reset padding that was for row layout */
605+
box-sizing: border-box; /* Ensure padding/border don't add to width */
604606
}
605607

606608
.tool-entry .tool-header .tool-enable-label {
@@ -613,9 +615,17 @@ footer { /* Basic footer style */
613615
}
614616

615617
.tool-entry .tool-header .tool-exposed-name {
618+
margin-bottom: 0.5rem; /* Space below "Exposed As" text before reset button */
616619
/* font-size can remain as is or be adjusted if needed */
617620
/* margin-left was reset above */
618621
}
622+
623+
.tool-entry .tool-header .reset-tool-overrides-button {
624+
/* width: auto; /* Allow button to size to its content, but still be left-aligned due to align-items: flex-start on parent */
625+
/* align-self: flex-start; /* Explicitly align left if width is auto */
626+
/* No margin-bottom needed if it's the last item in the stacked header before details */
627+
margin-top: 0.25rem; /* Add a little space if it stacks below exposed-name */
628+
}
619629
}
620630

621631
footer p {
@@ -629,4 +639,20 @@ footer a {
629639

630640
footer a:hover {
631641
text-decoration: underline;
642+
}
643+
/* Styles for Per-Tool Reset Button */
644+
.reset-tool-overrides-button {
645+
background-color: #6c757d; /* Secondary/neutral color */
646+
border-color: #6c757d;
647+
color: #fff;
648+
padding: 0.2rem 0.5rem; /* Smaller padding */
649+
font-size: 0.8em; /* Smaller font */
650+
margin-left: 0.75rem; /* Space from the "Exposed As" text */
651+
line-height: 1.4;
652+
flex-shrink: 0; /* Prevent shrinking if header space is tight */
653+
}
654+
.reset-tool-overrides-button:hover {
655+
background-color: #5a6268;
656+
border-color: #545b62;
657+
color: #fff;
632658
}

public/tools.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ function renderToolEntry(toolKey, toolDefinition, toolConfig, isConfigOnly = fal
124124
</label>
125125
<h3 title="${!isServerActive ? 'Server is inactive' : ''}">${toolKey}</h3>
126126
<span class="tool-exposed-name">Exposed As: ${exposedName}</span>
127+
<button class="reset-tool-overrides-button" title="Reset all overrides for this tool to defaults">Reset</button>
127128
</div>
128129
<div class="tool-details">
129130
<div>
@@ -142,6 +143,36 @@ function renderToolEntry(toolKey, toolDefinition, toolConfig, isConfigOnly = fal
142143

143144
toolListDiv.appendChild(entryDiv); // Append first, then query elements within it
144145

146+
// Add click listener to the new Reset button
147+
const resetButton = entryDiv.querySelector('.reset-tool-overrides-button');
148+
if (resetButton) {
149+
resetButton.addEventListener('click', (e) => {
150+
e.stopPropagation(); // Prevent a click on the button from also toggling collapse if it's in the header
151+
if (confirm(`Are you sure you want to reset all overrides for tool "${toolKey}"?\nThis will remove any custom settings for its name, description, and enabled state from the configuration. You will need to save the tool configuration to make this permanent.`)) {
152+
if (window.currentToolConfig && window.currentToolConfig.tools && window.currentToolConfig.tools[toolKey]) {
153+
delete window.currentToolConfig.tools[toolKey];
154+
console.log(`Overrides for tool ${toolKey} marked for deletion.`);
155+
// Mark main tool config as dirty (if such a flag exists, or rely on main save button's behavior)
156+
// To reflect changes immediately, re-render the tools list
157+
// This will pick up the deleted config for this toolKey and render it with defaults
158+
renderTools();
159+
// Optionally, provide a status message or highlight the main save button
160+
if (window.saveToolStatus) { // Ensure saveToolStatus is accessed via window or defined in this scope
161+
window.saveToolStatus.textContent = `Overrides for '${toolKey}' reset. Click "Save & Reload" to apply.`;
162+
window.saveToolStatus.style.color = 'orange';
163+
setTimeout(() => { if (window.saveToolStatus) window.saveToolStatus.textContent = ''; }, 5000);
164+
}
165+
} else {
166+
// If the toolKey wasn't in currentToolConfig.tools, it means it was already using defaults.
167+
// However, the UI might show input values if the user typed them without saving.
168+
// Re-rendering will clear these UI-only changes.
169+
renderTools(); // Call renderTools to refresh the UI for this entry too
170+
alert(`Tool "${toolKey}" is already using default settings or has no saved overrides.`);
171+
}
172+
}
173+
});
174+
}
175+
145176
// Add click listener to the header (h3) to toggle collapse
146177
const headerH3 = entryDiv.querySelector('.tool-header h3');
147178
if (headerH3) {

0 commit comments

Comments
 (0)