Conversation
Co-authored-by: Ashi Krishnan <ashi@queerlyamorous.org>
Co-authored-by: Ashi Krishnan <ashi@queerlyamorous.org>
Co-authored-by: Ashi Krishnan <ashi@queerlyamorous.org>
Co-authored-by: Ashi Krishnan <ashi@queerlyamorous.org>clear
queerviolet
left a comment
There was a problem hiding this comment.
I think we should have some UI for making the draft not a draft ("Ready for Review" on dotcom).
Also, when I try to Approve or Request Changes, it fails with Unprocessable Entity. Are those things we can do to Draft PRs? If not, we should remove the buttons.
|
One UX thing and a small code nit, otherwise LG! |
Co-authored-by: Ashi Krishnan <queerviolet@github.com>
... since REST API doesn't actually allow this. The documentation says it's supported, but turns out only in that it returns the `draft` field. The patch request doesn't take a draft param
This reverts commit d5e4fa5.
Looks like this is due to the fact that a PR author is trying to approve/request changes on their own PR. Which is not allowed. I checked master and this is a pre-existing bug. So let's call this out-of-scope and tackle it separately |
Due to lack of graphql support
Strangely the extension was working even without it listed explicitly. It was listed in the yarn.lock, and I guess that was getting us by... In any case, we started seeing this error with the stack trace pointing to lodash: ``` ```Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'nonce-i53qcjvFaMb4cikgwqc758pL4aWAtfGk'".``` ```
smashwilson
left a comment
There was a problem hiding this comment.
Random drive-by diff comments 👀
| "graphql": "^14.0.2", | ||
| "iconv-lite": "0.4.23", | ||
| "js-base64": "^2.4.9", | ||
| "lodash": "^4.17.11", |
There was a problem hiding this comment.
I'm actually depending on lodash.isequal in #1169. I'll have to consolidate after this is merged so it isn't redundant 🙈
src/github/pullRequestOverview.ts
Outdated
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src vscode-resource: https:; script-src 'unsafe-eval' 'nonce-${nonce}'; style-src vscode-resource: 'unsafe-inline' http: https: data:;"> |
There was a problem hiding this comment.
Ohhh I bet this is the change that caused that EvalError you were seeing yesterday ☝️
It's a very good change to make, though.
There was a problem hiding this comment.
Heh yup, and totally!
| "command": "pr.merge", | ||
| "when": "config.git.enabled && github:inReviewMode" | ||
| }, | ||
| { |
There was a problem hiding this comment.
we should also scope pr.createDraft to be when you're not in review mode. Looks like something funky is happening with pr.create and that context key right now, the bang operator should work but I still see the command when checked out. Changing the syntax to github:inReviewMode == 'false' fixes it
There was a problem hiding this comment.
Good to know about that funkiness! Made the fix 👍
src/github/credentials.ts
Outdated
| agent, | ||
| baseUrl, | ||
| headers: { 'user-agent': 'GitHub VSCode Pull Requests' } | ||
| headers: { 'user-agent': 'GitHub VSCode Pull Requests', Accept: 'application/vnd.github.shadow-cat-preview+json' } |
There was a problem hiding this comment.
just curious, why is this change needed?
There was a problem hiding this comment.
Good question! It's required for access to the Draft PR API while it's in preview -- https://developer.github.com/v3/previews/#draft-pull-requests
I'll add a comment to the code to increase clarity 👍
src/github/interface.ts
Outdated
| } | ||
|
|
||
| export interface PullRequest { | ||
| id?: string; |
There was a problem hiding this comment.
should this be a required property?
There was a problem hiding this comment.
That would certainly be ideal! However, as long as we fall back to using REST, this field must be optional. id refers specifically to the graphql object id and is required for making mutations (such as updating draft status).
And unfortunately the REST API doesn't currently support updating the draft status of PRs (and the GitHub pull requests team doesn't seem to have plans to add support). So for now users simply cannot convert from draft status to ready-for-review unless graphql is supported https://github.com/microsoft/vscode-pull-request-github/pull/1173/files#diff-4c377281588b3e01e164412d5a23724aR1229)
There was a problem hiding this comment.
I feel like we dealt with this in some way—making this id either the GraphQL node id, or the database ID as returned by the REST API. @RMacfarlane do you recall?
There was a problem hiding this comment.
(IMO this isn't a blocker, as going from an optional field to a required field is always non-breaking.)
There was a problem hiding this comment.
Oh yeah! On comments we have an id property and a graphNodeId property. id is the database id, graphNodeId is the GraphQL node id. Both are always present, the REST API had a node_id property that we used to fill in the graphNodeId. I think we still have some mixed usage of REST and GraphQL when dealing with comments, even when GraphQL is supported
| }, | ||
| "dependencies": { | ||
| "@octokit/rest": "^15.15.1", | ||
| "@octokit/rest": "^16.21.0", |
There was a problem hiding this comment.
thanks for updating this!
The bang operator doesn't seem to be working as expected, hence using the more verbose `github:inReviewMode == 'false'` syntax Co-authored-by: Rachel Macfarlane <ramacfar@microsoft.com>
Co-authored-by: Rachel Macfarlane <ramacfar@microsoft.com>
Co-authored-by: Rachel Macfarlane <ramacfar@microsoft.com>
Co-authored-by: Rachel Macfarlane <ramacfar@microsoft.com>
Looks like there's a bug in VS Code. Currently the pr.create and pr.createDraft commands always show up regardless of review mode. I'll go ahead and ship and hope that the bug gets fixed soon.
Version: 1.35.0-insider
Commit: 2737cde4facc8411982862742f5c6cd3dabef323
Date: 2019-05-31T05:16:11.646Z
Electron: 3.1.8
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Darwin x64 17.7.0
ca80c6f to
14b067e
Compare
|
That's weird that I cannot find create draft pull request command!!!! |



On dotcom users can create draft pull requests to indicate that their PR is a work in progress and not yet ready for review.
With this PR, users may submit draft pull requests using the
GitHub Pull Requests: Create Draft Pull Requestcommand. When viewing the description of a draft PR in the editor, aDraftbadge is displayed in the header.This PR also includes upgrades of
@octokit/restandtypescript. In order to use the Draft Pull Request rest API we needed to upgrade octokit, which required a typescript upgrade.Fixes #1129
Fixes #1190
TODO:
GitHub Pull Requests: Create Draft Pull RequestDraftbadge to PR description headerHandleUnprocessable Entityerror when clicking "Approve" and "Request changes" buttons while in draft mode