Skip to content

Commit 0b43586

Browse files
committed
Applied patch
1 parent c99d48a commit 0b43586

22 files changed

+728
-35
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Build
22

33
on:
4+
workflow_dispatch: {}
45
push:
56
branches:
67
- '**'

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ Stay in the flow by using Atlassian for VSCode to start work on a JIRA issue, ra
77

88
[**Download now**](https://marketplace.visualstudio.com/items?itemName=Atlassian.atlascode&ssr=false#overview)
99

10+
## [Devsphere specific changelog](/DEVSPHERE_CHANGELOG.md)
11+
We're adding certain features & updates to this fork which may or may not be suitable to push upstream. Refer to the [Devsphere specific changelog](/DEVSPHERE_CHANGELOG.md) to get more context.
1012

1113
## Usage
1214

13-
1415
### Getting Started
1516

1617
- Make sure you have VS Code version 1.77.0 or above

package.json

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@
9898
},
9999
"category": "Atlassian"
100100
},
101+
{
102+
"command": "atlascode.devsphere.review.initialise",
103+
"title": "Initialise Devsphere Review Settings",
104+
"category": "Atlassian"
105+
},
106+
{
107+
"command": "atlascode.devsphere.custom.reset",
108+
"title": "Reset Devsphere Custom Configuration",
109+
"category": "Atlassian"
110+
},
101111
{
102112
"command": "atlascode.jira.searchIssues",
103113
"title": "Search Jira Issue Results",
@@ -402,6 +412,14 @@
402412
"title": "Disable Help Explorer",
403413
"category": "Atlassian"
404414
},
415+
{
416+
"command": "atlascode.bitbucket.pullRequestsOverview.refresh",
417+
"title": "Refresh",
418+
"icon": {
419+
"light": "resources/light/refresh.svg",
420+
"dark": "resources/dark/refresh.svg"
421+
}
422+
},
405423
{
406424
"command": "atlascode.showOnboardingFlow",
407425
"title": "Show Onboarding Flow",
@@ -432,7 +450,12 @@
432450
{
433451
"id": "atlascode.views.bb.pullrequestsTreeView",
434452
"name": "Bitbucket pull requests",
435-
"when": "atlascode:bitbucketExplorerEnabled && config.atlascode.bitbucket.enabled"
453+
"when": "atlascode:bitbucketExplorerEnabled && config.atlascode.bitbucket.enabled && config.atlascode.bitbucket.explorer.repositoryBasedPullRequestView.enabled"
454+
},
455+
{
456+
"id": "atlascode.views.bb.pullRequestsOverviewTreeView",
457+
"name": "Bitbucket pull requests overview",
458+
"when": "atlascode:bitbucketExplorerEnabled && config.atlascode.bitbucket.enabled && config.atlascode.bitbucket.explorer.pullRequestsOverview.enabled"
436459
},
437460
{
438461
"id": "atlascode.views.bb.pipelinesTreeView",
@@ -579,6 +602,11 @@
579602
{
580603
"command": "atlascode.disableHelpExplorer",
581604
"when": "view == atlascode.views.helpTreeView"
605+
},
606+
{
607+
"command": "atlascode.bitbucket.pullRequestsOverview.refresh",
608+
"when": "view == atlascode.views.bb.pullRequestsOverviewTreeView",
609+
"group": "navigation@1"
582610
}
583611
],
584612
"view/item/context": [
@@ -1105,6 +1133,18 @@
11051133
"description": "Enables the Bitbucket Pull Request Explorer",
11061134
"scope": "window"
11071135
},
1136+
"atlascode.bitbucket.explorer.repositoryBasedPullRequestView.enabled": {
1137+
"type": "boolean",
1138+
"default": true,
1139+
"description": "Enable repository based pull requests tree view",
1140+
"scope": "window"
1141+
},
1142+
"atlascode.bitbucket.explorer.pullRequestsOverview.enabled": {
1143+
"type": "boolean",
1144+
"default": true,
1145+
"description": "Enable pull requests overview tree view",
1146+
"scope": "window"
1147+
},
11081148
"atlascode.bitbucket.explorer.nestFilesEnabled": {
11091149
"type": "boolean",
11101150
"default": true,
@@ -1408,4 +1448,4 @@
14081448
"webpack-node-externals": "^3.0.0"
14091449
},
14101450
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
1411-
}
1451+
}

src/atlclients/clientManager.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { ConfigurationChangeEvent, Disposable, ExtensionContext } from 'vscode';
66
import { commands, window } from 'vscode';
77

