diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-18 03:09:24 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-18 03:09:24 +0000 |
commit | 95f5aad5aa99577555f01476f771e581957934f1 (patch) | |
tree | 3ce10768748ac63c5b42dfbfde989983afa54973 /app/assets/javascripts/notes | |
parent | ccefff8087799bc076737ad080f18cf98e6fe114 (diff) | |
download | gitlab-ce-95f5aad5aa99577555f01476f771e581957934f1.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/notes')
-rw-r--r-- | app/assets/javascripts/notes/components/discussion_notes.vue | 18 | ||||
-rw-r--r-- | app/assets/javascripts/notes/components/noteable_note.vue | 7 |
2 files changed, 20 insertions, 5 deletions
diff --git a/app/assets/javascripts/notes/components/discussion_notes.vue b/app/assets/javascripts/notes/components/discussion_notes.vue index 458da5cf67f..a1e887c47d0 100644 --- a/app/assets/javascripts/notes/components/discussion_notes.vue +++ b/app/assets/javascripts/notes/components/discussion_notes.vue @@ -9,6 +9,7 @@ import NoteableNote from './noteable_note.vue'; import ToggleRepliesWidget from './toggle_replies_widget.vue'; import NoteEditedText from './note_edited_text.vue'; import DiscussionNotesRepliesWrapper from './discussion_notes_replies_wrapper.vue'; +import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; export default { name: 'DiscussionNotes', @@ -17,6 +18,7 @@ export default { NoteEditedText, DiscussionNotesRepliesWrapper, }, + mixins: [glFeatureFlagsMixin()], props: { discussion: { type: Object, @@ -93,6 +95,18 @@ export default { componentData(note) { return note.isPlaceholderNote ? note.notes[0] : note; }, + handleMouseEnter(discussion) { + if (this.glFeatures.multilineComments && discussion.position) { + this.setSelectedCommentPositionHover(discussion.position.line_range); + } + }, + handleMouseLeave(discussion) { + // Even though position isn't used here we still don't want to unecessarily call a mutation + // The lack of position tells us that highlighting is irrelevant in this context + if (this.glFeatures.multilineComments && discussion.position) { + this.setSelectedCommentPositionHover(); + } + }, }, }; </script> @@ -101,8 +115,8 @@ export default { <div class="discussion-notes"> <ul class="notes" - @mouseenter="setSelectedCommentPositionHover(discussion.position.line_range)" - @mouseleave="setSelectedCommentPositionHover()" + @mouseenter="handleMouseEnter(discussion)" + @mouseleave="handleMouseLeave(discussion)" > <template v-if="shouldGroupReplies"> <component diff --git a/app/assets/javascripts/notes/components/noteable_note.vue b/app/assets/javascripts/notes/components/noteable_note.vue index 9bf8cffe940..5999ded8721 100644 --- a/app/assets/javascripts/notes/components/noteable_note.vue +++ b/app/assets/javascripts/notes/components/noteable_note.vue @@ -152,9 +152,10 @@ export default { return this.line && this.startLineNumber !== this.endLineNumber; }, + showMultilineCommentForm() { + return Boolean(this.isEditing && this.note.position && this.diffFile && this.line); + }, commentLineOptions() { - if (!this.diffFile || !this.line) return []; - const sideA = this.line.type === 'new' ? 'right' : 'left'; const sideB = sideA === 'left' ? 'right' : 'left'; const lines = this.diffFile.highlighted_diff_lines.length @@ -339,7 +340,7 @@ export default { > <div v-if="showMultiLineComment" data-testid="multiline-comment"> <multiline-comment-form - v-if="isEditing && note.position" + v-if="showMultilineCommentForm" v-model="commentLineStart" :line="line" :comment-line-options="commentLineOptions" |