Commit 0d08ba3d authored by Fatih Acet's avatar Fatih Acet

IssueNotesRefactor: Fix error messages of edit/reply failure for discussions.

parent 704ec994
...@@ -96,6 +96,7 @@ ...@@ -96,6 +96,7 @@
methods: { methods: {
...mapActions([ ...mapActions([
'saveNote', 'saveNote',
'removePlaceholderNotes',
]), ]),
setIsSubmitButtonDisabled(note, isSubmitting) { setIsSubmitButtonDisabled(note, isSubmitting) {
if (!_.isEmpty(note) && !isSubmitting) { if (!_.isEmpty(note) && !isSubmitting) {
...@@ -147,6 +148,12 @@ ...@@ -147,6 +148,12 @@
.catch(() => { .catch(() => {
this.isSubmitting = false; this.isSubmitting = false;
this.discard(false); this.discard(false);
Flash(
'Your comment could not be submitted! Please check your network connection and try again.',
'alert',
$(this.$el),
);
this.removePlaceholderNotes();
}); });
} else { } else {
this.toggleIssueState(); this.toggleIssueState();
......
...@@ -78,6 +78,7 @@ ...@@ -78,6 +78,7 @@
...mapActions([ ...mapActions([
'saveNote', 'saveNote',
'toggleDiscussion', 'toggleDiscussion',
'removePlaceholderNotes',
]), ]),
componentName(note) { componentName(note) {
if (note.isPlaceholderNote) { if (note.isPlaceholderNote) {
...@@ -126,7 +127,15 @@ ...@@ -126,7 +127,15 @@
this.isReplying = false; this.isReplying = false;
this.resetAutoSave(); this.resetAutoSave();
}) })
.catch(() => Flash('Something went wrong while adding your reply. Please try again.')); .catch(() => {
Flash(
'Your comment could not be submitted! Please check your network connection and try again.',
'alert',
$(this.$el),
);
this.removePlaceholderNotes();
this.$refs.noteForm.isSubmitting = false;
});
}, },
}, },
mounted() { mounted() {
...@@ -191,7 +200,6 @@ ...@@ -191,7 +200,6 @@
:key="note.id" :key="note.id"
/> />
</ul> </ul>
<div class="flash-container"></div>
<div <div
:class="{ 'is-replying': isReplying }" :class="{ 'is-replying': isReplying }"
class="discussion-reply-holder"> class="discussion-reply-holder">
......
...@@ -57,6 +57,9 @@ export const createNewNote = ({ commit }, { endpoint, data }) => service ...@@ -57,6 +57,9 @@ export const createNewNote = ({ commit }, { endpoint, data }) => service
return res; return res;
}); });
export const removePlaceholderNotes = ({ commit }) =>
commit(types.REMOVE_PLACEHOLDER_NOTES);
export const saveNote = ({ commit, dispatch }, noteData) => { export const saveNote = ({ commit, dispatch }, noteData) => {
const { note } = noteData.data.note; const { note } = noteData.data.note;
let placeholderText = note; let placeholderText = note;
...@@ -127,14 +130,6 @@ export const saveNote = ({ commit, dispatch }, noteData) => { ...@@ -127,14 +130,6 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
commit(types.REMOVE_PLACEHOLDER_NOTES); commit(types.REMOVE_PLACEHOLDER_NOTES);
return res; return res;
})
.catch(() => {
Flash(
'Your comment could not be submitted! Please check your network connection and try again.',
'alert',
$(noteData.flashContainer),
);
commit(types.REMOVE_PLACEHOLDER_NOTES);
}); });
}; };
......
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