Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix workspace search under user detail #8562

Merged
merged 1 commit into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion components/dashboard/src/admin/WorkspacesSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
4 changes: 4 additions & 0 deletions components/gitpod-db/src/typeorm/workspace-db-impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions components/gitpod-protocol/src/admin-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,5 @@ export type AdminGetWorkspacesQuery = {
instanceIdOrWorkspaceId?: string;
instanceId?: string;
workspaceId?: string;
ownerId?: string;
};