Skip to content

Commit 2205b45

Browse files
authored
PR Actions Are Not Shown When Title Is Long (#6225)
Fixes #6222
1 parent d360aa6 commit 2205b45

2 files changed

Lines changed: 20 additions & 15 deletions

File tree

src/view/treeNodes/pullRequestNode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ export class PRNode extends TreeNode implements vscode.CommentingRangeProvider2
281281
const currentBranchIsForThisPR = this.pullRequestModel.equals(this._folderReposManager.activePullRequest);
282282

283283
const { title, number, author, isDraft, html_url } = this.pullRequestModel;
284-
284+
const labelTitle = this.pullRequestModel.title.length > 50 ? `${this.pullRequestModel.title.substring(0, 50)}...` : this.pullRequestModel.title;
285285
const { login } = author;
286286

287287
const hasNotification = this._notificationProvider.hasNotification(this.pullRequestModel);
@@ -299,7 +299,7 @@ export class PRNode extends TreeNode implements vscode.CommentingRangeProvider2
299299
tooltipPrefix += `#${formattedPRNumber}: `;
300300
}
301301

302-
const label = `${labelPrefix}${isDraft ? '[DRAFT] ' : ''}${title}`;
302+
const label = `${labelPrefix}${isDraft ? '[DRAFT] ' : ''}${labelTitle}`;
303303
const tooltip = `${tooltipPrefix}${title} by @${login}`;
304304
const description = `by @${login}`;
305305

src/view/treeNodes/repositoryChangesNode.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ export class RepositoryChangesNode extends DescriptionNode implements vscode.Tre
2626

2727
constructor(
2828
public parent: BaseTreeNode,
29-
private _pullRequest: PullRequestModel,
29+
pullRequest: PullRequestModel,
3030
private _pullRequestManager: FolderRepositoryManager,
3131
private _reviewModel: ReviewModel,
3232
private _progress: ProgressHelper
3333
) {
34-
super(parent, _pullRequest.title, _pullRequest, _pullRequestManager.repository, _pullRequestManager);
34+
super(parent, pullRequest.title, pullRequest, _pullRequestManager.repository, _pullRequestManager);
3535
// Cause tree values to be filled
3636
this.getTreeItem();
3737

@@ -59,7 +59,7 @@ export class RepositoryChangesNode extends DescriptionNode implements vscode.Tre
5959
}),
6060
);
6161

62-
this._disposables.push(_pullRequest.onDidInvalidate(() => {
62+
this._disposables.push(this.pullRequestModel.onDidInvalidate(() => {
6363
this.refresh();
6464
}));
6565
}
@@ -77,34 +77,39 @@ export class RepositoryChangesNode extends DescriptionNode implements vscode.Tre
7777
await this._progress.progress;
7878
if (!this._filesCategoryNode || !this._commitsCategoryNode) {
7979
Logger.appendLine(`Creating file and commit nodes for PR #${this.pullRequestModel.number}`, PR_TREE);
80-
this._filesCategoryNode = new FilesCategoryNode(this.parent, this._reviewModel, this._pullRequest);
80+
this._filesCategoryNode = new FilesCategoryNode(this.parent, this._reviewModel, this.pullRequestModel);
8181
this._commitsCategoryNode = new CommitsNode(
8282
this.parent,
8383
this._pullRequestManager,
84-
this._pullRequest,
84+
this.pullRequestModel,
8585
);
8686
}
8787
this.children = [this._filesCategoryNode, this._commitsCategoryNode];
8888
return this.children;
8989
}
9090

91+
private setLabel() {
92+
this.label = this.pullRequestModel.title;
93+
if (this.label.length > 50) {
94+
this.tooltip = this.label;
95+
this.label = `${this.label.substring(0, 50)}...`;
96+
}
97+
}
98+
9199
async getTreeItem(): Promise<vscode.TreeItem> {
92-
this.label = this._pullRequest.title;
93-
this.iconPath = (await DataUri.avatarCirclesAsImageDataUris(this._pullRequestManager.context, [this._pullRequest.author], 16, 16))[0];
100+
this.setLabel();
101+
this.iconPath = (await DataUri.avatarCirclesAsImageDataUris(this._pullRequestManager.context, [this.pullRequestModel.author], 16, 16))[0];
94102
this.description = undefined;
95103
if (this.parent.children?.length && this.parent.children.length > 1) {
96104
const allSameOwner = this.parent.children.every(child => {
97105
return child instanceof RepositoryChangesNode && child.pullRequestModel.remote.owner === this.pullRequestModel.remote.owner;
98106
});
99107
if (allSameOwner) {
100-
this.description = this._pullRequest.remote.repositoryName;
108+
this.description = this.pullRequestModel.remote.repositoryName;
101109
} else {
102-
this.description = `${this._pullRequest.remote.owner}/${this._pullRequest.remote.repositoryName}`;
103-
}
104-
if (this.label.length > 35) {
105-
this.tooltip = this.label;
106-
this.label = `${this.label.substring(0, 35)}...`;
110+
this.description = `${this.pullRequestModel.remote.owner}/${this.pullRequestModel.remote.repositoryName}`;
107111
}
112+
108113
}
109114
this.updateContextValue();
110115
return this;

0 commit comments

Comments
 (0)