Skip to content

Commit cca5f59

Browse files
committed
Merge remote-tracking branch 'origin/master' into misolori/ux-polish
2 parents dc57f26 + dd7f2d1 commit cca5f59

25 files changed

+417
-153
lines changed

.gitignore

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ ClientBin/
221221
*.publishsettings
222222
orleans.codegen.cs
223223

224-
# Including strong name files can present a security risk
224+
# Including strong name files can present a security risk
225225
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
226226
#*.snk
227227

@@ -317,7 +317,7 @@ __pycache__/
317317
# OpenCover UI analysis results
318318
OpenCover/
319319

320-
# Azure Stream Analytics local run output
320+
# Azure Stream Analytics local run output
321321
ASALocalRun/
322322

323323
# MSBuild Binary and Structured Log
@@ -326,11 +326,12 @@ ASALocalRun/
326326
# NVidia Nsight GPU debugger configuration file
327327
*.nvuser
328328

329-
# MFractors (Xamarin productivity tool) working folder
329+
# MFractors (Xamarin productivity tool) working folder
330330
.mfractor/
331331

332332

333333
out
334334
node_modules
335335
media
336-
.DS_Store
336+
.DS_Store
337+
*.vsix

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"eamodio.tsl-problem-matcher"
4+
]
5+
}

.vscode/launch.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,14 @@
99
"args": [
1010
"--extensionDevelopmentPath=${workspaceFolder}"
1111
],
12+
"smartStep": true,
13+
"sourceMaps": true,
1214
"outFiles": [
13-
"${workspaceFolder}/out/**/*.js"
14-
]
15+
"${workspaceFolder}/media/*.js"
16+
],
17+
"sourceMapPathOverrides": {
18+
"webpack:///./*": "${workspaceRoot}/*"
19+
}
1520
},
1621
{
1722
"name": "Extension Tests",

.vscode/tasks.json

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,15 @@
44
"version": "2.0.0",
55
"tasks": [
66
{
7-
"label": "watch all",
8-
"dependsOn": [
9-
"webpack:preview",
10-
"npm:src"
11-
],
12-
"group": {
7+
"identifier": "npm",
8+
"label": "npm",
9+
"type": "npm",
10+
"script": "watch",
11+
"problemMatcher": ["$ts-webpack-watch"],
12+
"group":{
1313
"kind": "build",
1414
"isDefault": true
15-
},
16-
"problemMatcher": []
17-
},
18-
{
19-
"identifier": "npm:src",
20-
"label": "npm src",
21-
"type": "npm",
22-
"script": "compile",
23-
"problemMatcher": [],
24-
"group": "build"
25-
},
26-
{
27-
"identifier": "webpack:preview",
28-
"label": "npm build-preview",
29-
"type": "npm",
30-
"script": "build-preview",
31-
"group": "build"
15+
}
3216
}
3317
]
3418
}

.vscodeignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
.vscode/**
2-
out/test/**
3-
out/**/*.map
2+
out/**
43
src/**
4+
preview-src/**
5+
node_modules/**
56
.gitignore
6-
tsconfig.json
7+
tsconfig.json
8+
*.vsix

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"url": "https://github.com/Microsoft/vscode-pull-request-github"
99
},
1010
"enableProposedApi": true,
11-
"version": "0.0.10",
11+
"version": "0.0.12",
1212
"publisher": "Microsoft",
1313
"engines": {
1414
"vscode": "^1.25.0"
@@ -22,7 +22,7 @@
2222
"extensionDependencies": [
2323
"vscode.git"
2424
],
25-
"main": "./out/extension",
25+
"main": "./media/extension",
2626
"contributes": {
2727
"configuration": {
2828
"type": "object",
@@ -69,7 +69,7 @@
6969
"commands": [
7070
{
7171
"command": "pr.pick",
72-
"title": "Checkout Pull Request",
72+
"title": "Check Out Pull Request",
7373
"category": "GitHub Pull Requests"
7474
},
7575
{
@@ -214,8 +214,8 @@
214214
"scripts": {
215215
"vscode:prepublish": "tsc -p ./ && webpack --mode production",
216216
"postinstall": "node ./node_modules/vscode/bin/install",
217-
"compile": "tsc -watch -p ./",
218-
"build-preview": "webpack --watch --mode development",
217+
"compile": "tsc -p ./",
218+
"watch": "webpack --watch --mode development",
219219
"test": "node ./node_modules/mocha/bin/_mocha --timeout 1000 --colors ./out/test/**/*.js"
220220
},
221221
"devDependencies": {

preview-src/index.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,11 @@ body .comment-form textarea {
305305
background-color: var(--vscode-input-background);
306306
color: var(--vscode-input-foreground);
307307
font-family: var(--vscode-editor-font-family);
308+
resize: none;
309+
}
310+
311+
.reply-button {
312+
margin-left: auto;
308313
}
309314

310315
body .comment-form textarea:focus {
@@ -315,6 +320,7 @@ body .comment-form .form-actions {
315320
overflow: auto;
316321
padding-top: 20px;
317322
margin-bottom: 10px;
323+
display: flex;
318324
}
319325

320326
body button:disabled {

preview-src/index.ts

Lines changed: 60 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55
import './index.css';
6-
import { renderTimelineEvent, getStatus, renderComment, PullRequestStateEnum } from './pullRequestOverviewRenderer';
6+
import { renderTimelineEvent, getStatus, renderComment, PullRequestStateEnum, renderReview } from './pullRequestOverviewRenderer';
77
import md from './mdRenderer';
88

99
declare var acquireVsCodeApi: any;
@@ -14,6 +14,8 @@ const ElementIds = {
1414
CheckoutDefaultBranch: 'checkout-default-branch',
1515
Close: 'close',
1616
Reply: 'reply',
17+
Approve: 'approve',
18+
RequestChanges: 'request-changes',
1719
Status: 'status',
1820
CommentTextArea: 'comment-textarea',
1921
TimelineEvents:'timeline-events' // If updating this value, change id in pullRequestOverview.ts as well.
@@ -33,6 +35,16 @@ function handleMessage(event: any) {
3335
break;
3436
case 'pr.append-comment':
3537
appendComment(message.value);
38+
break;
39+
case 'pr.append-review':
40+
appendReview(message.value);
41+
break;
42+
case 'pr.enable-approve':
43+
(<HTMLButtonElement>document.getElementById(ElementIds.Approve)).disabled = false;
44+
break;
45+
case 'pr.enable-request-changes':
46+
(<HTMLButtonElement>document.getElementById(ElementIds.RequestChanges)).disabled = false;
47+
break;
3648
default:
3749
break;
3850
}
@@ -93,19 +105,42 @@ function addEventListeners(pr: any) {
93105
});
94106
});
95107

96-
// Enable 'Comment' button only when the user has entered text
108+
// Enable 'Comment' and 'RequestChanges' button only when the user has entered text
97109
document.getElementById(ElementIds.CommentTextArea)!.addEventListener('input', (e) => {
98-
(<HTMLButtonElement>document.getElementById(ElementIds.Reply)).disabled = !(<any>e.target).value;
99-
})
110+
const hasNoText = !(<any>e.target).value;
111+
(<HTMLButtonElement>document.getElementById(ElementIds.Reply)).disabled = hasNoText;
112+
(<HTMLButtonElement>document.getElementById(ElementIds.RequestChanges)).disabled = hasNoText;
113+
114+
});
100115

101116
document.getElementById(ElementIds.Reply)!.addEventListener('click', () => {
102117
submitComment();
103118
});
104119

105120
document.getElementById(ElementIds.Close)!.addEventListener('click', () => {
106121
(<HTMLButtonElement>document.getElementById(ElementIds.Close)).disabled = true;
122+
const inputBox = (<HTMLTextAreaElement>document.getElementById(ElementIds.CommentTextArea));
123+
vscode.postMessage({
124+
command: 'pr.close',
125+
text: inputBox.value
126+
});
127+
});
128+
129+
document.getElementById(ElementIds.Approve)!.addEventListener('click', () => {
130+
(<HTMLButtonElement>document.getElementById(ElementIds.Approve)).disabled = true;
131+
const inputBox = (<HTMLTextAreaElement>document.getElementById(ElementIds.CommentTextArea));
132+
vscode.postMessage({
133+
command: 'pr.approve',
134+
text: inputBox.value
135+
});
136+
});
137+
138+
document.getElementById(ElementIds.RequestChanges)!.addEventListener('click', () => {
139+
(<HTMLButtonElement>document.getElementById(ElementIds.RequestChanges)).disabled = true;
140+
const inputBox = (<HTMLTextAreaElement>document.getElementById(ElementIds.CommentTextArea));
107141
vscode.postMessage({
108-
command: 'pr.close'
142+
command: 'pr.request-changes',
143+
text: inputBox.value
109144
});
110145
});
111146

