Commit 6ba4be4d authored by Phil Hughes's avatar Phil Hughes

Merge branch '12632-fix-multiple-discussions' into 'master'

Starting a new discussion only on line without Draft note created on it

Closes #12632

See merge request gitlab-org/gitlab-ee!14569
parents cc63ce9b db42f841
...@@ -24,6 +24,11 @@ export default { ...@@ -24,6 +24,11 @@ export default {
required: false, required: false,
default: '', default: '',
}, },
hasDraft: {
type: Boolean,
required: false,
default: false,
},
}, },
computed: { computed: {
className() { className() {
...@@ -55,6 +60,7 @@ export default { ...@@ -55,6 +60,7 @@ export default {
:help-page-path="helpPagePath" :help-page-path="helpPagePath"
/> />
<diff-discussion-reply <diff-discussion-reply
v-if="!hasDraft"
:has-form="line.hasForm" :has-form="line.hasForm"
:render-reply-placeholder="Boolean(line.discussions.length)" :render-reply-placeholder="Boolean(line.discussions.length)"
@showNewDiscussionForm=" @showNewDiscussionForm="
......
...@@ -57,6 +57,7 @@ export default { ...@@ -57,6 +57,7 @@ export default {
:diff-file-hash="diffFile.file_hash" :diff-file-hash="diffFile.file_hash"
:line="line" :line="line"
:help-page-path="helpPagePath" :help-page-path="helpPagePath"
:has-draft="shouldRenderDraftRow(diffFile.file_hash, line) || false"
/> />
<inline-draft-comment-row <inline-draft-comment-row
v-if="shouldRenderDraftRow(diffFile.file_hash, line)" v-if="shouldRenderDraftRow(diffFile.file_hash, line)"
......
...@@ -28,6 +28,16 @@ export default { ...@@ -28,6 +28,16 @@ export default {
required: false, required: false,
default: '', default: '',
}, },
hasDraftLeft: {
type: Boolean,
required: false,
default: false,
},
hasDraftRight: {
type: Boolean,
required: false,
default: false,
},
}, },
computed: { computed: {
hasExpandedDiscussionOnLeft() { hasExpandedDiscussionOnLeft() {
...@@ -121,6 +131,7 @@ export default { ...@@ -121,6 +131,7 @@ export default {
/> />
</div> </div>
<diff-discussion-reply <diff-discussion-reply
v-if="!hasDraftLeft"
:has-form="showLeftSideCommentForm" :has-form="showLeftSideCommentForm"
:render-reply-placeholder="shouldRenderReplyPlaceholderOnLeft" :render-reply-placeholder="shouldRenderReplyPlaceholderOnLeft"
@showNewDiscussionForm="showNewDiscussionForm" @showNewDiscussionForm="showNewDiscussionForm"
...@@ -145,6 +156,7 @@ export default { ...@@ -145,6 +156,7 @@ export default {
/> />
</div> </div>
<diff-discussion-reply <diff-discussion-reply
v-if="!hasDraftRight"
:has-form="showRightSideCommentForm" :has-form="showRightSideCommentForm"
:render-reply-placeholder="shouldRenderReplyPlaceholderOnRight" :render-reply-placeholder="shouldRenderReplyPlaceholderOnRight"
@showNewDiscussionForm="showNewDiscussionForm" @showNewDiscussionForm="showNewDiscussionForm"
......
...@@ -58,6 +58,8 @@ export default { ...@@ -58,6 +58,8 @@ export default {
:diff-file-hash="diffFile.file_hash" :diff-file-hash="diffFile.file_hash"
:line-index="index" :line-index="index"
:help-page-path="helpPagePath" :help-page-path="helpPagePath"
:has-draft-left="hasParallelDraftLeft(diffFile.file_hash, line) || false"
:has-draft-right="hasParallelDraftRight(diffFile.file_hash, line) || false"
/> />
<parallel-draft-comment-row <parallel-draft-comment-row
v-if="shouldRenderParallelDraftRow(diffFile.file_hash, line)" v-if="shouldRenderParallelDraftRow(diffFile.file_hash, line)"
......
...@@ -41,6 +41,20 @@ export const shouldRenderParallelDraftRow = (state, getters) => (diffFileSha, li ...@@ -41,6 +41,20 @@ export const shouldRenderParallelDraftRow = (state, getters) => (diffFileSha, li
return draftsForFile ? Boolean(draftsForFile[lkey] || draftsForFile[rkey]) : false; return draftsForFile ? Boolean(draftsForFile[lkey] || draftsForFile[rkey]) : false;
}; };
export const hasParallelDraftLeft = (state, getters) => (diffFileSha, line) => {
const draftsForFile = getters.draftsPerFileHashAndLine[diffFileSha];
const lkey = parallelLineKey(line, 'left');
return draftsForFile ? Boolean(draftsForFile[lkey]) : false;
};
export const hasParallelDraftRight = (state, getters) => (diffFileSha, line) => {
const draftsForFile = getters.draftsPerFileHashAndLine[diffFileSha];
const rkey = parallelLineKey(line, 'left');
return draftsForFile ? Boolean(draftsForFile[rkey]) : false;
};
export const shouldRenderDraftRowInDiscussion = (state, getters) => discussionId => export const shouldRenderDraftRowInDiscussion = (state, getters) => discussionId =>
typeof getters.draftsPerDiscussionId[discussionId] !== 'undefined'; typeof getters.draftsPerDiscussionId[discussionId] !== 'undefined';
......
...@@ -7,6 +7,8 @@ export default { ...@@ -7,6 +7,8 @@ export default {
'shouldRenderParallelDraftRow', 'shouldRenderParallelDraftRow',
'draftForLine', 'draftForLine',
'draftsForFile', 'draftsForFile',
'hasParallelDraftLeft',
'hasParallelDraftRight',
]), ]),
imageDiscussions() { imageDiscussions() {
return this.diffFile.discussions.concat(this.draftsForFile(this.diffFile.file_hash)); return this.diffFile.discussions.concat(this.draftsForFile(this.diffFile.file_hash));
......
---
title: Starting a new discussion only on line without Draft note created on it
merge_request: 14569
author:
type: fixed
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