mirror of
https://github.com/coder/coder.git
synced 2026-10-24 01:26:25 +08:00
feat: Workspaces filtering (#1972)
Co-authored-by: G r e y <grey@coder.com> Co-authored-by: Kira Pilot <kira@coder.com>
This commit is contained in:
co-authored by
G r e y
Kira Pilot
parent
ac6cb269db
commit
8b03e2b0e1
@@ -118,10 +118,10 @@ describe("api.ts", () => {
|
||||
it.each<[TypesGen.WorkspaceFilter | undefined, string]>([
|
||||
[undefined, "/api/v2/workspaces"],
|
||||
|
||||
[{ OrganizationID: "1", Owner: "" }, "/api/v2/workspaces?organization_id=1"],
|
||||
[{ OrganizationID: "", Owner: "1" }, "/api/v2/workspaces?owner=1"],
|
||||
[{ organization_id: "1", owner: "" }, "/api/v2/workspaces?organization_id=1"],
|
||||
[{ organization_id: "", owner: "1" }, "/api/v2/workspaces?owner=1"],
|
||||
|
||||
[{ OrganizationID: "1", Owner: "me" }, "/api/v2/workspaces?organization_id=1&owner=me"],
|
||||
[{ organization_id: "1", owner: "me" }, "/api/v2/workspaces?organization_id=1&owner=me"],
|
||||
])(`getWorkspacesURL(%p) returns %p`, (filter, expected) => {
|
||||
expect(getWorkspacesURL(filter)).toBe(expected)
|
||||
})
|
||||
|
||||
+7
-4
@@ -117,11 +117,14 @@ export const getWorkspacesURL = (filter?: TypesGen.WorkspaceFilter): string => {
|
||||
const basePath = "/api/v2/workspaces"
|
||||
const searchParams = new URLSearchParams()
|
||||
|
||||
if (filter?.OrganizationID) {
|
||||
searchParams.append("organization_id", filter.OrganizationID)
|
||||
if (filter?.organization_id) {
|
||||
searchParams.append("organization_id", filter.organization_id)
|
||||
}
|
||||
if (filter?.Owner) {
|
||||
searchParams.append("owner", filter.Owner)
|
||||
if (filter?.owner) {
|
||||
searchParams.append("owner", filter.owner)
|
||||
}
|
||||
if (filter?.name) {
|
||||
searchParams.append("name", filter.name)
|
||||
}
|
||||
|
||||
const searchString = searchParams.toString()
|
||||
|
||||
@@ -443,8 +443,9 @@ export interface WorkspaceBuildsRequest extends Pagination {
|
||||
|
||||
// From codersdk/workspaces.go:200:6
|
||||
export interface WorkspaceFilter {
|
||||
readonly OrganizationID: string
|
||||
readonly Owner: string
|
||||
readonly organization_id?: string
|
||||
readonly owner?: string
|
||||
readonly name?: string
|
||||
}
|
||||
|
||||
// From codersdk/workspaceresources.go:21:6
|
||||
|
||||
Reference in New Issue
Block a user