Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Changing the Pull Request node icon to represent merge-ability #1020

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/github/pullRequestModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class PullRequestModel {
public localBranchName?: string;
public labels: string[];
public mergeBase?: string;
public mergeable?: boolean;

public get isOpen(): boolean {
return this.state === PullRequestStateEnum.Open;
Expand Down Expand Up @@ -90,6 +91,8 @@ export class PullRequestModel {
this.createdAt = prItem.createdAt;
this.updatedAt = prItem.updatedAt ? prItem.updatedAt : this.createdAt;

this.mergeable = prItem.mergeable;

this.head = new GitHubRef(prItem.head!.ref, prItem.head!.label, prItem.head!.sha, prItem.head!.repo.cloneUrl);
this.base = new GitHubRef(prItem.base!.ref, prItem.base!.label, prItem.base!.sha, prItem.base!.repo.cloneUrl);
}
Expand Down
7 changes: 6 additions & 1 deletion src/github/queries.gql
Original file line number Diff line number Diff line change
Expand Up @@ -336,4 +336,9 @@ query GetMentionableUsers($owner: String!, $name: String!, $first: Int!, $after:
remaining
resetAt
}
}
}

fragment ActorParts on Actor{login url avatarUrl ... on User{name}}
fragment PageInfoParts on PageInfo{hasNextPage endCursor}
fragment RefParts on Ref{name prefix target{oid commitResourcePath}repository{url owner{login}name}}
query GetPullRequests{repository(owner:"github",name:"VisualStudio"){pullRequests(first:1,states:OPEN){nodes{number title bodyHTML url author{...ActorParts}labels(first:100){nodes{name}pageInfo{...PageInfoParts}}state assignees(first:100){nodes{...ActorParts}}createdAt updatedAt merged mergeable headRef{...RefParts}baseRef{...RefParts}}pageInfo{...PageInfoParts}}}}
8 changes: 7 additions & 1 deletion src/view/treeNodes/pullRequestNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ export class PRNode extends TreeNode {
title,
prNumber,
author,
mergeable
} = this.pullRequestModel;

const {
Expand All @@ -376,13 +377,18 @@ export class PRNode extends TreeNode {
const tooltip = `${tooltipPrefix}${title} (#${formattedPRNumber}) by @${login}`;
const description = `#${formattedPRNumber} by @${login}`;

const iconPath = {
light: mergeable ? 'resources/icons/light/check.svg' : 'resources/icons/delete.svg',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for these paths, I think we need to use a VSCode API to find the absolute path for them, since VSCode will know where the extension is installed

src/common/resources.ts has code for this, you can add the check and delete icons there and then import them here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the hints, I was going to have to ask that question eventually.

dark: mergeable ? 'resources/icons/light/check.svg' : 'resources/icons/delete.svg'}
;

return {
label,
tooltip,
description,
collapsibleState: 1,
contextValue: 'pullrequest' + (this._isLocal ? ':local' : '') + (currentBranchIsForThisPR ? ':active' : ':nonactive'),
iconPath: this.pullRequestModel.userAvatarUri
iconPath
};
}

Expand Down