Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitff034db

Browse files
committed
feat: add shared_with_user search filter
1 parentefec4e6 commitff034db

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

‎coderd/searchquery/search.go‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ func Workspaces(ctx context.Context, db database.Store, query string, page coder
226226
filter.HasExternalAgent=parser.NullableBoolean(values, sql.NullBool{},"has_external_agent")
227227
filter.OrganizationID=parseOrganization(ctx,db,parser,values,"organization")
228228
filter.Shared=parser.NullableBoolean(values, sql.NullBool{},"shared")
229+
filter.SharedWithUserID=parseUser(ctx,db,parser,values,"shared_with_user")
229230

230231
typeparamMatchstruct {
231232
namestring
@@ -363,6 +364,25 @@ func parseOrganization(ctx context.Context, db database.Store, parser *httpapi.Q
363364
})
364365
}
365366

367+
funcparseUser(ctx context.Context,db database.Store,parser*httpapi.QueryParamParser,vals url.Values,queryParamstring) uuid.UUID {
368+
returnhttpapi.ParseCustom(parser,vals,uuid.Nil,queryParam,func(vstring) (uuid.UUID,error) {
369+
ifv=="" {
370+
returnuuid.Nil,nil
371+
}
372+
userID,err:=uuid.Parse(v)
373+
iferr==nil {
374+
returnuserID,nil
375+
}
376+
user,err:=db.GetUserByEmailOrUsername(ctx, database.GetUserByEmailOrUsernameParams{
377+
Username:v,
378+
})
379+
iferr!=nil {
380+
returnuuid.Nil,xerrors.Errorf("user %q either does not exist, or you are unauthorized to view them",v)
381+
}
382+
returnuser.ID,nil
383+
})
384+
}
385+
366386
// splitQueryParameterByDelimiter takes a query string and splits it into the individual elements
367387
// of the query. Each element is separated by a delimiter. All quoted strings are
368388
// kept as a single element.

‎codersdk/workspaces.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,8 @@ type WorkspaceFilter struct {
518518
Limitint`json:"limit,omitempty" typescript:"-"`
519519
// Shared is a whether the workspace is shared with any users or groups
520520
Shared*bool`json:"shared,omitempty" typescript:"-"`
521+
// SharedWithUser is the username or ID of the user that the workspace is shared with
522+
SharedWithUserstring`json:"shared_with_user,omitempty" typescript:"-"`
521523
// FilterQuery supports a raw filter query string
522524
FilterQuerystring`json:"q,omitempty"`
523525
}
@@ -544,6 +546,9 @@ func (f WorkspaceFilter) asRequestOption() RequestOption {
544546
iff.Shared!=nil {
545547
params=append(params,fmt.Sprintf("shared:%v",*f.Shared))
546548
}
549+
iff.SharedWithUser!="" {
550+
params=append(params,fmt.Sprintf("shared_with_user:%q",f.SharedWithUser))
551+
}
547552
iff.FilterQuery!="" {
548553
// If custom stuff is added, just add it on here.
549554
params=append(params,f.FilterQuery)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp