Repository navigation
fix(ui): Admin UI "Select All" now respects search filters for tools/resources/prompts - #3968
Conversation
…sources/prompts Add search query parameter 'q' to /admin/tools/ids, /admin/resources/ids, and /admin/prompts/ids endpoints. Update frontend selectors to pass active search term to backend APIs. Support both Add Server and Edit Server modes by detecting appropriate search input IDs. Add comprehensive unit tests covering search functionality with various filter combinations. Closes #3950 Signed-off-by: Bogdan-Marius-Catanus <bogdan-marius.catanus@ibm.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
…and search field bugs - Port search query parameter passing from deleted monolithic admin.js to modular files: tools.js, resources.js, prompts.js in admin_ui/ - Remove duplicate include_inactive filter in prompt and resource IDs endpoints - Fix prompt IDs endpoint search fields to match HTML partial (original_name, display_name instead of name) for consistent search results - Add include_public parameter to all 3 IDs endpoints so Select All respects the "View Public" checkbox state, matching the visible filtered list in team-scoped mode - Pass include_public from frontend Select All handlers by reading the view-public checkbox for both add and edit server modes - Add JS unit tests for Select All search parameter passing in all 3 modules - Add Python tests for include_public parameter Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
8f3011a to
d2e64bf
Compare
crivetimihai
left a comment
There was a problem hiding this comment.
Nice work on this fix, @bogdanmariusc10 — the core idea of wiring search queries into the Select All endpoints is solid.
During rebase I resolved a couple of conflicts and made some additional fixes worth calling out:
Rebase changes
The monolithic admin.js was split into modules under admin_ui/ in #3137, so I ported your frontend changes to tools.js, resources.js, and prompts.js using the correct search input element IDs from the modular codebase (searchTools/searchEditTools, etc.).
Bugs fixed
-
Duplicate
include_inactivefilter — the prompts/ids and resources/ids endpoints each applied theenabled.is_(True)WHERE clause twice. Removed the duplicates. -
Prompt search field mismatch — the prompt IDs endpoint was searching
DbPrompt.name, but the HTML partial searchesoriginal_nameanddisplay_name. This would cause Select All to return different items than the visible filtered list. Updated to match. -
Team-scope divergence — the IDs endpoints unconditionally included all platform-public items via a hardcoded
visibility == "public"OR condition, but the visible list only includes them when the "View Public" checkbox is checked. Added aninclude_publicquery parameter (defaultfalse) to all three IDs endpoints, mirroring the partial endpoints. The frontend now reads the view-public checkbox and passesinclude_public=truewhen appropriate.
Tests added
- 3 new Python tests for the
include_publicparameter - 7 JS tests covering search param passing for add/edit modes across all three entity types
- Updated 3 existing regression tests (#3446) to pass
include_public=True
Verified
- All 14 Python unit tests pass
- All 166 JS unit tests pass
- E2E tested against a live deployment: search filtering, case insensitivity, team scoping,
include_publictoggle, backward compatibility, auth enforcement, and SQL injection resistance all confirmed working correctly.
…resources/prompts (#3968) * fix(ui): Admin UI Select All now respects search filters for tools/resources/prompts Add search query parameter 'q' to /admin/tools/ids, /admin/resources/ids, and /admin/prompts/ids endpoints. Update frontend selectors to pass active search term to backend APIs. Support both Add Server and Edit Server modes by detecting appropriate search input IDs. Add comprehensive unit tests covering search functionality with various filter combinations. Closes #3950 Signed-off-by: Bogdan-Marius-Catanus <bogdan-marius.catanus@ibm.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> * fix(ui): port Select All search filter to modular JS, fix team-scope and search field bugs - Port search query parameter passing from deleted monolithic admin.js to modular files: tools.js, resources.js, prompts.js in admin_ui/ - Remove duplicate include_inactive filter in prompt and resource IDs endpoints - Fix prompt IDs endpoint search fields to match HTML partial (original_name, display_name instead of name) for consistent search results - Add include_public parameter to all 3 IDs endpoints so Select All respects the "View Public" checkbox state, matching the visible filtered list in team-scoped mode - Pass include_public from frontend Select All handlers by reading the view-public checkbox for both add and edit server modes - Add JS unit tests for Select All search parameter passing in all 3 modules - Add Python tests for include_public parameter Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> --------- Signed-off-by: Bogdan-Marius-Catanus <bogdan-marius.catanus@ibm.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> Co-authored-by: Bogdan-Marius-Catanus <bogdan-marius.catanus@ibm.com> Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
…resources/prompts (#3968) * fix(ui): Admin UI Select All now respects search filters for tools/resources/prompts Add search query parameter 'q' to /admin/tools/ids, /admin/resources/ids, and /admin/prompts/ids endpoints. Update frontend selectors to pass active search term to backend APIs. Support both Add Server and Edit Server modes by detecting appropriate search input IDs. Add comprehensive unit tests covering search functionality with various filter combinations. Closes #3950 Signed-off-by: Bogdan-Marius-Catanus <bogdan-marius.catanus@ibm.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> * fix(ui): port Select All search filter to modular JS, fix team-scope and search field bugs - Port search query parameter passing from deleted monolithic admin.js to modular files: tools.js, resources.js, prompts.js in admin_ui/ - Remove duplicate include_inactive filter in prompt and resource IDs endpoints - Fix prompt IDs endpoint search fields to match HTML partial (original_name, display_name instead of name) for consistent search results - Add include_public parameter to all 3 IDs endpoints so Select All respects the "View Public" checkbox state, matching the visible filtered list in team-scoped mode - Pass include_public from frontend Select All handlers by reading the view-public checkbox for both add and edit server modes - Add JS unit tests for Select All search parameter passing in all 3 modules - Add Python tests for include_public parameter Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> --------- Signed-off-by: Bogdan-Marius-Catanus <bogdan-marius.catanus@ibm.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> Co-authored-by: Bogdan-Marius-Catanus <bogdan-marius.catanus@ibm.com> Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
…resources/prompts (#3968) * fix(ui): Admin UI Select All now respects search filters for tools/resources/prompts Add search query parameter 'q' to /admin/tools/ids, /admin/resources/ids, and /admin/prompts/ids endpoints. Update frontend selectors to pass active search term to backend APIs. Support both Add Server and Edit Server modes by detecting appropriate search input IDs. Add comprehensive unit tests covering search functionality with various filter combinations. Closes #3950 Signed-off-by: Bogdan-Marius-Catanus <bogdan-marius.catanus@ibm.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> * fix(ui): port Select All search filter to modular JS, fix team-scope and search field bugs - Port search query parameter passing from deleted monolithic admin.js to modular files: tools.js, resources.js, prompts.js in admin_ui/ - Remove duplicate include_inactive filter in prompt and resource IDs endpoints - Fix prompt IDs endpoint search fields to match HTML partial (original_name, display_name instead of name) for consistent search results - Add include_public parameter to all 3 IDs endpoints so Select All respects the "View Public" checkbox state, matching the visible filtered list in team-scoped mode - Pass include_public from frontend Select All handlers by reading the view-public checkbox for both add and edit server modes - Add JS unit tests for Select All search parameter passing in all 3 modules - Add Python tests for include_public parameter Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> --------- Signed-off-by: Bogdan-Marius-Catanus <bogdan-marius.catanus@ibm.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> Co-authored-by: Bogdan-Marius-Catanus <bogdan-marius.catanus@ibm.com> Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
🔗 Related Issue
Closes #3950
📝 Summary
Fixed a bug in the Admin UI where the "Select All" button for tools, resources, and prompts was selecting ALL items in the system instead of respecting the active search filter.
Problem: When users searched for specific tools/resources/prompts and clicked "Select All", it would select every item in the database rather than just the filtered search results.
Solution:
qto three backend endpoints:/admin/tools/ids,/admin/resources/idsand/admin/prompts/idsImpact: Users can now search for specific items and use "Select All" to select only the filtered results, providing the expected UX behavior.
🏷️ Type of Change
🧪 Verification
make lintmake testmake coverage✅ Checklist
make black isort pre-commit)📓 Notes
Backend Changes (
mcpgateway/admin.py):/admin/tools/idsendpoint (lines 8714-8761)/admin/resources/idsendpoint (lines 10058-10107)/admin/prompts/idsendpoint (lines 9973-10019)Frontend Changes (
mcpgateway/static/admin.js):initToolSelect()function (lines 9976-9980)initResourceSelect()function (lines 10420-10423)initPromptSelect()function (lines 10851-10854)Tests Added (
tests/unit/mcpgateway/test_admin_ids_search.py):11 comprehensive unit tests covering:
Technical Details
The fix detects the appropriate search input element based on the context:
Add Server mode: Uses
#searchTools,#searchResources,#searchPromptsEdit Server mode: Uses
#searchEditTools,#searchEditResources,#searchEditPromptsSearch is case-insensitive and uses the existing
_normalize_search_query()and_like_contains()helper functions for consistency with other search implementations in the codebase.