Skip to content
Snippets Groups Projects
Commit 1fec9ebe authored by Phil Hughes's avatar Phil Hughes
Browse files

Merge branch 'vrt-mr-update-ce-backport' into 'master'

Conformance MR for Update Visual Review Toolbar to post to MRs

See merge request gitlab-org/gitlab-ce!28687
parents f0ef8700 016c79ca
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -49,7 +49,7 @@ export default {
required: false,
default: () => ({
sourceProjectId: '',
issueId: '',
mergeRequestId: '',
appUrl: '',
}),
},
Loading
Loading
Loading
Loading
@@ -48,7 +48,7 @@ export default {
visualReviewAppMeta() {
return {
appUrl: this.mr.appUrl,
issueId: this.mr.iid,
mergeRequestId: this.mr.iid,
sourceProjectId: this.mr.sourceProjectId,
};
},
Loading
Loading
Loading
Loading
@@ -374,12 +374,12 @@ function clearNote (inputId) {
}
}
 
function confirmAndClear (discussionId) {
function confirmAndClear (mergeRequestId) {
const commentButton = document.getElementById('gitlab-comment-button');
const note = document.getElementById('gitlab-validation-note');
 
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);
}
Loading
Loading
@@ -412,7 +412,7 @@ function getProjectDetails () {
const browser = getBrowserId(userAgent);
 
const scriptEl = document.getElementById('review-app-toolbar-script')
const { projectId, discussionId, mrUrl } = scriptEl.dataset;
const { projectId, mergeRequestId, mrUrl } = scriptEl.dataset;
 
return {
href,
Loading
Loading
@@ -422,7 +422,7 @@ function getProjectDetails () {
innerWidth,
innerHeight,
projectId,
discussionId,
mergeRequestId,
mrUrl,
};
}
Loading
Loading
@@ -449,7 +449,7 @@ function postComment ({
innerWidth,
innerHeight,
projectId,
discussionId,
mergeRequestId,
mrUrl,
}) {
// Clear any old errors
Loading
Loading
@@ -466,18 +466,20 @@ function postComment ({
}
 
const detailText = `
<details>
<summary>Metadata</summary>
Posted from ${href} | ${platform} | ${browser} | ${innerWidth} x ${innerHeight}.
<br /><br />
*User agent: ${userAgent}*
</details>
\n
<details>
<summary>Metadata</summary>
Posted from ${href} | ${platform} | ${browser} | ${innerWidth} x ${innerHeight}.
<br /><br />
<em>User agent: ${userAgent}</em>
</details>
`;
 
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, {
method: 'POST',
Loading
Loading
@@ -489,7 +491,7 @@ function postComment ({
})
.then((response) => {
if (response.ok) {
confirmAndClear(discussionId);
confirmAndClear(mergeRequestId);
return;
}
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment