Commit 016c79ca authored by sarahghp's avatar sarahghp

Add changes to match ee

parent 7b5cc7b4
...@@ -49,7 +49,7 @@ export default { ...@@ -49,7 +49,7 @@ export default {
required: false, required: false,
default: () => ({ default: () => ({
sourceProjectId: '', sourceProjectId: '',
issueId: '', mergeRequestId: '',
appUrl: '', appUrl: '',
}), }),
}, },
......
...@@ -48,7 +48,7 @@ export default { ...@@ -48,7 +48,7 @@ export default {
visualReviewAppMeta() { visualReviewAppMeta() {
return { return {
appUrl: this.mr.appUrl, appUrl: this.mr.appUrl,
issueId: this.mr.iid, mergeRequestId: this.mr.iid,
sourceProjectId: this.mr.sourceProjectId, sourceProjectId: this.mr.sourceProjectId,
}; };
}, },
......
...@@ -374,12 +374,12 @@ function clearNote (inputId) { ...@@ -374,12 +374,12 @@ function clearNote (inputId) {
} }
} }
function confirmAndClear (discussionId) { function confirmAndClear (mergeRequestId) {
const commentButton = document.getElementById('gitlab-comment-button'); const commentButton = document.getElementById('gitlab-comment-button');
const note = document.getElementById('gitlab-validation-note'); const note = document.getElementById('gitlab-validation-note');
commentButton.innerText = 'Feedback sent'; commentButton.innerText = 'Feedback sent';
note.innerText = `Your comment was successfully posted to issue #${discussionId}`; note.innerText = `Your comment was successfully posted to merge request #${mergeRequestId}`;
setTimeout(resetCommentButton, 1000); setTimeout(resetCommentButton, 1000);
} }
...@@ -412,7 +412,7 @@ function getProjectDetails () { ...@@ -412,7 +412,7 @@ function getProjectDetails () {
const browser = getBrowserId(userAgent); const browser = getBrowserId(userAgent);
const scriptEl = document.getElementById('review-app-toolbar-script') const scriptEl = document.getElementById('review-app-toolbar-script')
const { projectId, discussionId, mrUrl } = scriptEl.dataset; const { projectId, mergeRequestId, mrUrl } = scriptEl.dataset;
return { return {
href, href,
...@@ -422,7 +422,7 @@ function getProjectDetails () { ...@@ -422,7 +422,7 @@ function getProjectDetails () {
innerWidth, innerWidth,
innerHeight, innerHeight,
projectId, projectId,
discussionId, mergeRequestId,
mrUrl, mrUrl,
}; };
} }
...@@ -449,7 +449,7 @@ function postComment ({ ...@@ -449,7 +449,7 @@ function postComment ({
innerWidth, innerWidth,
innerHeight, innerHeight,
projectId, projectId,
discussionId, mergeRequestId,
mrUrl, mrUrl,
}) { }) {
// Clear any old errors // Clear any old errors
...@@ -466,18 +466,20 @@ function postComment ({ ...@@ -466,18 +466,20 @@ function postComment ({
} }
const detailText = ` const detailText = `
<details> \n
<summary>Metadata</summary> <details>
Posted from ${href} | ${platform} | ${browser} | ${innerWidth} x ${innerHeight}. <summary>Metadata</summary>
<br /><br /> Posted from ${href} | ${platform} | ${browser} | ${innerWidth} x ${innerHeight}.
*User agent: ${userAgent}* <br /><br />
</details> <em>User agent: ${userAgent}</em>
</details>
`; `;
const url = ` const url = `
${mrUrl}/api/v4/projects/${projectId}/issues/${discussionId}/discussions`; ${mrUrl}/api/v4/projects/${projectId}/merge_requests/${mergeRequestId}/discussions`;
const body = `${commentText}${detailText}`;
const body = `${commentText} ${detailText}`;
fetch(url, { fetch(url, {
method: 'POST', method: 'POST',
...@@ -489,7 +491,7 @@ function postComment ({ ...@@ -489,7 +491,7 @@ function postComment ({
}) })
.then((response) => { .then((response) => {
if (response.ok) { if (response.ok) {
confirmAndClear(discussionId); confirmAndClear(mergeRequestId);
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment