From eab0e4d92b75fc22a64c56fb7f0e72ca69ff21b4 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Fri, 1 Mar 2019 14:27:44 -0500 Subject: [PATCH 1/2] Attempting to add a flag to control mergable state --- src/github/pullRequestModel.ts | 3 +++ src/view/treeNodes/pullRequestNode.ts | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/github/pullRequestModel.ts b/src/github/pullRequestModel.ts index 565fb29ca5..c51d6c395f 100644 --- a/src/github/pullRequestModel.ts +++ b/src/github/pullRequestModel.ts @@ -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; @@ -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); } diff --git a/src/view/treeNodes/pullRequestNode.ts b/src/view/treeNodes/pullRequestNode.ts index 3f0ee300d3..12e78848c3 100644 --- a/src/view/treeNodes/pullRequestNode.ts +++ b/src/view/treeNodes/pullRequestNode.ts @@ -363,6 +363,7 @@ export class PRNode extends TreeNode { title, prNumber, author, + mergeable } = this.pullRequestModel; const { @@ -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', + 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 }; } From 5def0a9feec58948a4ad271b2108508bf5843c92 Mon Sep 17 00:00:00 2001 From: Stanley Goldman Date: Fri, 1 Mar 2019 15:32:13 -0500 Subject: [PATCH 2/2] Adding a graphql query --- src/github/queries.gql | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/github/queries.gql b/src/github/queries.gql index 5591fb747a..b68d005696 100644 --- a/src/github/queries.gql +++ b/src/github/queries.gql @@ -336,4 +336,9 @@ query GetMentionableUsers($owner: String!, $name: String!, $first: Int!, $after: remaining resetAt } -} \ No newline at end of file +} + +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}}}} \ No newline at end of file