Skip to content

Conversation

@songyu-bytedance
Copy link
Collaborator

@songyu-bytedance songyu-bytedance commented Dec 17, 2025

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.

Copy link
Collaborator

@weilaaa weilaaa left a comment

Choose a reason for hiding this comment

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

/lgtm

@weilaaa weilaaa merged commit 6a40a79 into volcengine:main Dec 17, 2025
2 checks passed
weilaaa pushed a commit that referenced this pull request Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants