@@ -20,7 +20,7 @@ import { converter } from "./public-api";
20
20
import { getGitpodService } from "./service" ;
21
21
import { PaginationResponse } from "@gitpod/public-api/lib/gitpod/v1/pagination_pb" ;
22
22
import { generateAsyncGenerator } from "@gitpod/gitpod-protocol/lib/generate-async-generator" ;
23
- import { WorkspaceInstance } from "@gitpod/gitpod-protocol" ;
23
+ import { GetWorkspacesScope , WorkspaceInstance } from "@gitpod/gitpod-protocol" ;
24
24
25
25
export class JsonRpcWorkspaceClient implements PromiseClient < typeof WorkspaceService > {
26
26
async getWorkspace ( request : PartialMessage < GetWorkspaceRequest > ) : Promise < GetWorkspaceResponse > {
@@ -90,24 +90,28 @@ export class JsonRpcWorkspaceClient implements PromiseClient<typeof WorkspaceSer
90
90
_options ?: CallOptions ,
91
91
) : Promise < ListWorkspacesResponse > {
92
92
request . scope = request . scope ?? ListWorkspacesRequest_Scope . MY_WORKSPACES_IN_ORGANIZATION ;
93
- if (
94
- request . scope === ListWorkspacesRequest_Scope . MY_WORKSPACES_IN_ORGANIZATION ||
95
- request . scope === ListWorkspacesRequest_Scope . ALL_WORKSPACES_IN_ORGANIZATION
96
- ) {
97
- throw new ConnectError ( "organization_id is required" , Code . InvalidArgument ) ;
93
+ let getWorkspacesScope : GetWorkspacesScope = GetWorkspacesScope . MY_WORKSPACES_IN_ORGANIZATION ;
94
+ if ( request . scope === ListWorkspacesRequest_Scope . ALL_WORKSPACES_IN_INSTALLATION ) {
95
+ getWorkspacesScope = GetWorkspacesScope . ALL_WORKSPACES_IN_INSTALLATION ;
96
+ } else if ( request . scope === ListWorkspacesRequest_Scope . ALL_WORKSPACES_IN_ORGANIZATION ) {
97
+ getWorkspacesScope = GetWorkspacesScope . ALL_WORKSPACES_IN_ORGANIZATION ;
98
+ } else if ( request . scope === ListWorkspacesRequest_Scope . MY_WORKSPACES_IN_ORGANIZATION ) {
99
+ getWorkspacesScope = GetWorkspacesScope . MY_WORKSPACES_IN_ORGANIZATION ;
98
100
}
99
101
const server = getGitpodService ( ) . server ;
100
102
const pageSize = request . pagination ?. pageSize || 100 ;
101
- const workspaces = await server . getWorkspaces ( {
103
+ const results = await server . getWorkspaces ( {
102
104
organizationId : request . organizationId ,
103
- pinnedOnly : request . pinned === true ? true : undefined ,
105
+ pinnedOnly : request . pinned ,
104
106
limit : pageSize ,
105
107
offset : ( request . pagination ?. page ?? 0 ) * pageSize ,
108
+ searchString : request . searchTerm ,
109
+ scope : getWorkspacesScope ,
106
110
} ) ;
107
111
const response = new ListWorkspacesResponse ( ) ;
108
- response . workspaces = workspaces . map ( ( info ) => converter . toWorkspace ( info ) ) ;
112
+ response . workspaces = results . rows . map ( ( info ) => converter . toWorkspace ( info ) ) ;
109
113
response . pagination = new PaginationResponse ( ) ;
110
- response . pagination . total = workspaces . length ;
114
+ response . pagination . total = results . total ;
111
115
return response ;
112
116
}
113
117
}
0 commit comments