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:
Brett Kolodny
2025-09-16 12:37:39 -04:00
committed by GitHub
parent 8487216548
commit e6b04d1918
8 changed files with 282 additions and 5 deletions
+1
View File
@@ -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
+30
View File
@@ -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
{