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 f63ab1bb0675d9344708fc54fccc08c1e506496a..43ba527dad8bd4d14c00fd7f0993da84ae8fb33c 100644 --- a/app/assets/javascripts/diffs/components/diff_line_note_form.vue +++ b/app/assets/javascripts/diffs/components/diff_line_note_form.vue @@ -8,7 +8,7 @@ import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import MultilineCommentForm from '~/notes/components/multiline_comment_form.vue'; import { commentLineOptions, formatLineRange } from '~/notes/components/multiline_comment_utils'; import NoteForm from '~/notes/components/note_form.vue'; -import autosave from '~/notes/mixins/autosave'; +import { capitalizeFirstCharacter } from '~/lib/utils/text_utility'; import { DIFF_NOTE_TYPE, INLINE_DIFF_LINES_KEY, @@ -21,7 +21,7 @@ export default { NoteForm, MultilineCommentForm, }, - mixins: [autosave, diffLineNoteFormMixin, glFeatureFlagsMixin()], + mixins: [diffLineNoteFormMixin, glFeatureFlagsMixin()], props: { diffFileHash: { type: String, @@ -146,6 +146,27 @@ export default { return lines; }, + autosaveKey() { + if (!this.isLoggedIn) return ''; + + const { + id, + noteable_type: noteableTypeUnderscored, + noteableType, + diff_head_sha: diffHeadSha, + source_project_id: sourceProjectId, + } = this.noteableData; + + return [ + s__('Autosave|Note'), + capitalizeFirstCharacter(noteableTypeUnderscored || noteableType), + id, + diffHeadSha, + DIFF_NOTE_TYPE, + sourceProjectId, + this.line.line_code, + ].join('/'); + }, }, created() { if (this.range) { @@ -155,17 +176,6 @@ export default { } }, mounted() { - if (this.isLoggedIn) { - const keys = [ - this.noteableData.diff_head_sha, - DIFF_NOTE_TYPE, - this.noteableData.source_project_id, - this.line.line_code, - ]; - - this.initAutoSave(this.noteableData, keys); - } - if (this.selectedCommentPosition) { this.commentLineStart = this.selectedCommentPosition.start; } @@ -196,9 +206,6 @@ export default { lineCode: this.line.line_code, fileHash: this.diffFileHash, }); - this.$nextTick(() => { - this.resetAutoSave(); - }); }), handleSaveNote(note) { return this.saveDiffDiscussion({ note, formData: this.formData }).then(() => @@ -232,6 +239,7 @@ export default { :diff-file="diffFile" :show-suggest-popover="showSuggestPopover" :save-button-title="__('Comment')" + :autosave-key="autosaveKey" class="diff-comment-form gl-mt-3" @handleFormUpdateAddToReview="addToReview" @cancelForm="handleCancelCommentForm" diff --git a/app/assets/javascripts/notes/components/note_body.vue b/app/assets/javascripts/notes/components/note_body.vue index eef011db7d2926b5bf18e50d11cf676e91790e29..b4e5129ca0efc02422f8c23c312cb49e21a51578 100644 --- a/app/assets/javascripts/notes/components/note_body.vue +++ b/app/assets/javascripts/notes/components/note_body.vue @@ -5,7 +5,6 @@ import SafeHtml from '~/vue_shared/directives/safe_html'; import { __ } from '~/locale'; import Suggestions from '~/vue_shared/components/markdown/suggestions.vue'; import { renderGFM } from '~/behaviors/markdown/render_gfm'; -import autosave from '../mixins/autosave'; import NoteAttachment from './note_attachment.vue'; import NoteAwardsList from './note_awards_list.vue'; import NoteEditedText from './note_edited_text.vue'; @@ -22,7 +21,6 @@ export default { directives: { SafeHtml, }, - mixins: [autosave], props: { note: { type: Object, @@ -96,21 +94,9 @@ export default { }, mounted() { this.renderGFM(); - - if (this.isEditing) { - this.initAutoSave(this.note); - } }, updated() { this.renderGFM(); - - if (this.isEditing) { - if (!this.autosave) { - this.initAutoSave(this.note); - } else { - this.setAutoSave(); - } - } }, methods: { ...mapActions([ diff --git a/app/assets/javascripts/notes/components/note_form.vue b/app/assets/javascripts/notes/components/note_form.vue index b6ede10d02b7ae3bd350ce26ac54d884dcf5ebb8..bde645a4f4171f0fc1f505ec819b6ec077292b03 100644 --- a/app/assets/javascripts/notes/components/note_form.vue +++ b/app/assets/javascripts/notes/components/note_form.vue @@ -1,10 +1,10 @@