mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
Doctor getWorkspaces
This commit is contained in:
+13
-3
@@ -279,10 +279,20 @@ export const getURLWithSearchParams = (
|
||||
}
|
||||
|
||||
export const getWorkspaces = async (
|
||||
filter?: TypesGen.WorkspaceFilter,
|
||||
options: TypesGen.AuditLogsRequest,
|
||||
): Promise<TypesGen.Workspace[]> => {
|
||||
const url = getURLWithSearchParams("/api/v2/workspaces", filter)
|
||||
const response = await axios.get<TypesGen.Workspace[]>(url)
|
||||
const searchParams = new URLSearchParams()
|
||||
if (options.limit) {
|
||||
searchParams.set("limit", options.limit.toString())
|
||||
}
|
||||
if (options.offset) {
|
||||
searchParams.set("offset", options.offset.toString())
|
||||
}
|
||||
if (options.q) {
|
||||
searchParams.set("q", options.q)
|
||||
}
|
||||
|
||||
const response = await axios.get<TypesGen.Workspace[]>(`/api/v2/workspaces?${searchParams.toString()}`)
|
||||
return response.data
|
||||
}
|
||||
|
||||
|
||||
@@ -418,7 +418,11 @@ export const workspacesMachine =
|
||||
},
|
||||
services: {
|
||||
getWorkspaces: (context) =>
|
||||
API.getWorkspaces(queryToFilter(context.filter)),
|
||||
API.getWorkspaces({
|
||||
...queryToFilter(context.filter),
|
||||
offset: (context.page - 1) * context.limit,
|
||||
limit: context.limit,
|
||||
}),
|
||||
updateWorkspaceRefs: (context, event) => {
|
||||
const refsToKeep: WorkspaceItemMachineRef[] = []
|
||||
context.workspaceRefs?.forEach((ref) => {
|
||||
|
||||
Reference in New Issue
Block a user