From 1c2898583d1b4920c06627a900d8448cd12a61fd Mon Sep 17 00:00:00 2001 From: Lee Tickett Date: Wed, 24 Feb 2021 16:00:26 +0000 Subject: [PATCH 1/4] Allow add comment to review --- .../components/preview_item.vue | 14 +- .../notes/components/comment_form.vue | 129 +++++++++++------- .../notes/components/notes_app.vue | 7 + .../javascripts/notes/stores/getters.js | 27 +++- .../8225-allow-add-discussion-to-review.yml | 5 + .../discussions/img/mr_review_new_comment.png | Bin 0 -> 140521 bytes doc/user/discussions/img/review_preview.png | Bin 27664 -> 93375 bytes doc/user/discussions/index.md | 16 ++- .../components/batch_comments/draft_note.scss | 20 ++- locale/gitlab.pot | 3 + .../discussion_comments/merge_request_spec.rb | 36 ++++- .../components/preview_item_spec.js | 12 ++ .../notes/components/comment_form_spec.js | 67 ++++++++- .../notes/components/notes_app_spec.js | 32 +++++ spec/frontend/notes/mock_data.js | 10 ++ spec/frontend/notes/stores/getters_spec.js | 69 ++++++++-- 16 files changed, 355 insertions(+), 92 deletions(-) create mode 100644 changelogs/unreleased/8225-allow-add-discussion-to-review.yml create mode 100644 doc/user/discussions/img/mr_review_new_comment.png diff --git a/app/assets/javascripts/batch_comments/components/preview_item.vue b/app/assets/javascripts/batch_comments/components/preview_item.vue index 756bcfdb3d047e..753608cf6f7638 100644 --- a/app/assets/javascripts/batch_comments/components/preview_item.vue +++ b/app/assets/javascripts/batch_comments/components/preview_item.vue @@ -41,13 +41,17 @@ export default { titleText() { const file = this.discussion ? this.discussion.diff_file : this.draft; - if (file) { + if (file?.file_path) { return file.file_path; } - return sprintf(__("%{authorsName}'s thread"), { - authorsName: this.discussion.notes.find((note) => !note.system).author.name, - }); + if (this.discussion) { + return sprintf(__("%{authorsName}'s thread"), { + authorsName: this.discussion.notes.find((note) => !note.system).author.name, + }); + } + + return __('Your new comment'); }, linePosition() { if (this.position?.position_type === IMAGE_DIFF_POSITION_TYPE) { @@ -94,7 +98,7 @@ export default { - + {{ titleText }} + {{ issueActionButtonTitle }} diff --git a/app/assets/javascripts/notes/components/notes_app.vue b/app/assets/javascripts/notes/components/notes_app.vue index 58cfd150659922..433f75a752db85 100644 --- a/app/assets/javascripts/notes/components/notes_app.vue +++ b/app/assets/javascripts/notes/components/notes_app.vue @@ -3,8 +3,10 @@ import { mapGetters, mapActions } from 'vuex'; import highlightCurrentUser from '~/behaviors/markdown/highlight_current_user'; import { __ } from '~/locale'; import initUserPopovers from '~/user_popovers'; +import TimelineEntryItem from '~/vue_shared/components/notes/timeline_entry_item.vue'; import OrderedLayout from '~/vue_shared/components/ordered_layout.vue'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; +import draftNote from '../../batch_comments/components/draft_note.vue'; import { deprecatedCreateFlash as Flash } from '../../flash'; import { getLocationHash, doesHashExistInUrl } from '../../lib/utils/url_utility'; import placeholderNote from '../../vue_shared/components/notes/placeholder_note.vue'; @@ -32,6 +34,8 @@ export default { discussionFilterNote, OrderedLayout, SidebarSubscription, + draftNote, + TimelineEntryItem, }, mixins: [glFeatureFlagsMixin()], props: { @@ -276,6 +280,9 @@ export default {