88
import { CloudPullRequestApi } from '../bitbucket/bitbucket-cloud/pullRequests';
9+
import { PullRequestsOverviewApi } from '../bitbucket/bitbucket-cloud/pullRequestsOverview';
910
import { CloudRepositoriesApi } from '../bitbucket/bitbucket-cloud/repositories';
1011
import { ServerPullRequestApi } from '../bitbucket/bitbucket-server/pullRequests';
1112
import { ServerRepositoriesApi } from '../bitbucket/bitbucket-server/repositories';
@@ -124,6 +125,9 @@ export class ClientManager implements Disposable {
124125
pullrequests: isOAuthInfo(info)
125126
? new CloudPullRequestApi(this.createOAuthHTTPClient(site, info.access))
126127
: undefined!,
128+
pullrequestsOverview: isOAuthInfo(info)
129+
? new PullRequestsOverviewApi(this.createOAuthHTTPClient(site, info.access))
130+
: undefined!,
127131
pipelines: isOAuthInfo(info)
128132
? new PipelineApiImpl(this.createOAuthHTTPClient(site, info.access))
129133
: undefined!,
@@ -138,6 +142,8 @@ export class ClientManager implements Disposable {
138142
isBasicAuthInfo(info) || isPATAuthInfo(info)
139143
? new ServerPullRequestApi(this.createHTTPClient(site, info))
140144
: undefined!,
145+
// Note: For now Internal Pull Requests are not supported for Server
146+
pullrequestsOverview: undefined,
141147
pipelines: undefined,
142148
};
143149
}

src/bitbucket/bbContext.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { CacheMap } from '../util/cachemap';
99
import { Time } from '../util/time';
1010
import { PullRequestCommentController } from '../views/pullrequest/prCommentController';
1111
import { PullRequestsExplorer } from '../views/pullrequest/pullRequestsExplorer';
12+
import { PullRequestsOverviewExplorer } from '../views/pullrequest/PullRequestsOverviewExplorer';
1213
import { clientForSite, getBitbucketCloudRemotes, getBitbucketRemotes, workspaceRepoFor } from './bbUtils';
1314
import { BitbucketSite, PullRequest, User, WorkspaceRepo } from './model';
1415

