-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only allow exact-matching of workspace search #8632
Conversation
Codecov Report
@@ Coverage Diff @@
## main #8632 +/- ##
==========================================
- Coverage 14.87% 11.17% -3.70%
==========================================
Files 52 18 -34
Lines 4963 993 -3970
==========================================
- Hits 738 111 -627
+ Misses 4153 880 -3273
+ Partials 72 2 -70
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
if (!props.user) { // In the workspace search page | ||
// This only allows searching for exact-matches of workspace or instance IDs | ||
if ((queryTerm.length === 0) || | ||
(!matchesNewWorkspaceIdExactly(queryTerm) && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO we should try to avoid calling the matches
functions multiple times.
One way do to that is to move it too line 79 👇
There we could do:
if (!props.user) {
if (queryTerm.length === 0 || (!query.instanceIdOrWorkspaceId && !query.workspaceId)) {
return;
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, good point!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@geropl I was thinking we could return early when there is an empty search, and then check further down if they're partial matches, like so:
const search = async () => {
// Disables empty search on the workspace search page
if (!props.user && queryTerm.length === 0) {
return;
}
setSearching(true);
try {
...
if (!query.ownerId && !query.instanceIdOrWorkspaceId && !query.workspaceId) {
return;
}
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - thx for caring and improving safety! 🙏
@@ -105,6 +114,10 @@ export function WorkspaceSearch(props: Props) { | |||
<button disabled={searching} onClick={search}>Search</button> | |||
</div> | |||
</div> | |||
<div className={'flex rounded-xl bg-gray-200 dark:bg-gray-800 text-gray-600 dark:text-gray-400 p-2 w-2/3 mb-2'}> | |||
<img className="w-4 h-4 m-1 ml-2 mr-4" alt="info" src={info} /> | |||
<span>Please enter complete IDs - this search does not perform partial-matching.</span> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one hurt! Opened #8701 to improve this.
Description
This PR disables empty string and partial match search.
Related Issue(s)
Fixes #8614
How to test
Release Notes
Documentation