Skip to content

Commit e31be3b

Browse files
fix(ui): missing Show Inactive toggle in Virtual Servers tab (#1544) (#1558)
* fix(ui): missing Show Inactive toggle in Virtual Servers tab (#1544) * web lint Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com> --------- Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com> Co-authored-by: Keval Mahajan <mahajankeval23@gmail.com>
1 parent f36af63 commit e31be3b

File tree

3 files changed

+65
-8
lines changed

3 files changed

+65
-8
lines changed

mcpgateway/admin.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12258,13 +12258,15 @@ async def get_prompts_section(
1225812258
@require_permission("admin")
1225912259
async def get_servers_section(
1226012260
team_id: Optional[str] = None,
12261+
include_inactive: bool = False,
1226112262
db: Session = Depends(get_db),
1226212263
user=Depends(get_current_user_with_permissions),
1226312264
):
1226412265
"""Get servers data filtered by team.
1226512266

1226612267
Args:
1226712268
team_id: Optional team ID to filter by
12269+
include_inactive: Whether to include inactive servers
1226812270
db: Database session
1226912271
user: Current authenticated user context
1227012272

@@ -12274,10 +12276,10 @@ async def get_servers_section(
1227412276
try:
1227512277
local_server_service = ServerService()
1227612278
user_email = get_user_email(user)
12277-
LOGGER.debug(f"User {user_email} requesting servers section with team_id={team_id}")
12279+
LOGGER.debug(f"User {user_email} requesting servers section with team_id={team_id}, include_inactive={include_inactive}")
1227812280

12279-
# Get all servers and filter by team
12280-
servers_list = await local_server_service.list_servers(db, include_inactive=True)
12281+
# Get servers with optional include_inactive parameter
12282+
servers_list = await local_server_service.list_servers(db, include_inactive=include_inactive)
1228112283

1228212284
# Apply team filtering if specified
1228312285
if team_id:

mcpgateway/static/admin.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8718,6 +8718,23 @@ function toggleInactiveItems(type) {
87188718
// ignore (shouldn't happen)
87198719
}
87208720

8721+
// For servers (catalog), use loadServers function if available, otherwise reload page
8722+
if (type === "servers") {
8723+
if (typeof window.loadServers === "function") {
8724+
window.loadServers();
8725+
return;
8726+
}
8727+
// Fallback to page reload
8728+
const fallbackUrl = new URL(window.location);
8729+
if (checkbox.checked) {
8730+
fallbackUrl.searchParams.set("include_inactive", "true");
8731+
} else {
8732+
fallbackUrl.searchParams.delete("include_inactive");
8733+
}
8734+
window.location = fallbackUrl;
8735+
return;
8736+
}
8737+
87218738
// Try to find the HTMX container that loads this entity's partial
87228739
// Prefer an element with hx-get containing the admin partial endpoint
87238740
const selector = `[hx-get*="/admin/${type}/partial"]`;
@@ -14804,7 +14821,28 @@ function initializeTabState() {
1480414821
// GLOBAL EXPORTS - Make functions available to HTML onclick handlers
1480514822
// ===================================================================
1480614823

14824+
/**
14825+
* Load servers (Virtual Servers / Catalog) with optional include_inactive parameter
14826+
*/
14827+
async function loadServers() {
14828+
const checkbox = safeGetElement("show-inactive-servers");
14829+
const includeInactive = checkbox ? checkbox.checked : false;
14830+
14831+
// Build URL with include_inactive parameter
14832+
const url = new URL(window.location);
14833+
if (includeInactive) {
14834+
url.searchParams.set("include_inactive", "true");
14835+
} else {
14836+
url.searchParams.delete("include_inactive");
14837+
}
14838+
14839+
// Reload the page with the updated parameters
14840+
// Since the catalog panel is server-side rendered, we need a full page reload
14841+
window.location.href = url.toString();
14842+
}
14843+
1480714844
window.toggleInactiveItems = toggleInactiveItems;
14845+
window.loadServers = loadServers;
1480814846
window.handleToggleSubmit = handleToggleSubmit;
1480914847
window.handleSubmitWithConfirmation = handleSubmitWithConfirmation;
1481014848
window.viewTool = viewTool;

mcpgateway/templates/admin.html

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,23 +1693,40 @@ <h3 class="text-lg font-medium text-gray-900 mb-4">
16931693
<!-- Catalog Panel (Virtual Servers) -->
16941694
<div id="catalog-panel" class="tab-panel hidden">
16951695
<div class="flex justify-between items-center mb-4">
1696-
<div>
1697-
<h2 class="text-2xl font-bold dark:text-gray-200">
1698-
Virtual MCP Servers
1699-
</h2>
1696+
<div class="flex items-center space-x-10">
1697+
<h2 class="text-2xl font-bold dark:text-gray-200">Virtual MCP Servers</h2>
17001698
<p class="text-sm text-gray-600 dark:text-gray-400 mt-1">
17011699
Virtual Servers let you combine Tools, Resources, and Prompts into
17021700
an MCP Server with its own API key (see API Tokens).
17031701
</p>
17041702
</div>
1703+
<div class="flex items-center">
1704+
<input
1705+
type="checkbox"
1706+
id="show-inactive-servers"
1707+
class="mr-2"
1708+
onchange="toggleInactiveItems('servers')"
1709+
/>
1710+
<label
1711+
for="show-inactive-servers"
1712+
class="text-sm font-medium text-gray-700 dark:text-gray-300"
1713+
>Show Inactive</label
1714+
>
1715+
</div>
1716+
</div>
17051717

1718+
<!-- Tag Filtering for Virtual Servers -->
1719+
<div class="bg-white shadow rounded-lg p-4 mb-4 dark:bg-gray-800">
17061720
<div class="flex items-center space-x-4">
1721+
<label class="text-sm font-medium text-gray-700 dark:text-gray-300"
1722+
>Filter by Tags:</label
1723+
>
17071724
<input
17081725
type="text"
17091726
id="search-servers"
17101727
data-testid="search-input"
17111728
placeholder="Search servers via tags..."
1712-
class="mt-1 px-1.5 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:bg-gray-900 dark:placeholder-gray-300 dark:text-gray-300"
1729+
class="flex-1 rounded-md border border-gray-300 dark:border-gray-600 shadow-sm px-3 py-1 text-sm focus:border-indigo-500 focus:ring-indigo-500 dark:bg-gray-900 dark:text-gray-300"
17131730
oninput="filterServerTable(this.value)"
17141731
/>
17151732
<button

0 commit comments

Comments
 (0)