diff options
author | Fatih Acet <acetfatih@gmail.com> | 2018-07-12 00:36:14 +0200 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2018-07-18 12:55:56 +0200 |
commit | 9cd5ca2f57186c80257d9dd1ab12f957a97aac51 (patch) | |
tree | 22b7f1195698f37d5c27303f46814f218fba0439 | |
parent | 5f7a81c441a40203ae0a33ea8419028b08631caf (diff) | |
download | gitlab-ce-9cd5ca2f57186c80257d9dd1ab12f957a97aac51.tar.gz |
Fix autosave in noteable discussion.
-rw-r--r-- | app/assets/javascripts/diffs/components/diff_line_note_form.vue | 11 | ||||
-rw-r--r-- | app/assets/javascripts/notes/components/noteable_discussion.vue | 23 |
2 files changed, 16 insertions, 18 deletions
diff --git a/app/assets/javascripts/diffs/components/diff_line_note_form.vue b/app/assets/javascripts/diffs/components/diff_line_note_form.vue index 5476fb47967..5d9bd78a1a5 100644 --- a/app/assets/javascripts/diffs/components/diff_line_note_form.vue +++ b/app/assets/javascripts/diffs/components/diff_line_note_form.vue @@ -1,12 +1,11 @@ <script> -import $ from 'jquery'; import { mapState, mapGetters, mapActions } from 'vuex'; import createFlash from '~/flash'; import { s__ } from '~/locale'; import noteForm from '../../notes/components/note_form.vue'; import { getNoteFormData } from '../store/utils'; import autosave from '../../notes/mixins/autosave'; -import { DIFF_NOTE_TYPE, NOTE_TYPE } from '../constants'; +import { DIFF_NOTE_TYPE } from '../constants'; export default { components: { @@ -42,21 +41,21 @@ export default { }, mounted() { if (this.isLoggedIn) { - const noteableData = this.noteableData; const keys = [ - noteableData.diff_head_sha, + this.noteableData.diff_head_sha, DIFF_NOTE_TYPE, - noteableData.source_project_id, + this.noteableData.source_project_id, this.line.lineCode, ]; - this.initAutoSave(noteableData, keys); + this.initAutoSave(this.noteableData, keys); } }, methods: { ...mapActions('diffs', ['cancelCommentForm']), ...mapActions(['saveNote', 'refetchDiscussionById']), handleCancelCommentForm() { + // eslint-disable-next-line no-alert if (!window.confirm('Are you sure you want to cancel creating this comment?')) { return; } diff --git a/app/assets/javascripts/notes/components/noteable_discussion.vue b/app/assets/javascripts/notes/components/noteable_discussion.vue index 0216869d36f..4a0d526ff37 100644 --- a/app/assets/javascripts/notes/components/noteable_discussion.vue +++ b/app/assets/javascripts/notes/components/noteable_discussion.vue @@ -144,19 +144,17 @@ export default { return this.isDiffDiscussion ? '' : 'card discussion-wrapper'; }, }, - mounted() { - if (this.isReplying) { - this.initAutoSave(this.transformedDiscussion); - } - }, - updated() { - if (this.isReplying) { - if (!this.autosave) { - this.initAutoSave(this.transformedDiscussion); + watch: { + isReplying() { + if (this.isReplying) { + this.$nextTick(() => { + // Pass an extra key to separate reply and note edit forms + this.initAutoSave(this.transformedDiscussion, ['Reply']); + }); } else { - this.setAutoSave(); + this.autosave.dispose(); } - } + }, }, created() { this.resolveDiscussionsSvg = resolveDiscussionsSvg; @@ -420,7 +418,8 @@ Please check your network connection and try again.`; :is-editing="false" save-button-title="Comment" @handleFormUpdate="saveReply" - @cancelForm="cancelReplyForm" /> + @cancelForm="cancelReplyForm" + /> <note-signed-out-widget v-if="!canReply" /> </div> </div> |