From 53e23a296d8cae21485698750b20244b2e075608 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Mon, 4 Mar 2019 22:00:18 +0100 Subject: Pass autosaveKey from NoteableDiscussion to NoteForm --- app/assets/javascripts/lib/utils/autosave.js | 5 +++++ app/assets/javascripts/notes/components/noteable_discussion.vue | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'app') diff --git a/app/assets/javascripts/lib/utils/autosave.js b/app/assets/javascripts/lib/utils/autosave.js index 551035024a9..023c336db02 100644 --- a/app/assets/javascripts/lib/utils/autosave.js +++ b/app/assets/javascripts/lib/utils/autosave.js @@ -1,3 +1,5 @@ +import { capitalizeFirstCharacter } from '~/lib/utils/text_utility'; + export const clearDraft = autosaveKey => { try { window.localStorage.removeItem(`autosave/${autosaveKey}`); @@ -25,3 +27,6 @@ export const updateDraft = (autosaveKey, text) => { console.error(e); } }; + +export const getDiscussionReplyKey = (noteableType, discussionId) => + ['Note', capitalizeFirstCharacter(noteableType), discussionId, 'Reply'].join('/'); diff --git a/app/assets/javascripts/notes/components/noteable_discussion.vue b/app/assets/javascripts/notes/components/noteable_discussion.vue index fd3cc859545..22103001e02 100644 --- a/app/assets/javascripts/notes/components/noteable_discussion.vue +++ b/app/assets/javascripts/notes/components/noteable_discussion.vue @@ -4,6 +4,7 @@ import { mapActions, mapGetters } from 'vuex'; import { GlTooltipDirective } from '@gitlab/ui'; import { truncateSha } from '~/lib/utils/text_utility'; import { s__, __, sprintf } from '~/locale'; +import { getDiscussionReplyKey } from '~/lib/utils/autosave'; import systemNote from '~/vue_shared/components/notes/system_note.vue'; import icon from '~/vue_shared/components/icon.vue'; import diffLineNoteFormMixin from 'ee_else_ce/notes/mixins/diff_line_note_form'; @@ -108,6 +109,9 @@ export default { author() { return this.firstNote.author; }, + autosaveKey() { + return getDiscussionReplyKey(this.firstNote.noteable_type, this.discussion.id); + }, canReply() { return this.getNoteableData.current_user.can_create_note; }, @@ -512,6 +516,7 @@ Please check your network connection and try again.`; :is-editing="false" :line="diffLine" save-button-title="Comment" + :autosave-key="autosaveKey" @handleFormUpdateAddToReview="addReplyToReview" @handleFormUpdate="saveReply" @cancelForm="cancelReplyForm" -- cgit v1.2.1