Commit 9abe46ab authored by Enrique Alcántara's avatar Enrique Alcántara

Merge branch 'jdb/fix-mlc-comments-on-overview-tab' into 'master'

Update multiline comment display

See merge request gitlab-org/gitlab!38721
parents 2cd472a6 5ff36b8c
...@@ -23,7 +23,6 @@ import { ...@@ -23,7 +23,6 @@ import {
commentLineOptions, commentLineOptions,
formatLineRange, formatLineRange,
} from './multiline_comment_utils'; } from './multiline_comment_utils';
import MultilineCommentForm from './multiline_comment_form.vue';
export default { export default {
name: 'NoteableNote', name: 'NoteableNote',
...@@ -34,7 +33,6 @@ export default { ...@@ -34,7 +33,6 @@ export default {
noteActions, noteActions,
NoteBody, NoteBody,
TimelineEntryItem, TimelineEntryItem,
MultilineCommentForm,
}, },
mixins: [noteable, resolvable, glFeatureFlagsMixin()], mixins: [noteable, resolvable, glFeatureFlagsMixin()],
props: { props: {
...@@ -147,14 +145,16 @@ export default { ...@@ -147,14 +145,16 @@ export default {
return getEndLineNumber(this.lineRange); return getEndLineNumber(this.lineRange);
}, },
showMultiLineComment() { showMultiLineComment() {
if (!this.glFeatures.multilineComments || !this.discussionRoot) return false; if (
if (this.isEditing) return true; !this.glFeatures.multilineComments ||
!this.discussionRoot ||
this.startLineNumber.length === 0 ||
this.endLineNumber.length === 0
)
return false;
return this.line && this.startLineNumber !== this.endLineNumber; return this.line && this.startLineNumber !== this.endLineNumber;
}, },
showMultilineCommentForm() {
return Boolean(this.isEditing && this.note.position && this.diffFile && this.line);
},
commentLineOptions() { commentLineOptions() {
const sideA = this.line.type === 'new' ? 'right' : 'left'; const sideA = this.line.type === 'new' ? 'right' : 'left';
const sideB = sideA === 'left' ? 'right' : 'left'; const sideB = sideA === 'left' ? 'right' : 'left';
...@@ -344,17 +344,9 @@ export default { ...@@ -344,17 +344,9 @@ export default {
:data-note-id="note.id" :data-note-id="note.id"
class="note note-wrapper qa-noteable-note-item" class="note note-wrapper qa-noteable-note-item"
> >
<div v-if="showMultiLineComment" data-testid="multiline-comment">
<multiline-comment-form
v-if="showMultilineCommentForm"
v-model="commentLineStart"
:line="line"
:comment-line-options="commentLineOptions"
:line-range="note.position.line_range"
class="gl-mb-3 gl-text-gray-700 gl-pb-3"
/>
<div <div
v-else v-if="showMultiLineComment"
data-testid="multiline-comment"
class="gl-mb-3 gl-text-gray-700 gl-border-gray-200 gl-border-b-solid gl-border-b-1 gl-pb-3" class="gl-mb-3 gl-text-gray-700 gl-border-gray-200 gl-border-b-solid gl-border-b-1 gl-pb-3"
> >
<gl-sprintf :message="__('Comment on lines %{startLine} to %{endLine}')"> <gl-sprintf :message="__('Comment on lines %{startLine} to %{endLine}')">
...@@ -366,7 +358,6 @@ export default { ...@@ -366,7 +358,6 @@ export default {
</template> </template>
</gl-sprintf> </gl-sprintf>
</div> </div>
</div>
<div v-once class="timeline-icon"> <div v-once class="timeline-icon">
<user-avatar-link <user-avatar-link
:link-href="author.path" :link-href="author.path"
......
---
title: Fix multiline comment rendering
merge_request: 38721
author:
type: fixed
...@@ -83,19 +83,35 @@ describe('issue_note', () => { ...@@ -83,19 +83,35 @@ describe('issue_note', () => {
}); });
}); });
it('should render multiline comment if editing discussion root', () => { it('should only render if it has everything it needs', () => {
wrapper.setProps({ discussionRoot: true }); const position = {
wrapper.vm.isEditing = true; line_range: {
start: {
return wrapper.vm.$nextTick().then(() => { line_code: 'abc_1_1',
expect(findMultilineComment().exists()).toBe(true); type: null,
}); old_line: '',
new_line: '',
},
end: {
line_code: 'abc_2_2',
type: null,
old_line: '2',
new_line: '2',
},
},
};
const line = {
line_code: 'abc_1_1',
type: null,
old_line: '1',
new_line: '1',
};
wrapper.setProps({
note: { ...note, position },
discussionRoot: true,
line,
}); });
it('should only render multiline comment form if it has everything it needs', () => {
wrapper.setProps({ line: { line_code: '' } });
wrapper.vm.isEditing = true;
return wrapper.vm.$nextTick().then(() => { return wrapper.vm.$nextTick().then(() => {
expect(findMultilineComment().exists()).toBe(false); expect(findMultilineComment().exists()).toBe(false);
}); });
......
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