mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: add shared filter to workspaces query (#19807)
Adds a `shared:<boolean>` search query to the `/workspaces [get]` endpoint https://github.com/user-attachments/assets/ccf84bd9-c1fd-4085-825b-2e3176a2d488 Closes [coder/internal#972](https://github.com/coder/internal/issues/972)
This commit is contained in:
@@ -225,6 +225,7 @@ func Workspaces(ctx context.Context, db database.Store, query string, page coder
|
||||
filter.HasAITask = parser.NullableBoolean(values, sql.NullBool{}, "has-ai-task")
|
||||
filter.HasExternalAgent = parser.NullableBoolean(values, sql.NullBool{}, "has_external_agent")
|
||||
filter.OrganizationID = parseOrganization(ctx, db, parser, values, "organization")
|
||||
filter.Shared = parser.NullableBoolean(values, sql.NullBool{}, "shared")
|
||||
|
||||
type paramMatch struct {
|
||||
name string
|
||||
|
||||
@@ -282,6 +282,36 @@ func TestSearchWorkspace(t *testing.T) {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "SharedTrue",
|
||||
Query: "shared:true",
|
||||
Expected: database.GetWorkspacesParams{
|
||||
Shared: sql.NullBool{
|
||||
Bool: true,
|
||||
Valid: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "SharedFalse",
|
||||
Query: "shared:false",
|
||||
Expected: database.GetWorkspacesParams{
|
||||
Shared: sql.NullBool{
|
||||
Bool: false,
|
||||
Valid: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "SharedMissing",
|
||||
Query: "",
|
||||
Expected: database.GetWorkspacesParams{
|
||||
Shared: sql.NullBool{
|
||||
Bool: false,
|
||||
Valid: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// Failures
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user