Skip to content

fix(ui): Admin UI "Select All" now respects search filters for tools/resources/prompts - #3968

Merged
crivetimihai merged 2 commits into
mainfrom
3950-bug-admin-ui-associated-tools-select-all-does-not-limit-to-searched-returned-values
Apr 5, 2026
Merged

crivetimihai merged 2 commits into
mainfrom
3950-bug-admin-ui-associated-tools-select-all-does-not-limit-to-searched-returned-values

Conversation

@bogdanmariusc10

Copy link
Copy Markdown
Collaborator

🔗 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:

  • Added search query parameter q to three backend endpoints: /admin/tools/ids, /admin/resources/ids and /admin/prompts/ids
  • Updated frontend JavaScript selectors to detect and pass the active search term to the backend
  • Implemented case-insensitive search across multiple fields (ID, name, description, gateway name)
  • Works in both "Add Server" and "Edit Server" modes

Impact: 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

  • Bug fix
  • Feature / Enhancement
  • Documentation
  • Refactor
  • Chore (deps, CI, tooling)
  • Other (describe below)

🧪 Verification

Check Command Status
Lint suite make lint ✅ Pass
Unit tests make test ✅ Pass
Coverage ≥ 80% make coverage ✅ Pass

✅ Checklist

  • Code formatted (make black isort pre-commit)
  • Tests added/updated for changes
  • Documentation updated (if applicable)
  • No secrets or credentials committed

📓 Notes

Backend Changes (mcpgateway/admin.py):

  • /admin/tools/ids endpoint (lines 8714-8761)
  • /admin/resources/ids endpoint (lines 10058-10107)
  • /admin/prompts/ids endpoint (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:

  • Search with query parameter
  • Empty search query handling
  • Search with gateway filter
  • Search with team filter
  • Search with no results
  • Case-insensitive search
  • Combined filters (search + gateway + team)

Technical Details

The fix detects the appropriate search input element based on the context:

Add Server mode: Uses #searchTools, #searchResources, #searchPrompts
Edit Server mode: Uses #searchEditTools, #searchEditResources, #searchEditPrompts

Search is case-insensitive and uses the existing _normalize_search_query() and _like_contains() helper functions for consistency with other search implementations in the codebase.

@bogdanmariusc10 bogdanmariusc10 added the ui User Interface label Apr 1, 2026
@bogdanmariusc10 bogdanmariusc10 added the SHOULD P2: Important but not vital; high-value items that are not crucial for the immediate release label Apr 1, 2026
@bogdanmariusc10 bogdanmariusc10 added the api REST API Related item label Apr 1, 2026
Bogdan-Marius-Catanus and others added 2 commits April 5, 2026 00:49
…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>
@crivetimihai
crivetimihai force-pushed the 3950-bug-admin-ui-associated-tools-select-all-does-not-limit-to-searched-returned-values branch from 8f3011a to d2e64bf Compare April 5, 2026 09:10

@crivetimihai crivetimihai left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. Duplicate include_inactive filter — the prompts/ids and resources/ids endpoints each applied the enabled.is_(True) WHERE clause twice. Removed the duplicates.

  2. Prompt search field mismatch — the prompt IDs endpoint was searching DbPrompt.name, but the HTML partial searches original_name and display_name. This would cause Select All to return different items than the visible filtered list. Updated to match.

  3. 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 an include_public query parameter (default false) to all three IDs endpoints, mirroring the partial endpoints. The frontend now reads the view-public checkbox and passes include_public=true when appropriate.

Tests added

  • 3 new Python tests for the include_public parameter
  • 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_public toggle, backward compatibility, auth enforcement, and SQL injection resistance all confirmed working correctly.

@crivetimihai
crivetimihai merged commit 8ee277a into main Apr 5, 2026
27 checks passed
@crivetimihai
crivetimihai deleted the 3950-bug-admin-ui-associated-tools-select-all-does-not-limit-to-searched-returned-values branch April 5, 2026 09:32
jonpspri pushed a commit that referenced this pull request Apr 10, 2026
…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>
claudia-gray pushed a commit that referenced this pull request Apr 13, 2026
…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>
msureshkumar88 pushed a commit that referenced this pull request May 13, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api REST API Related item SHOULD P2: Important but not vital; high-value items that are not crucial for the immediate release ui User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Admin UI Associated Tools Select all does not limit to searched returned values

2 participants