提交 8730f968 编写于 作者: P Peng Lyu

explicit reply comment thread command

上级 4ef75189
......@@ -150,14 +150,12 @@ export class PRProvider implements vscode.TreeDataProvider<PRGroupTreeItem | Pul
};
}
});
let reply = {
command: 'diff-' + element.prItem.number + '-post',
title: 'Add single comment'
};
let actions = [
{
command: 'diff-' + element.prItem.number + '-post',
title: 'Add single comment'
}
];
let actions = [reply];
const _onDidChangeCommentThreads = new vscode.EventEmitter<vscode.CommentThreadChangedEvent>();
setTimeout(() => _onDidChangeCommentThreads.fire({ changed: [], added: [], removed: [] }), 5000);
......@@ -226,7 +224,7 @@ export class PRProvider implements vscode.TreeDataProvider<PRGroupTreeItem | Pul
gravatar: comment.user.avatar_url
};
}),
actions: actions
reply: reply
});
}
......
......@@ -38,6 +38,7 @@ export class ReviewMode {
private _commentsCache: Map<String, Comment[]>;
private _localFileChanges: FileChangeTreeItem[] = [];
private _actions: vscode.Command[] = [];
private _reply: vscode.Command = null;
private _lastCommitSha: string;
private _onDidChangeCommentThreads = new vscode.EventEmitter<vscode.CommentThreadChangedEvent>();
......@@ -132,12 +133,12 @@ export class ReviewMode {
}
});
this._actions = [
{
command: this._prNumber + '-post',
title: 'Add single comment'
}
];
this._reply = {
command: this._prNumber + '-post',
title: 'Add single comment'
};
this._actions = [this._reply];
this.registerCommentProvider();
......@@ -282,7 +283,7 @@ export class ReviewMode {
gravatar: comment.user.avatar_url
};
}),
actions: this._actions
reply: this._reply
});
}
......
......@@ -943,7 +943,7 @@ export interface CommentThread {
readonly resource: string;
readonly range: IRange;
readonly comments: Comment[];
readonly actions: Command[];
readonly reply: Command;
}
export interface NewCommentAction {
......
......@@ -5033,7 +5033,7 @@ declare namespace monaco.languages {
readonly resource: string;
readonly range: IRange;
readonly comments: Comment[];
readonly actions: Command[];
readonly reply: Command;
}
export interface NewCommentAction {
......
......@@ -775,7 +775,7 @@ declare module 'vscode' {
resource: Uri;
range: Range;
comments: Comment[];
actions?: Command[];
reply?: Command;
}
interface NewCommentAction {
......
......@@ -118,7 +118,7 @@ function convertCommentThread(vscodeCommentThread: vscode.CommentThread, command
resource: vscodeCommentThread.resource.toString(),
range: extHostTypeConverter.fromRange(vscodeCommentThread.range),
comments: vscodeCommentThread.comments.map(convertComment),
actions: vscodeCommentThread.actions.map(commandsConverter.toInternal)
reply: vscodeCommentThread.reply ? commandsConverter.toInternal(vscodeCommentThread.reply) : null
};
}
......
......@@ -268,14 +268,14 @@ export class ReviewZoneWidget extends ZoneWidget {
this._commentsElement.appendChild(newCommentNode.domNode);
}
const commentForm = $('.comment-form').appendTo(this._bodyElement).getHTMLElement();
const textArea = <HTMLTextAreaElement>$('textarea').appendTo(commentForm).getHTMLElement();
const formActions = $('.form-actions').appendTo(commentForm).getHTMLElement();
if (this._commentThread.reply) {
const commentForm = $('.comment-form').appendTo(this._bodyElement).getHTMLElement();
const textArea = <HTMLTextAreaElement>$('textarea').appendTo(commentForm).getHTMLElement();
const formActions = $('.form-actions').appendTo(commentForm).getHTMLElement();
for (const action of this._commentThread.actions) {
const button = $('button').appendTo(formActions).getHTMLElement();
button.onclick = async () => {
let newComment = await this.commandService.executeCommand(action.id, this._commentThread.threadId, this.editor.getModel().uri, lineNumber, textArea.value);
let newComment = await this.commandService.executeCommand(this._commentThread.reply.id, this._commentThread.threadId, this.editor.getModel().uri, lineNumber, textArea.value);
if (newComment) {
textArea.value = '';
this._commentThread.comments.push(newComment);
......@@ -286,7 +286,7 @@ export class ReviewZoneWidget extends ZoneWidget {
$(this._secondaryHeading).safeInnerHtml(secondaryHeading);
}
};
button.textContent = action.title;
button.textContent = this._commentThread.reply.title;
}
this._resizeObserver = new ResizeObserver(entries => {
......@@ -538,7 +538,8 @@ export class ReviewController implements IEditorContribution {
endLineNumber: lineNumber,
endColumn: 0
},
actions: newCommentAction.actions
reply: null
// actions: newCommentAction.actions
}, {}, this.themeService, this.commandService);
this._zoneWidget.onDidClose(e => {
this._zoneWidget = null;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册