Skip to content

Commit 3bace2d

Browse files
AlexTugarevroboquat
authored andcommitted
[projects] fix project association for workspaces based on prebuilds
1 parent c2b701b commit 3bace2d

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

components/server/ee/src/workspace/workspace-factory.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,27 @@ export class WorkspaceFactoryEE extends WorkspaceFactory {
205205
extensions: config && config.vscode && config.vscode.extensions || []
206206
}
207207

208+
const project = await this.projectDB.findProjectByCloneUrl(context.prebuiltWorkspace.cloneURL);
209+
let projectId: string | undefined;
210+
// associate with a project, if it's the personal project of the current user
211+
if (project?.userId && project?.userId === user.id) {
212+
projectId = project.id;
213+
}
214+
// associate with a project, if the current user is a team member
215+
if (project?.teamId) {
216+
const teams = await this.teamDB.findTeamsByUser(user.id);
217+
if (teams.some(t => t.id === project?.teamId)) {
218+
projectId = project.id;
219+
}
220+
}
221+
208222
const id = await generateWorkspaceID();
209223
const newWs: Workspace = {
210224
id,
211225
type: "regular",
212226
creationTime: new Date().toISOString(),
213227
contextURL: normalizedContextURL,
214-
projectId: context.prebuiltWorkspace.projectId,
228+
projectId,
215229
description: this.getDescription(context),
216230
ownerId: user.id,
217231
context: <WorkspaceContext & WithSnapshot & WithPrebuild>{

0 commit comments

Comments
 (0)