summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/diffs/components/diff_line_note_form.vue
diff options
context:
space:
mode:
authorFelipe Artur <fcardozo@gitlab.com>2018-07-27 18:25:53 +0000
committerFelipe Artur <fcardozo@gitlab.com>2018-07-27 18:25:53 +0000
commit0cf823558887aaf2ad041473ed9961755d5d5f3b (patch)
treecafd8d35271ddad4890ce05c88075816f8733e01 /app/assets/javascripts/diffs/components/diff_line_note_form.vue
parent923b26133b8d04e8c4da4183b8f0382eefcc8147 (diff)
parentd1f09ec7cdab3b6892b1006b8c382c08be4cd9e0 (diff)
downloadgitlab-ce-0cf823558887aaf2ad041473ed9961755d5d5f3b.tar.gz
Merge branch '11-1-3-stable-fixes-mr-refactor-regressions' into '11-1-stable-patch-3'11-1-stable-patch-3
MR refactor fixes for 11.1.3 See merge request gitlab-org/gitlab-ce!20878
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.vue31
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);