Skip to content

Commit

Permalink
fix: Allow spaces in searches (#2723)
Browse files Browse the repository at this point in the history
  • Loading branch information
Emyrk committed Jun 29, 2022
1 parent 889e2e6 commit baa3618
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
9 changes: 9 additions & 0 deletions coderd/users_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ func TestSearchUsers(t *testing.T) {
RbacRole: []string{},
},
},
{
Name: "UsernameWithSpaces",
Query: " user-name ",
Expected: database.GetUsersParams{
Search: "user-name",
Status: []database.UserStatus{},
RbacRole: []string{},
},
},
{
Name: "Username+Param",
Query: "usEr-name stAtus:actiVe",
Expand Down
8 changes: 8 additions & 0 deletions coderd/workspaces_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ func TestSearchWorkspace(t *testing.T) {
Name: "bar",
},
},
{
Name: "Owner/NameWithSpaces",
Query: " Foo/Bar ",
Expected: database.GetWorkspacesParams{
OwnerUsername: "foo",
Name: "bar",
},
},
{
Name: "Name",
Query: "workspace-name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import SearchIcon from "@material-ui/icons/Search"
import { FormikErrors, useFormik } from "formik"
import { useState } from "react"
import { getValidationErrorMessage } from "../../api/errors"
import { getFormHelpers, onChangeTrimmed } from "../../util/formUtils"
import { getFormHelpers } from "../../util/formUtils"
import { CloseDropdown, OpenDropdown } from "../DropdownArrows/DropdownArrows"
import { Stack } from "../Stack/Stack"

Expand Down Expand Up @@ -91,7 +91,7 @@ export const SearchBarWithFilter: React.FC<SearchBarWithFilterProps> = ({
<TextField
{...getFieldHelpers("query")}
className={styles.textFieldRoot}
onChange={onChangeTrimmed(form)}
onChange={form.handleChange}
fullWidth
variant="outlined"
InputProps={{
Expand Down

0 comments on commit baa3618

Please sign in to comment.