diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2018-07-18 15:12:31 +0000 |
---|---|---|
committer | André Luís <aluis@gitlab.com> | 2018-07-23 15:20:37 +0100 |
commit | 56c0658840511f47f198cb0204b81417b2531b7e (patch) | |
tree | c09b510011c617b7649b431b714c1c2e94734771 /app/assets/javascripts/diffs/components/diff_line_note_form.vue | |
parent | 8d4f7f3982553f547633b0567a12ffcd9e5c2cb7 (diff) | |
download | gitlab-ce-56c0658840511f47f198cb0204b81417b2531b7e.tar.gz |
Merge branch '_acet-fix-mr-autosave' into 'master'
Fix autosave issues for MR discussions
Closes #48876 and #48877
See merge request gitlab-org/gitlab-ce!20569
Diffstat (limited to 'app/assets/javascripts/diffs/components/diff_line_note_form.vue')
-rw-r--r-- | app/assets/javascripts/diffs/components/diff_line_note_form.vue | 31 |
1 files changed, 19 insertions, 12 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 32f9516d332..cbe4551d06b 100644 --- a/app/assets/javascripts/diffs/components/diff_line_note_form.vue +++ b/app/assets/javascripts/diffs/components/diff_line_note_form.vue @@ -1,17 +1,17 @@ <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 '../../autosave'; -import { DIFF_NOTE_TYPE, NOTE_TYPE } from '../constants'; +import autosave from '../../notes/mixins/autosave'; +import { DIFF_NOTE_TYPE } from '../constants'; export default { components: { noteForm, }, + mixins: [autosave], props: { diffFileHash: { type: String, @@ -41,28 +41,35 @@ export default { }, mounted() { if (this.isLoggedIn) { - const noteableData = this.getNoteableData; const keys = [ - NOTE_TYPE, - this.noteableType, - noteableData.id, - 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.autosave = new Autosave($(this.$refs.noteForm.$refs.textarea), keys); + this.initAutoSave(this.noteableData, keys); } }, methods: { ...mapActions('diffs', ['cancelCommentForm']), ...mapActions(['saveNote', 'refetchDiscussionById']), - handleCancelCommentForm() { - this.autosave.reset(); + handleCancelCommentForm(shouldConfirm, isDirty) { + if (shouldConfirm && isDirty) { + const msg = s__('Notes|Are you sure you want to cancel creating this comment?'); + + // eslint-disable-next-line no-alert + if (!window.confirm(msg)) { + return; + } + } + this.cancelCommentForm({ lineCode: this.line.lineCode, }); + this.$nextTick(() => { + this.resetAutoSave(); + }); }, handleSaveNote(note) { const selectedDiffFile = this.getDiffFileByHash(this.diffFileHash); |