Commit 2a44a1bb authored by Winnie Hellmann's avatar Winnie Hellmann

Pass autosaveKey from NoteableDiscussion to NoteForm

(cherry picked from commit a862585cd81bf6f6045b6cbac4ef8f0d368b72c6)
parent 2b3b660d
import { capitalizeFirstCharacter } from '~/lib/utils/text_utility';
export const clearDraft = autosaveKey => { export const clearDraft = autosaveKey => {
try { try {
window.localStorage.removeItem(`autosave/${autosaveKey}`); window.localStorage.removeItem(`autosave/${autosaveKey}`);
...@@ -25,3 +27,6 @@ export const updateDraft = (autosaveKey, text) => { ...@@ -25,3 +27,6 @@ export const updateDraft = (autosaveKey, text) => {
console.error(e); console.error(e);
} }
}; };
export const getDiscussionReplyKey = (noteableType, discussionId) =>
['Note', capitalizeFirstCharacter(noteableType), discussionId, 'Reply'].join('/');
...@@ -4,6 +4,7 @@ import { mapActions, mapGetters } from 'vuex'; ...@@ -4,6 +4,7 @@ import { mapActions, mapGetters } from 'vuex';
import { GlTooltipDirective } from '@gitlab/ui'; import { GlTooltipDirective } from '@gitlab/ui';
import { truncateSha } from '~/lib/utils/text_utility'; import { truncateSha } from '~/lib/utils/text_utility';
import { s__, __, sprintf } from '~/locale'; import { s__, __, sprintf } from '~/locale';
import { getDiscussionReplyKey } from '~/lib/utils/autosave';
import systemNote from '~/vue_shared/components/notes/system_note.vue'; import systemNote from '~/vue_shared/components/notes/system_note.vue';
import icon from '~/vue_shared/components/icon.vue'; import icon from '~/vue_shared/components/icon.vue';
import diffLineNoteFormMixin from 'ee_else_ce/notes/mixins/diff_line_note_form'; import diffLineNoteFormMixin from 'ee_else_ce/notes/mixins/diff_line_note_form';
...@@ -108,6 +109,9 @@ export default { ...@@ -108,6 +109,9 @@ export default {
author() { author() {
return this.firstNote.author; return this.firstNote.author;
}, },
autosaveKey() {
return getDiscussionReplyKey(this.firstNote.noteable_type, this.discussion.id);
},
canReply() { canReply() {
return this.getNoteableData.current_user.can_create_note; return this.getNoteableData.current_user.can_create_note;
}, },
...@@ -517,6 +521,7 @@ Please check your network connection and try again.`; ...@@ -517,6 +521,7 @@ Please check your network connection and try again.`;
:is-editing="false" :is-editing="false"
:line="diffLine" :line="diffLine"
save-button-title="Comment" save-button-title="Comment"
:autosave-key="autosaveKey"
@handleFormUpdateAddToReview="addReplyToReview" @handleFormUpdateAddToReview="addReplyToReview"
@handleFormUpdate="saveReply" @handleFormUpdate="saveReply"
@cancelForm="cancelReplyForm" @cancelForm="cancelReplyForm"
......
---
title: Display draft when toggling replies
merge_request: 25563
author:
type: fixed
...@@ -84,6 +84,7 @@ describe('noteable_discussion component', () => { ...@@ -84,6 +84,7 @@ describe('noteable_discussion component', () => {
expect(noteFormProps.isEditing).toBe(false); expect(noteFormProps.isEditing).toBe(false);
expect(noteFormProps.line).toBe(null); expect(noteFormProps.line).toBe(null);
expect(noteFormProps.saveButtonTitle).toBe('Comment'); expect(noteFormProps.saveButtonTitle).toBe('Comment');
expect(noteFormProps.autosaveKey).toBe(`Note/Issue/${discussionMock.id}/Reply`);
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment