Skip to content

Commit 9317155

Browse files
committed
Doctor getWorkspaces
1 parent 86caa80 commit 9317155

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

site/src/api/api.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,20 @@ export const getURLWithSearchParams = (
279279
}
280280

281281
export const getWorkspaces = async (
282-
filter?: TypesGen.WorkspaceFilter,
282+
options: TypesGen.AuditLogsRequest,
283283
): Promise<TypesGen.Workspace[]> => {
284-
const url = getURLWithSearchParams("/api/v2/workspaces", filter)
285-
const response = await axios.get<TypesGen.Workspace[]>(url)
284+
const searchParams = new URLSearchParams()
285+
if (options.limit) {
286+
searchParams.set("limit", options.limit.toString())
287+
}
288+
if (options.offset) {
289+
searchParams.set("offset", options.offset.toString())
290+
}
291+
if (options.q) {
292+
searchParams.set("q", options.q)
293+
}
294+
295+
const response = await axios.get<TypesGen.Workspace[]>(`/api/v2/workspaces?${searchParams.toString()}`)
286296
return response.data
287297
}
288298

site/src/xServices/workspaces/workspacesXService.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,11 @@ export const workspacesMachine =
418418
},
419419
services: {
420420
getWorkspaces: (context) =>
421-
API.getWorkspaces(queryToFilter(context.filter)),
421+
API.getWorkspaces({
422+
...queryToFilter(context.filter),
423+
offset: (context.page - 1) * context.limit,
424+
limit: context.limit,
425+
}),
422426
updateWorkspaceRefs: (context, event) => {
423427
const refsToKeep: WorkspaceItemMachineRef[] = []
424428
context.workspaceRefs?.forEach((ref) => {

0 commit comments

Comments
 (0)