diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /app/assets/javascripts/notes/components/note_form.vue | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) | |
download | gitlab-ce-8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781.tar.gz |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'app/assets/javascripts/notes/components/note_form.vue')
-rw-r--r-- | app/assets/javascripts/notes/components/note_form.vue | 70 |
1 files changed, 64 insertions, 6 deletions
diff --git a/app/assets/javascripts/notes/components/note_form.vue b/app/assets/javascripts/notes/components/note_form.vue index 21d0bffdf1c..795ee10ca0f 100644 --- a/app/assets/javascripts/notes/components/note_form.vue +++ b/app/assets/javascripts/notes/components/note_form.vue @@ -1,6 +1,5 @@ <script> -import { mapGetters, mapActions } from 'vuex'; -import noteFormMixin from 'ee_else_ce/notes/mixins/note_form'; +import { mapGetters, mapActions, mapState } from 'vuex'; import { mergeUrlParams } from '~/lib/utils/url_utility'; import eventHub from '../event_hub'; import issueWarning from '../../vue_shared/components/issue/issue_warning.vue'; @@ -16,7 +15,7 @@ export default { issueWarning, markdownField, }, - mixins: [issuableStateMixin, resolvable, noteFormMixin], + mixins: [issuableStateMixin, resolvable], props: { noteBody: { type: String, @@ -82,6 +81,11 @@ export default { required: false, default: false, }, + isDraft: { + type: Boolean, + required: false, + default: false, + }, }, data() { let updatedNoteBody = this.noteBody; @@ -107,6 +111,16 @@ export default { 'getNotesDataByProp', 'getUserDataByProp', ]), + ...mapState({ + withBatchComments: state => state.batchComments?.withBatchComments, + }), + ...mapGetters('batchComments', ['hasDrafts']), + showBatchCommentsActions() { + return this.withBatchComments && this.noteId === '' && !this.discussion.for_commit; + }, + showResolveDiscussionToggle() { + return (this.discussion?.id && this.discussion.resolvable) || this.isDraft; + }, noteHash() { if (this.noteId) { return `#note_${this.noteId}`; @@ -202,8 +216,6 @@ export default { methods: { ...mapActions(['toggleResolveNote']), shouldToggleResolved(shouldResolve, beforeSubmitDiscussionState) { - // shouldBeResolved() checks the actual resolution state, - // considering batchComments (EEP), if applicable/enabled. const newResolvedStateAfterUpdate = this.shouldBeResolved && this.shouldBeResolved(shouldResolve); @@ -234,6 +246,50 @@ export default { updateDraft(autosaveKey, text); } }, + handleKeySubmit() { + if (this.showBatchCommentsActions) { + this.handleAddToReview(); + } else { + this.handleUpdate(); + } + }, + handleUpdate(shouldResolve) { + const beforeSubmitDiscussionState = this.discussionResolved; + this.isSubmitting = true; + + this.$emit( + 'handleFormUpdate', + this.updatedNoteBody, + this.$refs.editNoteForm, + () => { + this.isSubmitting = false; + + if (this.shouldToggleResolved(shouldResolve, beforeSubmitDiscussionState)) { + this.resolveHandler(beforeSubmitDiscussionState); + } + }, + this.discussionResolved ? !this.isUnresolving : this.isResolving, + ); + }, + shouldBeResolved(resolveStatus) { + if (this.withBatchComments) { + return ( + (this.discussionResolved && !this.isUnresolving) || + (!this.discussionResolved && this.isResolving) + ); + } + + return resolveStatus; + }, + handleAddToReview() { + // check if draft should resolve thread + const shouldResolve = + (this.discussionResolved && !this.isUnresolving) || + (!this.discussionResolved && this.isResolving); + this.isSubmitting = true; + + this.$emit('handleFormUpdateAddToReview', this.updatedNoteBody, shouldResolve); + }, }, }; </script> @@ -293,6 +349,7 @@ export default { <input v-model="isUnresolving" type="checkbox" + class="js-unresolve-checkbox" data-qa-selector="unresolve_review_discussion_checkbox" /> {{ __('Unresolve thread') }} @@ -301,6 +358,7 @@ export default { <input v-model="isResolving" type="checkbox" + class="js-resolve-checkbox" data-qa-selector="resolve_review_discussion_checkbox" /> {{ __('Resolve thread') }} @@ -320,7 +378,7 @@ export default { <button :disabled="isDisabled" type="button" - class="btn qa-comment-now" + class="btn qa-comment-now js-comment-button" @click="handleUpdate()" > {{ __('Add comment now') }} |