@@ -21,6 +22,7 @@ export class BitbucketContext extends Disposable {
2122
private _gitApi: GitApi;
2223
private _repoMap: Map<string, WorkspaceRepo> = new Map();
2324
private _pullRequestsExplorer: PullRequestsExplorer;
25+
private _pullRequestsOverviewExplorer: PullRequestsOverviewExplorer;
2426
private _disposable: Disposable;
2527
private _currentUsers: CacheMap;
2628
private _pullRequestCache = new CacheMap();
@@ -31,6 +33,7 @@ export class BitbucketContext extends Disposable {
3133
super(() => this.dispose());
3234
this._gitApi = gitApi;
3335
this._pullRequestsExplorer = new PullRequestsExplorer(this);
36+
this._pullRequestsOverviewExplorer = new PullRequestsOverviewExplorer(this);
3437
this._currentUsers = new CacheMap();
3538

3639
Container.context.subscriptions.push(
@@ -48,6 +51,7 @@ export class BitbucketContext extends Disposable {
4851
this._gitApi.onDidOpenRepository(() => this.refreshRepos()),
4952
this._gitApi.onDidCloseRepository(() => this.refreshRepos()),
5053
this._pullRequestsExplorer,
54+
this._pullRequestsOverviewExplorer,
5155
this.prCommentController,
5256
);
5357

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import { DetailedSiteInfo } from '../../atlclients/authInfo';
2+
import { HTTPClient } from '../httpClient';
3+
import { BitbucketSite, PullRequest, WorkspaceRepo } from '../model';
4+
import { CloudPullRequestApi } from './pullRequests';
5+
6+
export interface OverviewViewState {
7+
pullRequests: {
8+
authored: PullRequest[];
9+
reviewing: PullRequest[];
10+
closed: PullRequest[];
11+
};
12+
}
13+
14+
export class PullRequestsOverviewApi {
15+
constructor(private client: HTTPClient) {}
16+
17+
private extractSiteFromPRData(prData: any, site: DetailedSiteInfo): BitbucketSite {
18+
// Extract site information from the PR data
19+
const repoSlug = prData.destination.repository.full_name.split('/')[1];
20+
const ownerSlug = prData.destination.repository.workspace.slug;
21+
22+
// Create a site object
23+
return {
24+
ownerSlug,
25+
repoSlug,
26+
details: site,
27+
};
28+
}
29+
30+
private createWorkspaceRepoFromPRData(prData: any, site: BitbucketSite): WorkspaceRepo {
31+
// Create a minimal WorkspaceRepo object with required fields
32+
return {
33+
rootUri: prData.destination.repository.full_name,
34+
mainSiteRemote: {
35+
site: site,
36+
remote: {
37+
name: prData.destination.repository.name,
38+
fetchUrl: `https://bitbucket.org/${prData.destination.repository.full_name}.git`,
39+
pushUrl: `https://bitbucket.org/${prData.destination.repository.full_name}.git`,
40+
isReadOnly: true,
41+
},
42+
},
43+
siteRemotes: [],
44+
};
45+
}
46+
47+
async getOverviewViewState(ownerSlug: string, site: DetailedSiteInfo): Promise<OverviewViewState> {
48+
const fields = [
49+
'+pullRequests.*.author',
50+
'+pullRequests.*.closed_on',
51+
'+pullRequests.*.comment_count',
52+
'+pullRequests.*.created_on',
53+
'+pullRequests.*.destination.branch.name',
54+
'+pullRequests.*.destination.commit.hash',
55+
'+pullRequests.*.destination.repository.workspace',
56+
'+pullRequests.*.id',
57+
'+pullRequests.*.links.html',
58+
'+pullRequests.*.links.self',
59+
'+pullRequests.*.participants',
60+
'+pullRequests.*.repository.links.avatar',
61+
'+pullRequests.*.repository.links.html',
62+
'+pullRequests.*.repository.full_name',
63+
'+pullRequests.*.repository.name',
64+
'+pullRequests.*.source.branch.name',
65+
'+pullRequests.*.source.commit.hash',
66+
'+pullRequests.*.source.repository.workspace',
67+
'+pullRequests.*.state',
68+
'+pullRequests.*.task_count',
69+
'+pullRequests.*.title',
70+
'+pullRequests.*.updated_on',
71+
].join(',');
72+
73+
const { data } = await this.client.get(
74+
`/workspaces/${ownerSlug}/overview-view-state/?fields=${encodeURIComponent(fields)}`,
75+
);
76+
77+
const authored: PullRequest[] = data.pullRequests.authored.map((pr: any) => {
78+
const bbSite = this.extractSiteFromPRData(pr, site);
79+
const workspaceRepo = this.createWorkspaceRepoFromPRData(pr, bbSite);
80+
81+
return CloudPullRequestApi.toPullRequestData(pr, bbSite, workspaceRepo);
82+
});
83+
84+
const reviewing: PullRequest[] = data.pullRequests.reviewing.map((pr: any) => {
85+
const bbSite = this.extractSiteFromPRData(pr, site);
86+
const workspaceRepo = this.createWorkspaceRepoFromPRData(pr, bbSite);
87+
return CloudPullRequestApi.toPullRequestData(pr, bbSite, workspaceRepo);
88+
});
89+
90+
const closed: PullRequest[] = data.pullRequests.closed.map((pr: any) => {
91+
const bbSite = this.extractSiteFromPRData(pr, site);
92+
const workspaceRepo = this.createWorkspaceRepoFromPRData(pr, bbSite);
93+
return CloudPullRequestApi.toPullRequestData(pr, bbSite, workspaceRepo);
94+
});
95+
96+
const response: OverviewViewState = {
97+
pullRequests: {
98+
authored,
99+
reviewing,
100+
closed,
101+
},
102+
};
103+
104+
return response;
105+
}
106+
}

src/bitbucket/model.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { DetailedSiteInfo, emptySiteInfo } from '../atlclients/authInfo';
44
import { PipelineApiImpl } from '../pipelines/pipelines';
55
import { Remote, Repository } from '../typings/git';
66
import { FileDiffQueryParams } from '../views/pullrequest/diffViewHelper';
7+
import { OverviewViewState } from './bitbucket-cloud/pullRequestsOverview';
78

89
export type BitbucketSite = {
910
details: DetailedSiteInfo;
@@ -369,6 +370,10 @@ export interface PullRequestApi {
369370
getFileContent(site: BitbucketSite, commitHash: string, path: string): Promise<string>;
370371
}
371372

373+
export interface PullRequestsOverviewApi {
374+
getOverviewViewState(ownerSlug: string, site: DetailedSiteInfo): Promise<OverviewViewState>;
375+
}
376+
372377
export interface RepositoriesApi {
373378
getMirrorHosts(): Promise<string[]>;
374379
get(site: BitbucketSite): Promise<Repo>;
@@ -383,10 +388,6 @@ export interface RepositoriesApi {
383388
export interface BitbucketApi {
384389
repositories: RepositoriesApi;
385390
pullrequests: PullRequestApi;
391+
pullrequestsOverview?: PullRequestsOverviewApi;
386392
pipelines?: PipelineApiImpl;
387393
}
388-
389-
export interface BitbucketApi {
390-
repositories: RepositoriesApi;
391-
pullrequests: PullRequestApi;
392-
}

src/commandContext.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export enum CommandContext {
1111
JiraLoginTree = 'atlascode:jiraLoginTreeEnabled',
1212
IsJiraAuthenticated = 'atlascode:isJiraAuthenticated',
1313
IsBBAuthenticated = 'atlascode:isBBAuthenticated',
14+
PullRequestOverviewEnabled = 'atlascode:bitbucketPullRequestOverviewEnabled',
15+
RepositoryBasedPullRequestViewEnabled = 'atlascode:bitbucketRepositoryBasedPullRequestViewEnabled',
1416
}
1517

1618
export function setCommandContext(key: CommandContext | string, value: any) {

0 commit comments

Comments
 (0)