提交 75a6aecf 编写于 作者: P Peng Lyu

send create issue comment request and update UI.

上级 2f2f03b9
......@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { renderTimelineEvent, getStatus } from './pullRequestOverviewRenderer';
import { renderTimelineEvent, getStatus, renderComment } from './pullRequestOverviewRenderer';
declare var acquireVsCodeApi: any;
const vscode = acquireVsCodeApi();
......@@ -17,6 +17,8 @@ function handleMessage(event: any) {
case 'checked-out':
updateCheckoutButton(true);
break;
case 'append-comment':
appendComment(message.value);
default:
break;
}
......@@ -59,6 +61,20 @@ function addEventListeners() {
command: 'pr.checkout'
});
});
document.getElementById('reply-button')!.addEventListener('click', () => {
(<HTMLButtonElement>document.getElementById('reply-button')).disabled = true;
vscode.postMessage({
command: 'pr.comment',
text: (<HTMLTextAreaElement>document.getElementById('commentTextArea')!).value
});
(<HTMLTextAreaElement>document.getElementById('commentTextArea')!).value = '';
});
}
function appendComment(comment: any) {
let newComment = renderComment(comment);
document.getElementById('pullrequest')!.insertAdjacentHTML('beforeend', newComment);
}
function updateCheckoutButton(isCheckedOut: boolean) {
......
......@@ -144,6 +144,17 @@ export class PullRequestModel {
return promise.data;
}
async createDiscussionComment(text: string): Promise<Comment> {
const promise = await this.otcokit.issues.createComment({
body: text,
number: this.prNumber,
owner: this.remote.owner,
repo: this.remote.repositoryName
});
return promise.data;
}
async createCommentReply(body: string, reply_to: string) {
let ret = await this.otcokit.pullRequests.createCommentReply({
owner: this.remote.owner,
......
......@@ -102,6 +102,15 @@ export class PullRequestOverviewPanel {
});
});
return;
case 'pr.comment':
const text = message.text;
this._pullRequest.createDiscussionComment(text).then(comment => {
this._panel.webview.postMessage({
command: 'append-comment',
value: comment
});
});
return;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册