Skip to content

Commit 6c4ebc3

Browse files
kabelalexr00
andauthored
Make the display of PR number in tree view configurable (#4576)
* Make the display of PR number in tree view configurable Closes #4463 Also updates the description node to always show the PR number, rather than just in the tooltip. * Remove number from description --------- Co-authored-by: Alex Ross <alros@microsoft.com>
1 parent 68260df commit 6c4ebc3

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,11 @@
508508
],
509509
"default": "firstDiff",
510510
"description": "%githubPullRequests.focusedMode.description%"
511+
},
512+
"githubPullRequests.showPullRequestNumberInTree": {
513+
"type": "boolean",
514+
"default": false,
515+
"description": "%githubPullRequests.showPullRequestNumberInTree.description%"
511516
}
512517
}
513518
},

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
"githubIssues.queries.default.recentIssues": "Recent Issues",
111111
"githubIssues.assignWhenWorking.description": "Assigns the issue you're working on to you. Only applies when the issue you're working on is in a repo you currently have open.",
112112
"githubPullRequests.focusedMode.description": "The layout to use when a pull request is checked out. Set to false to prevent layout changes.",
113+
"githubPullRequests.showPullRequestNumberInTree.description": "Shows the pull request number in the tree view.",
113114
"view.github.pull.request.name": "GitHub Pull Request",
114115
"view.github.login.name": "Login",
115116
"view.pr.github.name": "Pull Requests",

src/common/settingKeys.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const CREATE_DRAFT = 'createDraft';
2222
export const QUICK_DIFF_EXP = 'experimental.quickDiff';
2323
export const QUICK_DIFF = 'quickDiff';
2424
export const SET_AUTO_MERGE = 'setAutoMerge';
25+
export const SHOW_PULL_REQUEST_NUMBER_IN_TREE = 'showPullRequestNumberInTree';
2526

2627
// git
2728
export const GIT = 'git';

src/view/treeNodes/pullRequestNode.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import { Repository } from '../../api/api';
88
import { getCommentingRanges } from '../../common/commentingRanges';
99
import { InMemFileChange, SlimFileChange } from '../../common/file';
1010
import Logger from '../../common/logger';
11-
import { FILE_LIST_LAYOUT } from '../../common/settingKeys';
11+
import { FILE_LIST_LAYOUT, PR_SETTINGS_NAMESPACE, SHOW_PULL_REQUEST_NUMBER_IN_TREE } from '../../common/settingKeys';
1212
import { createPRNodeUri, fromPRUri, Schemes } from '../../common/uri';
1313
import { dispose } from '../../common/utils';
14-
import { FolderRepositoryManager, SETTINGS_NAMESPACE } from '../../github/folderRepositoryManager';
14+
import { FolderRepositoryManager } from '../../github/folderRepositoryManager';
1515
import { NotificationProvider } from '../../github/notifications';
1616
import { IResolvedPullRequestModel, PullRequestModel } from '../../github/pullRequestModel';
1717
import { InMemFileChangeModel, RemoteFileChangeModel } from '../fileChangeModel';
@@ -53,6 +53,7 @@ export class PRNode extends TreeNode implements vscode.CommentingRangeProvider {
5353
) {
5454
super();
5555
this.registerSinceReviewChange();
56+
this.registerConfigurationChange();
5657
this._disposables.push(this.pullRequestModel.onDidInvalidate(() => this.refresh(this)));
5758
}
5859

@@ -89,7 +90,7 @@ export class PRNode extends TreeNode implements vscode.CommentingRangeProvider {
8990
}
9091

9192
const result: TreeNode[] = [descriptionNode];
92-
const layout = vscode.workspace.getConfiguration(SETTINGS_NAMESPACE).get<string>(FILE_LIST_LAYOUT);
93+
const layout = vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<string>(FILE_LIST_LAYOUT);
9394
if (layout === 'tree') {
9495
// tree view
9596
const dirNode = new DirectoryTreeNode(this, '');
@@ -133,6 +134,16 @@ export class PRNode extends TreeNode implements vscode.CommentingRangeProvider {
133134
);
134135
}
135136

137+
protected registerConfigurationChange() {
138+
this._disposables.push(
139+
vscode.workspace.onDidChangeConfiguration(e => {
140+
if (e.affectsConfiguration(`${PR_SETTINGS_NAMESPACE}.${SHOW_PULL_REQUEST_NUMBER_IN_TREE}`)) {
141+
this.refresh();
142+
}
143+
})
144+
);
145+
}
146+
136147
public async reopenNewPrDiffs(pullRequest: PullRequestModel) {
137148
let hasOpenDiff: boolean = false;
138149
vscode.window.tabGroups.all.map(tabGroup => {
@@ -273,9 +284,19 @@ export class PRNode extends TreeNode implements vscode.CommentingRangeProvider {
273284

274285
const hasNotification = this._notificationProvider.hasNotification(this.pullRequestModel);
275286

276-
const labelPrefix = currentBranchIsForThisPR ? '✓ ' : '';
277-
const tooltipPrefix = currentBranchIsForThisPR ? 'Current Branch * ' : '';
278287
const formattedPRNumber = number.toString();
288+
let labelPrefix = currentBranchIsForThisPR ? '✓ ' : '';
289+
let tooltipPrefix = currentBranchIsForThisPR ? 'Current Branch * ' : '';
290+
291+
if (
292+
vscode.workspace
293+
.getConfiguration(PR_SETTINGS_NAMESPACE)
294+
.get<boolean>(SHOW_PULL_REQUEST_NUMBER_IN_TREE, false)
295+
) {
296+
labelPrefix += `#${formattedPRNumber}: `;
297+
tooltipPrefix += `#${formattedPRNumber}: `;
298+
}
299+
279300
const label = `${labelPrefix}${isDraft ? '[DRAFT] ' : ''}${title}`;
280301
const tooltip = `${tooltipPrefix}${title} by @${login}`;
281302
const description = `by @${login}`;

0 commit comments

Comments
 (0)