From bc753559860935687f5eb285c8def2a178a673d7 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Fri, 3 May 2019 23:13:03 +0200 Subject: Handle errors in successful notes reply --- app/assets/javascripts/notes/stores/actions.js | 17 +++++++++++++---- changelogs/unreleased/winh-notes-error-handling.yml | 5 +++++ locale/gitlab.pot | 3 +++ 3 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 changelogs/unreleased/winh-notes-error-handling.yml diff --git a/app/assets/javascripts/notes/stores/actions.js b/app/assets/javascripts/notes/stores/actions.js index bac124be34c..63658d49a05 100644 --- a/app/assets/javascripts/notes/stores/actions.js +++ b/app/assets/javascripts/notes/stores/actions.js @@ -268,11 +268,20 @@ export const saveNote = ({ commit, dispatch }, noteData) => { const { errors } = res; const commandsChanges = res.commands_changes; - if (hasQuickActions && errors && Object.keys(errors).length) { - eTagPoll.makeRequest(); + if (errors && Object.keys(errors).length) { + /* + The following reply means that quick actions have been successfully applied: - $('.js-gfm-input').trigger('clear-commands-cache.atwho'); - Flash(__('Commands applied'), 'notice', noteData.flashContainer); + {"commands_changes":{},"valid":false,"errors":{"commands_only":["Commands applied"]}} + */ + if (hasQuickActions) { + eTagPoll.makeRequest(); + + $('.js-gfm-input').trigger('clear-commands-cache.atwho'); + Flash(__('Commands applied'), 'notice', noteData.flashContainer); + } else { + throw new Error(__('Failed to save comment!')); + } } if (commandsChanges) { diff --git a/changelogs/unreleased/winh-notes-error-handling.yml b/changelogs/unreleased/winh-notes-error-handling.yml new file mode 100644 index 00000000000..6f23dd459d4 --- /dev/null +++ b/changelogs/unreleased/winh-notes-error-handling.yml @@ -0,0 +1,5 @@ +--- +title: Handle errors in successful notes reply +merge_request: 28082 +author: +type: fixed diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 2907430bd51..1a35b1b5491 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -4196,6 +4196,9 @@ msgstr "" msgid "Failed to remove user key." msgstr "" +msgid "Failed to save comment!" +msgstr "" + msgid "Failed to save merge conflicts resolutions. Please try again!" msgstr "" -- cgit v1.2.3