mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: implement fuzzy name matching for templates (#14211)
* chore: add fuzzy name search for templates * chore: implement fuzzy name matching for templates Templates search query defaults to a fuzzy name match
This commit is contained in:
@@ -405,8 +405,10 @@ func (c *Client) TemplatesByOrganization(ctx context.Context, organizationID uui
|
||||
}
|
||||
|
||||
type TemplateFilter struct {
|
||||
OrganizationID uuid.UUID
|
||||
ExactName string
|
||||
OrganizationID uuid.UUID `typescript:"-"`
|
||||
ExactName string `typescript:"-"`
|
||||
FuzzyName string `typescript:"-"`
|
||||
SearchQuery string `json:"q,omitempty"`
|
||||
}
|
||||
|
||||
// asRequestOption returns a function that can be used in (*Client).Request.
|
||||
@@ -424,6 +426,13 @@ func (f TemplateFilter) asRequestOption() RequestOption {
|
||||
params = append(params, fmt.Sprintf("exact_name:%q", f.ExactName))
|
||||
}
|
||||
|
||||
if f.FuzzyName != "" {
|
||||
params = append(params, fmt.Sprintf("name:%q", f.FuzzyName))
|
||||
}
|
||||
if f.SearchQuery != "" {
|
||||
params = append(params, f.SearchQuery)
|
||||
}
|
||||
|
||||
q := r.URL.Query()
|
||||
q.Set("q", strings.Join(params, " "))
|
||||
r.URL.RawQuery = q.Encode()
|
||||
|
||||
Reference in New Issue
Block a user