提交 3affb105 编写于 作者: J John Hampton 提交者: Fatih Acet

Add Comment in MR

上级 d35e2d23
# CHANGELOG
## v2.2.0 - 2019-11-06
- [Experimental Feature](https://gitlab.com/fatihacet/gitlab-vscode-extension#experimental-features): View Merge Request details and comments in VSCode. Click a Merge Request link from the sidebar and VSCode will open a new tab to show the Merge Request details. You can also directly comment on the Merge Request.
## v2.1.1 - 2019-07-10
### Fixed
......
{
"name": "gitlab-workflow",
"version": "2.1.0",
"version": "2.2.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......
......@@ -2,7 +2,7 @@
"name": "gitlab-workflow",
"displayName": "GitLab Workflow",
"description": "GitLab VSCode integration",
"version": "2.1.1",
"version": "2.2.0",
"publisher": "fatihacet",
"license": "MIT",
"repository": {
......
......@@ -180,9 +180,7 @@ async function fetchIssuables(params = {}) {
config.scope = config.scope.replace(/_/g, '-');
}
const path = `/projects/${project.id}/${config.type}?scope=${config.scope}&state=${
config.state
}`;
const path = `/projects/${project.id}/${config.type}?scope=${config.scope}&state=${config.state}`;
issuables = await fetch(path);
}
......@@ -419,15 +417,14 @@ async function renderMarkdown(markdown) {
return rendered.html;
}
async function saveNote({ issuable, note }) {
async function saveNote({ issuable, note, noteType }) {
let response = {};
try {
const projectId = issuable.project_id;
const issueId = issuable.iid;
response = await fetch(`/projects/${projectId}/issues/${issueId}/notes`, 'POST', {
id: projectId,
issue_iid: issueId,
const { iid } = issuable;
const { path } = noteType;
response = await fetch(`/projects/${projectId}/${path}/${iid}/notes`, 'POST', {
body: note,
});
} catch (e) {
......
......@@ -10,7 +10,7 @@ class SidebarTreeItem extends vscode.TreeItem {
let command = 'gl.showRichContent';
let arg = data;
if (data.sha || !enableExperimentalFeatures) {
if (!enableExperimentalFeatures) {
command = 'vscode.open';
arg = vscode.Uri.parse(data.web_url);
}
......
......@@ -20,12 +20,16 @@ export default {
},
},
methods: {
getNoteType() {
return this.issuable.sha ? { type: 'merge_request', path: 'merge_requests' } : { type: 'issue', path: 'issues' };
},
addComment() {
const { issuable, note, command } = this;
this.isSaving = true;
this.isFailed = false;
window.vsCodeApi.postMessage({ command, issuable, note });
const noteType = this.getNoteType();
window.vsCodeApi.postMessage({ command, issuable, note, noteType });
},
},
mounted() {
......
......@@ -20,7 +20,7 @@ const getNonce = () => {
return text;
};
const getResources = () => {
const getResources = panel => {
const paths = {
appScriptUri: 'src/webview/dist/js/app.js',
vendorUri: 'src/webview/dist/js/chunk-vendors.js',
......@@ -31,7 +31,7 @@ const getResources = () => {
Object.keys(paths).forEach(key => {
const uri = vscode.Uri.file(path.join(context.extensionPath, paths[key]));
paths[key] = uri.with({ scheme: 'vscode-resource' });
paths[key] = panel.webview.asWebviewUri(uri);
});
return paths;
......@@ -43,8 +43,8 @@ const getIndexPath = () => {
return isDev ? 'src/webview/public/dev.html' : 'src/webview/public/index.html';
};
const replaceResources = () => {
const { appScriptUri, vendorUri, styleUri, devScriptUri } = getResources();
const replaceResources = panel => {
const { appScriptUri, vendorUri, styleUri, devScriptUri } = getResources(panel);
return fs
.readFileSync(path.join(context.extensionPath, getIndexPath()), 'UTF-8')
......@@ -96,6 +96,7 @@ async function handleCreate(panel, issuable) {
const response = await gitLabService.saveNote({
issuable: message.issuable,
note: message.note,
noteType: message.noteType,
});
if (response.status !== false) {
......@@ -114,7 +115,7 @@ async function handleCreate(panel, issuable) {
async function create(issuable) {
const panel = createPanel(issuable);
const html = replaceResources();
const html = replaceResources(panel);
panel.webview.html = html;
panel.onDidChangeViewState(() => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册