diff --git a/components/dashboard/src/admin/WorkspacesSearch.tsx b/components/dashboard/src/admin/WorkspacesSearch.tsx index 612f3ae743b1be..edb3c1cc758d1b 100644 --- a/components/dashboard/src/admin/WorkspacesSearch.tsx +++ b/components/dashboard/src/admin/WorkspacesSearch.tsx @@ -68,7 +68,9 @@ export function WorkspaceSearch(props: Props) { const search = async () => { setSearching(true); try { - const query: AdminGetWorkspacesQuery = {}; + const query: AdminGetWorkspacesQuery = { + ownerId: props?.user?.id, // Workspace search in admin user detail + }; if (matchesInstanceIdOrLegacyWorkspaceIdExactly(queryTerm)) { query.instanceIdOrWorkspaceId = queryTerm; } else if (matchesNewWorkspaceIdExactly(queryTerm)) { diff --git a/components/gitpod-db/src/typeorm/workspace-db-impl.ts b/components/gitpod-db/src/typeorm/workspace-db-impl.ts index c5c2c42ebd30ef..7393df8075847f 100644 --- a/components/gitpod-db/src/typeorm/workspace-db-impl.ts +++ b/components/gitpod-db/src/typeorm/workspace-db-impl.ts @@ -768,6 +768,10 @@ export abstract class AbstractTypeORMWorkspaceDBImpl implements WorkspaceDB { } else if (query.workspaceId) { whereConditions.push("ws.id = :workspaceId"); whereConditionParams.workspaceId = query.workspaceId; + } else if (query.ownerId) { + // If an owner id is provided only search for workspaces belonging to that user. + whereConditions.push("ws.ownerId = :ownerId"); + whereConditionParams.ownerId = query.ownerId; } else if (query.instanceId) { // in addition to adding "instanceId" to the "WHERE" clause like for the other workspace-guided queries, // we modify the JOIN condition below to a) select the correct instance and b) make the query faster diff --git a/components/gitpod-protocol/src/admin-protocol.ts b/components/gitpod-protocol/src/admin-protocol.ts index 391b7166b802c6..5c23f40691ea29 100644 --- a/components/gitpod-protocol/src/admin-protocol.ts +++ b/components/gitpod-protocol/src/admin-protocol.ts @@ -116,4 +116,5 @@ export type AdminGetWorkspacesQuery = { instanceIdOrWorkspaceId?: string; instanceId?: string; workspaceId?: string; + ownerId?: string; };