@@ -118,18 +153,31 @@ function addEventListeners(pr: any) {
118153
});
119154
}
120155

156+
function clearTextArea() {
157+
(<HTMLTextAreaElement>document.getElementById(ElementIds.CommentTextArea)!).value = '';
158+
(<HTMLButtonElement>document.getElementById(ElementIds.Reply)).disabled = true;
159+
(<HTMLButtonElement>document.getElementById(ElementIds.RequestChanges)).disabled = true;
160+
}
161+
121162
function submitComment() {
122163
(<HTMLButtonElement>document.getElementById(ElementIds.Reply)).disabled = true;
123164
vscode.postMessage({
124165
command: 'pr.comment',
125166
text: (<HTMLTextAreaElement>document.getElementById(ElementIds.CommentTextArea)!).value
126167
});
127-
(<HTMLTextAreaElement>document.getElementById(ElementIds.CommentTextArea)!).value = '';
168+
169+
}
170+
171+
function appendReview(review: any): void {
172+
const newReview = renderReview(review);
173+
document.getElementById(ElementIds.TimelineEvents)!.insertAdjacentHTML('beforeend', newReview);
174+
clearTextArea();
128175
}
129176

130177
function appendComment(comment: any) {
131178
let newComment = renderComment(comment);
132179
document.getElementById(ElementIds.TimelineEvents)!.insertAdjacentHTML('beforeend', newComment);
180+
clearTextArea();
133181
}
134182

135183
function updateCheckoutButton(isCheckedOut: boolean) {
@@ -138,7 +186,7 @@ function updateCheckoutButton(isCheckedOut: boolean) {
138186
checkoutButton.disabled = isCheckedOut;
139187
checkoutMasterButton.disabled = false;
140188
const activeIcon = '<svg class="octicon octicon-check" viewBox="0 0 12 16" version="1.1" width="12" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M12 5l-8 8-4-4 1.5-1.5L4 10l6.5-6.5L12 5z"></path></svg>';
141-
checkoutButton.innerHTML = isCheckedOut ? `${activeIcon} Checked Out` : `Checkout`;
189+
checkoutButton.innerHTML = isCheckedOut ? `${activeIcon} Checked Out` : `Check out`;
142190

143191
const backButton = (<HTMLButtonElement>document.getElementById(ElementIds.CheckoutDefaultBranch));
144192
if (isCheckedOut) {
@@ -153,8 +201,10 @@ function updateCheckoutButton(isCheckedOut: boolean) {
153201
function setTextArea() {
154202
document.getElementById('comment-form')!.innerHTML = `<textarea id="${ElementIds.CommentTextArea}"></textarea>
155203
<div class="form-actions">
156-
<button class="reply-button" id="${ElementIds.Reply}" disabled="true"></button>
157-
<button class="close-button" id="${ElementIds.Close}"></button>
204+
<button id="${ElementIds.Close}">Close Pull Request</button>
205+
<button id="${ElementIds.RequestChanges}" disabled="true">Request Changes</button>
206+
<button id="${ElementIds.Approve}">Approve</button>
207+
<button class="reply-button" id="${ElementIds.Reply}" disabled="true">Comment</button>
158208
</div>`;
159209

160210
(<HTMLTextAreaElement>document.getElementById(ElementIds.CommentTextArea)!).placeholder = 'Leave a comment';
@@ -164,11 +214,9 @@ function setTextArea() {
164214
return;
165215
}
166216

167-
if (e.keyCode === 13 && e.ctrlKey) {
217+
if (e.keyCode === 13 && (e.metaKey || e.ctrlKey)) {
168218
submitComment();
169219
return;
170220
}
171221
});
172-
(<HTMLButtonElement>document.getElementById(ElementIds.Reply)!).textContent = 'Comment';
173-
(<HTMLButtonElement>document.getElementById(ElementIds.Close)!).textContent = 'Close Pull Request';
174222
}

0 commit comments

Comments
 (0)