mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: support 'me' as the username for template author (#19204)
`author:me` to find my templates. Much nicer than knowing my own username
This commit is contained in:
@@ -263,7 +263,7 @@ func Workspaces(ctx context.Context, db database.Store, query string, page coder
|
||||
return filter, parser.Errors
|
||||
}
|
||||
|
||||
func Templates(ctx context.Context, db database.Store, query string) (database.GetTemplatesWithFilterParams, []codersdk.ValidationError) {
|
||||
func Templates(ctx context.Context, db database.Store, actorID uuid.UUID, query string) (database.GetTemplatesWithFilterParams, []codersdk.ValidationError) {
|
||||
// Always lowercase for all searches.
|
||||
query = strings.ToLower(query)
|
||||
values, errors := searchTerms(query, func(term string, values url.Values) error {
|
||||
@@ -288,6 +288,11 @@ func Templates(ctx context.Context, db database.Store, query string) (database.G
|
||||
AuthorUsername: parser.String(values, "", "author"),
|
||||
}
|
||||
|
||||
if filter.AuthorUsername == codersdk.Me {
|
||||
filter.AuthorID = actorID
|
||||
filter.AuthorUsername = ""
|
||||
}
|
||||
|
||||
parser.ErrorExcessParams(values)
|
||||
return filter, parser.Errors
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user