Feat/host selection regex support #44
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR enhances the Zabbix host selection experience in the data source wizard under the /system/datasource module.
It adds regex and wildcard based search capabilities on top of the existing fuzzy search, enabling users to efficiently select multiple hosts that follow structured naming conventions such as AA--BB
Changes
Host search behavior
Extended the host search logic in instance-selection-configs.tsx to use a shared matcher.
The search now supports:
Plain substring search (backward compatible with the previous behavior).
Regex patterns like AA-\d+-BB.
Simple wildcard patterns using , e.g. AA--BB, server-*, -db-.
Shared matching utility
Enhanced the reusable matcher in filter.ts:
checkMatch(text, query):
First tries to interpret query as a regular expression (RegExp(query, 'i')).
If regex parsing fails, and query contains , converts * into . and builds a safe wildcard regex (^pattern$, case-insensitive).
Falls back to case‑insensitive substring matching when neither regex nor wildcard applies.
Keeps behavior safe for invalid patterns (e.g. [) by treating them as normal text instead of breaking search.
Type & import cleanup
Simplified imports in the host selection configs to use wizard aliases (e.g. @wizard/utils/filter, @wizard/types) instead of long relative paths.
Removed any casts by narrowing instance types (e.g. AliyunInstance & { userId?: string }) to keep TypeScript strict and clearer.
Type of Change
New feature (non-breaking enhancement to existing functionality)
Refactor / cleanup (types & imports)
Bug fix
Breaking change
Docs update
Testing
Manual verification
Verified that:
Entering a plain keyword (e.g. server) still performs case-insensitive fuzzy search and returns expected hosts.
Entering regex patterns such as AA-\d+-BB matches hosts like AA-12-BB, AA-99-BB and does not break when the pattern is invalid.
Entering wildcard patterns such as:
server-* matches server-01, server-test.
-db- matches names like prod-db-01.
Unit tests
E2E tests
API and Design Impact
No backend or API changes.
Frontend behavior is strictly backward compatible:
Existing fuzzy search continues to work.
Regex and wildcard support are additive enhancements for power users, improving multi-host selection workflows when host names follow structured patterns.