Commit 5ff36b8c authored by Justin Boyson's avatar Justin Boyson Committed by Enrique Alcántara

Update MLC display

Remove MLC from usage in Overview tab
Hide text if start or endline are blank
parent 1d704420
...@@ -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,28 +344,19 @@ export default { ...@@ -344,28 +344,19 @@ 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"> <div
<multiline-comment-form v-if="showMultiLineComment"
v-if="showMultilineCommentForm" data-testid="multiline-comment"
v-model="commentLineStart" class="gl-mb-3 gl-text-gray-700 gl-border-gray-200 gl-border-b-solid gl-border-b-1 gl-pb-3"
:line="line" >
:comment-line-options="commentLineOptions" <gl-sprintf :message="__('Comment on lines %{startLine} to %{endLine}')">
:line-range="note.position.line_range" <template #startLine>
class="gl-mb-3 gl-text-gray-700 gl-pb-3" <span :class="getLineClasses(startLineNumber)">{{ startLineNumber }}</span>
/> </template>
<div <template #endLine>
v-else <span :class="getLineClasses(endLineNumber)">{{ endLineNumber }}</span>
class="gl-mb-3 gl-text-gray-700 gl-border-gray-200 gl-border-b-solid gl-border-b-1 gl-pb-3" </template>
> </gl-sprintf>
<gl-sprintf :message="__('Comment on lines %{startLine} to %{endLine}')">
<template #startLine>
<span :class="getLineClasses(startLineNumber)">{{ startLineNumber }}</span>
</template>
<template #endLine>
<span :class="getLineClasses(endLineNumber)">{{ endLineNumber }}</span>
</template>
</gl-sprintf>
</div>
</div> </div>
<div v-once class="timeline-icon"> <div v-once class="timeline-icon">
<user-avatar-link <user-avatar-link
......
---
title: Fix multiline comment rendering
merge_request: 38721
author:
type: fixed
...@@ -83,18 +83,34 @@ describe('issue_note', () => { ...@@ -83,18 +83,34 @@ 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