Skip to content

Commit

Permalink
PR Actions Are Not Shown When Title Is Long (#6225)
Browse files Browse the repository at this point in the history
Fixes #6222
  • Loading branch information
alexr00 authored Sep 11, 2024
1 parent d360aa6 commit 2205b45
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/view/treeNodes/pullRequestNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ export class PRNode extends TreeNode implements vscode.CommentingRangeProvider2
const currentBranchIsForThisPR = this.pullRequestModel.equals(this._folderReposManager.activePullRequest);

const { title, number, author, isDraft, html_url } = this.pullRequestModel;

const labelTitle = this.pullRequestModel.title.length > 50 ? `${this.pullRequestModel.title.substring(0, 50)}...` : this.pullRequestModel.title;
const { login } = author;

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

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

Expand Down
31 changes: 18 additions & 13 deletions src/view/treeNodes/repositoryChangesNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ export class RepositoryChangesNode extends DescriptionNode implements vscode.Tre

constructor(
public parent: BaseTreeNode,
private _pullRequest: PullRequestModel,
pullRequest: PullRequestModel,
private _pullRequestManager: FolderRepositoryManager,
private _reviewModel: ReviewModel,
private _progress: ProgressHelper
) {
super(parent, _pullRequest.title, _pullRequest, _pullRequestManager.repository, _pullRequestManager);
super(parent, pullRequest.title, pullRequest, _pullRequestManager.repository, _pullRequestManager);
// Cause tree values to be filled
this.getTreeItem();

Expand Down Expand Up @@ -59,7 +59,7 @@ export class RepositoryChangesNode extends DescriptionNode implements vscode.Tre
}),
);

this._disposables.push(_pullRequest.onDidInvalidate(() => {
this._disposables.push(this.pullRequestModel.onDidInvalidate(() => {
this.refresh();
}));
}
Expand All @@ -77,34 +77,39 @@ export class RepositoryChangesNode extends DescriptionNode implements vscode.Tre
await this._progress.progress;
if (!this._filesCategoryNode || !this._commitsCategoryNode) {
Logger.appendLine(`Creating file and commit nodes for PR #${this.pullRequestModel.number}`, PR_TREE);
this._filesCategoryNode = new FilesCategoryNode(this.parent, this._reviewModel, this._pullRequest);
this._filesCategoryNode = new FilesCategoryNode(this.parent, this._reviewModel, this.pullRequestModel);
this._commitsCategoryNode = new CommitsNode(
this.parent,
this._pullRequestManager,
this._pullRequest,
this.pullRequestModel,
);
}
this.children = [this._filesCategoryNode, this._commitsCategoryNode];
return this.children;
}

private setLabel() {
this.label = this.pullRequestModel.title;
if (this.label.length > 50) {
this.tooltip = this.label;
this.label = `${this.label.substring(0, 50)}...`;
}
}

async getTreeItem(): Promise<vscode.TreeItem> {
this.label = this._pullRequest.title;
this.iconPath = (await DataUri.avatarCirclesAsImageDataUris(this._pullRequestManager.context, [this._pullRequest.author], 16, 16))[0];
this.setLabel();
this.iconPath = (await DataUri.avatarCirclesAsImageDataUris(this._pullRequestManager.context, [this.pullRequestModel.author], 16, 16))[0];
this.description = undefined;
if (this.parent.children?.length && this.parent.children.length > 1) {
const allSameOwner = this.parent.children.every(child => {
return child instanceof RepositoryChangesNode && child.pullRequestModel.remote.owner === this.pullRequestModel.remote.owner;
});
if (allSameOwner) {
this.description = this._pullRequest.remote.repositoryName;
this.description = this.pullRequestModel.remote.repositoryName;
} else {
this.description = `${this._pullRequest.remote.owner}/${this._pullRequest.remote.repositoryName}`;
}
if (this.label.length > 35) {
this.tooltip = this.label;
this.label = `${this.label.substring(0, 35)}...`;
this.description = `${this.pullRequestModel.remote.owner}/${this.pullRequestModel.remote.repositoryName}`;
}

}
this.updateContextValue();
return this;
Expand Down

0 comments on commit 2205b45

Please sign in to comment.