Skip to content

Commit c4b665b

Browse files
Adds missing properties for Azure workspaces and repos
1 parent f295ac3 commit c4b665b

File tree

6 files changed

+80
-23
lines changed

6 files changed

+80
-23
lines changed

src/env/browser/pathMapping/repositoryWebPathMappingProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ export class RepositoryWebPathMappingProvider implements RepositoryPathMappingPr
99

1010
async getLocalRepoPaths(_options: {
1111
remoteUrl?: string;
12-
repoInfo?: { provider: string; owner: string; repoName: string };
12+
repoInfo?: { provider?: string; owner?: string; repoName?: string };
1313
}): Promise<string[]> {
1414
return [];
1515
}
1616

1717
async writeLocalRepoPath(
18-
_options: { remoteUrl?: string; repoInfo?: { provider: string; owner: string; repoName: string } },
18+
_options: { remoteUrl?: string; repoInfo?: { provider?: string; owner?: string; repoName?: string } },
1919
_localPath: string,
2020
): Promise<void> {}
2121
}

src/env/node/pathMapping/repositoryLocalPathMappingProvider.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class RepositoryLocalPathMappingProvider implements RepositoryPathMapping
3030

3131
async getLocalRepoPaths(options: {
3232
remoteUrl?: string;
33-
repoInfo?: { provider: string; owner: string; repoName: string };
33+
repoInfo?: { provider?: string; owner?: string; repoName?: string };
3434
}): Promise<string[]> {
3535
const paths: string[] = [];
3636
if (options.remoteUrl != null) {
@@ -41,9 +41,11 @@ export class RepositoryLocalPathMappingProvider implements RepositoryPathMapping
4141
}
4242
if (options.repoInfo != null) {
4343
const { provider, owner, repoName } = options.repoInfo;
44-
const repoInfoPaths = await this._getLocalRepoPaths(`${provider}/${owner}/${repoName}`);
45-
if (repoInfoPaths != null) {
46-
paths.push(...repoInfoPaths);
44+
if (provider != null && owner != null && repoName != null) {
45+
const repoInfoPaths = await this._getLocalRepoPaths(`${provider}/${owner}/${repoName}`);
46+
if (repoInfoPaths != null) {
47+
paths.push(...repoInfoPaths);
48+
}
4749
}
4850
}
4951

@@ -66,7 +68,7 @@ export class RepositoryLocalPathMappingProvider implements RepositoryPathMapping
6668
}
6769

6870
async writeLocalRepoPath(
69-
options: { remoteUrl?: string; repoInfo?: { provider: string; owner: string; repoName: string } },
71+
options: { remoteUrl?: string; repoInfo?: { provider?: string; owner?: string; repoName?: string } },
7072
localPath: string,
7173
): Promise<void> {
7274
if (options.remoteUrl != null) {

src/pathMapping/repositoryPathMappingProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import type { Disposable } from 'vscode';
33
export interface RepositoryPathMappingProvider extends Disposable {
44
getLocalRepoPaths(options: {
55
remoteUrl?: string;
6-
repoInfo?: { provider: string; owner: string; repoName: string };
6+
repoInfo?: { provider?: string; owner?: string; repoName?: string };
77
}): Promise<string[]>;
88

99
writeLocalRepoPath(
10-
options: { remoteUrl?: string; repoInfo?: { provider: string; owner: string; repoName: string } },
10+
options: { remoteUrl?: string; repoInfo?: { provider?: string; owner?: string; repoName?: string } },
1111
localPath: string,
1212
): Promise<void>;
1313
}

src/plus/workspaces/models.ts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ export enum WorkspaceAutoAddSetting {
1313
Prompt = 'prompt',
1414
}
1515

16+
export enum WorkspaceRepositoryRelation {
17+
Direct = 'DIRECT',
18+
ProviderProject = 'PROVIDER_PROJECT',
19+
}
20+
1621
export type CodeWorkspaceFileContents = {
1722
folders: { path: string }[];
1823
settings: Record<string, any>;
@@ -69,7 +74,12 @@ export class CloudWorkspace {
6974
public readonly name: string,
7075
public readonly organizationId: string | undefined,
7176
public readonly provider: CloudWorkspaceProviderType,
77+
public readonly repoRelation: WorkspaceRepositoryRelation,
7278
public readonly current: boolean,
79+
public readonly azureInfo?: {
80+
organizationId?: string;
81+
project?: string;
82+
},
7383
repositories?: CloudWorkspaceRepositoryDescriptor[],
7484
localPath?: string,
7585
) {
@@ -147,10 +157,11 @@ export interface CloudWorkspaceRepositoryDescriptor {
147157
name: string;
148158
description: string;
149159
repository_id: string;
150-
provider: string;
160+
provider: string | null;
161+
provider_project_name: string | null;
151162
provider_organization_id: string;
152-
provider_organization_name: string;
153-
url: string;
163+
provider_organization_name: string | null;
164+
url: string | null;
154165
workspaceId: string;
155166
}
156167

@@ -203,12 +214,13 @@ export interface CloudWorkspaceData {
203214
name: string;
204215
description: string;
205216
type: CloudWorkspaceType;
206-
icon_url: string;
217+
icon_url: string | null;
207218
host_url: string;
208219
status: string;
209220
provider: string;
210-
azure_organization_id: string;
211-
azure_project: string;
221+
repo_relation: string;
222+
azure_organization_id: string | null;
223+
azure_project: string | null;
212224
created_date: Date;
213225
updated_date: Date;
214226
created_by: string;
@@ -313,10 +325,11 @@ export interface CloudWorkspaceRepositoryData {
313325
name: string;
314326
description: string;
315327
repository_id: string;
316-
provider: string;
328+
provider: string | null;
329+
provider_project_name: string | null;
317330
provider_organization_id: string;
318-
provider_organization_name: string;
319-
url: string;
331+
provider_organization_name: string | null;
332+
url: string | null;
320333
default_branch: string;
321334
branches: Branch[];
322335
pull_requests: CloudWorkspacePullRequestData[];

src/plus/workspaces/workspacesApi.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export class WorkspacesApi {
6666
name
6767
repository_id
6868
provider
69+
provider_project_name
6970
provider_organization_id
7071
provider_organization_name
7172
url
@@ -83,6 +84,9 @@ export class WorkspacesApi {
8384
id
8485
}
8586
provider
87+
azure_organization_id
88+
azure_project
89+
repo_relation
8690
${repoQuery ?? ''}
8791
`;
8892

@@ -143,6 +147,7 @@ export class WorkspacesApi {
143147
name
144148
repository_id
145149
provider
150+
provider_project_name
146151
provider_organization_id
147152
provider_organization_name
148153
url
@@ -166,6 +171,9 @@ export class WorkspacesApi {
166171
id
167172
}
168173
provider
174+
azure_organization_id
175+
azure_project
176+
repo_relation
169177
${repoQuery ?? ''}
170178
}
171179
`;
@@ -276,6 +284,7 @@ export class WorkspacesApi {
276284
name
277285
repository_id
278286
provider
287+
provider_project_name
279288
provider_organization_id
280289
provider_organization_name
281290
url
@@ -356,6 +365,9 @@ export class WorkspacesApi {
356365
id
357366
}
358367
provider
368+
azure_organization_id
369+
azure_project
370+
repo_relation
359371
}
360372
}
361373
`,
@@ -436,6 +448,7 @@ export class WorkspacesApi {
436448
name
437449
repository_id
438450
provider
451+
provider_project_name
439452
provider_organization_id
440453
provider_organization_name
441454
url

src/plus/workspaces/workspacesService.ts

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import type { SubscriptionChangeEvent } from '../subscription/subscriptionServic
1414
import type {
1515
AddWorkspaceRepoDescriptor,
1616
CloudWorkspaceData,
17-
CloudWorkspaceProviderType,
1817
CloudWorkspaceRepositoryDescriptor,
1918
GetWorkspacesResponse,
2019
LoadCloudWorkspacesResponse,
@@ -24,15 +23,18 @@ import type {
2423
RemoteDescriptor,
2524
RepositoryMatch,
2625
WorkspaceRepositoriesByName,
26+
WorkspaceRepositoryRelation,
2727
WorkspacesResponse,
2828
} from './models';
2929
import {
3030
CloudWorkspace,
3131
CloudWorkspaceProviderInputType,
32+
CloudWorkspaceProviderType,
3233
cloudWorkspaceProviderTypeToRemoteProviderId,
3334
LocalWorkspace,
3435
WorkspaceAddRepositoriesChoice,
3536
WorkspaceAutoAddSetting,
37+
WorkspaceType,
3638
} from './models';
3739
import { WorkspacesApi } from './workspacesApi';
3840
import type { WorkspacesPathMappingProvider } from './workspacesPathMappingProvider';
@@ -144,7 +146,14 @@ export class WorkspacesService implements Disposable {
144146
workspace.name,
145147
workspace.organization?.id,
146148
workspace.provider as CloudWorkspaceProviderType,
149+
workspace.repo_relation as WorkspaceRepositoryRelation,
147150
this._currentWorkspaceId != null && this._currentWorkspaceId === workspace.id,
151+
workspace.provider === CloudWorkspaceProviderType.Azure
152+
? {
153+
organizationId: workspace.azure_organization_id ?? undefined,
154+
project: workspace.azure_project ?? undefined,
155+
}
156+
: undefined,
148157
repositories,
149158
localPath,
150159
),
@@ -264,7 +273,14 @@ export class WorkspacesService implements Disposable {
264273
workspaceData.data.project.name,
265274
workspaceData.data.project.organization?.id,
266275
workspaceData.data.project.provider as CloudWorkspaceProviderType,
276+
workspaceData.data.project.repo_relation as WorkspaceRepositoryRelation,
267277
true,
278+
workspaceData.data.project.provider === CloudWorkspaceProviderType.Azure
279+
? {
280+
organizationId: workspaceData.data.project.azure_organization_id ?? undefined,
281+
project: workspaceData.data.project.azure_project ?? undefined,
282+
}
283+
: undefined,
268284
repositories,
269285
workspace.workspaceFile?.fsPath,
270286
);
@@ -476,12 +492,18 @@ export class WorkspacesService implements Disposable {
476492
await this.container.repositoryPathMapping.writeLocalRepoPath({ remoteUrl: remoteUrl }, repoPath);
477493
}
478494

479-
if (descriptor.id != null) {
495+
const workspace = this.getCloudWorkspace(workspaceId) ?? this.getLocalWorkspace(workspaceId);
496+
let provider: string | undefined;
497+
if (provider == null && workspace?.type === WorkspaceType.Cloud) {
498+
provider = workspace.provider;
499+
}
500+
501+
if (descriptor.id != null && descriptor.url != null && provider != null) {
480502
await this.container.repositoryPathMapping.writeLocalRepoPath(
481503
{
482504
remoteUrl: descriptor.url,
483505
repoInfo: {
484-
provider: descriptor.provider,
506+
provider: provider,
485507
owner: descriptor.provider_organization_id,
486508
repoName: descriptor.name,
487509
},
@@ -712,7 +734,14 @@ export class WorkspacesService implements Disposable {
712734
createdProjectData.name,
713735
createdProjectData.organization?.id,
714736
createdProjectData.provider as CloudWorkspaceProviderType,
737+
createdProjectData.repo_relation as WorkspaceRepositoryRelation,
715738
this._currentWorkspaceId != null && this._currentWorkspaceId === createdProjectData.id,
739+
createdProjectData.provider === CloudWorkspaceProviderType.Azure
740+
? {
741+
organizationId: createdProjectData.azure_organization_id ?? undefined,
742+
project: createdProjectData.azure_project ?? undefined,
743+
}
744+
: undefined,
716745
[],
717746
localPath,
718747
),
@@ -1287,10 +1316,10 @@ export class WorkspacesService implements Disposable {
12871316
if (repoLocalPath == null) {
12881317
repoLocalPath = (
12891318
await this.container.repositoryPathMapping.getLocalRepoPaths({
1290-
remoteUrl: descriptor.url,
1319+
remoteUrl: descriptor.url ?? undefined,
12911320
repoInfo: {
12921321
repoName: descriptor.name,
1293-
provider: descriptor.provider,
1322+
provider: descriptor.provider ?? undefined,
12941323
owner: descriptor.provider_organization_id,
12951324
},
12961325
})

0 commit comments

Comments
 (0)