diff options
Diffstat (limited to 'app/assets/javascripts/notes/stores/actions.js')
| -rw-r--r-- | app/assets/javascripts/notes/stores/actions.js | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/app/assets/javascripts/notes/stores/actions.js b/app/assets/javascripts/notes/stores/actions.js index 086e9122c60..5cb7b7aa4e2 100644 --- a/app/assets/javascripts/notes/stores/actions.js +++ b/app/assets/javascripts/notes/stores/actions.js @@ -9,7 +9,7 @@ import { confidentialWidget } from '~/sidebar/components/confidential/sidebar_co import updateIssueLockMutation from '~/sidebar/components/lock/mutations/update_issue_lock.mutation.graphql'; import updateMergeRequestLockMutation from '~/sidebar/components/lock/mutations/update_merge_request_lock.mutation.graphql'; import loadAwardsHandler from '../../awards_handler'; -import { deprecatedCreateFlash as Flash } from '../../flash'; +import createFlash from '../../flash'; import { isInViewport, scrollToElement, isInMRPage } from '../../lib/utils/common_utils'; import Poll from '../../lib/utils/poll'; import { create } from '../../lib/utils/recurrence'; @@ -354,7 +354,11 @@ export const saveNote = ({ commit, dispatch }, noteData) => { $('.js-gfm-input').trigger('clear-commands-cache.atwho'); - Flash(message || __('Commands applied'), 'notice', noteData.flashContainer); + createFlash({ + message: message || __('Commands applied'), + type: 'notice', + parent: noteData.flashContainer, + }); } return res; @@ -375,11 +379,11 @@ export const saveNote = ({ commit, dispatch }, noteData) => { awardsHandler.scrollToAwards(); }) .catch(() => { - Flash( - __('Something went wrong while adding your award. Please try again.'), - 'alert', - noteData.flashContainer, - ); + createFlash({ + message: __('Something went wrong while adding your award. Please try again.'), + type: 'alert', + parent: noteData.flashContainer, + }); }) .then(() => res); }; @@ -417,7 +421,11 @@ export const saveNote = ({ commit, dispatch }, noteData) => { const errorMsg = sprintf(__('Your comment could not be submitted because %{error}'), { error: base[0].toLowerCase(), }); - Flash(errorMsg, 'alert', noteData.flashContainer); + createFlash({ + message: errorMsg, + type: 'alert', + parent: noteData.flashContainer, + }); return { ...data, hasFlash: true }; } } @@ -480,7 +488,9 @@ export const poll = ({ commit, state, getters, dispatch }) => { }); notePollOccurrenceTracking.handle(2, () => { // On the second failure in a row, show the alert and try one more time (hoping to succeed and clear the error) - flashContainer = Flash(__('Something went wrong while fetching latest comments.')); + flashContainer = createFlash({ + message: __('Something went wrong while fetching latest comments.'), + }); setTimeout(() => eTagPoll.restart(), NOTES_POLLING_INTERVAL); }); @@ -570,7 +580,9 @@ export const filterDiscussion = ({ dispatch }, { path, filter, persistFilter }) .catch(() => { dispatch('setLoadingState', false); dispatch('setNotesFetchedState', true); - Flash(__('Something went wrong while fetching comments. Please try again.')); + createFlash({ + message: __('Something went wrong while fetching comments. Please try again.'), + }); }); }; @@ -613,7 +625,11 @@ export const submitSuggestion = ( const flashMessage = errorMessage || defaultMessage; - Flash(__(flashMessage), 'alert', flashContainer); + createFlash({ + message: __(flashMessage), + type: 'alert', + parent: flashContainer, + }); }) .finally(() => { commit(types.SET_RESOLVING_DISCUSSION, false); @@ -646,7 +662,11 @@ export const submitSuggestionBatch = ({ commit, dispatch, state }, { flashContai const flashMessage = errorMessage || defaultMessage; - Flash(__(flashMessage), 'alert', flashContainer); + createFlash({ + message: __(flashMessage), + type: 'alert', + parent: flashContainer, + }); }) .finally(() => { commit(types.SET_APPLYING_BATCH_STATE, false); @@ -685,7 +705,9 @@ export const fetchDescriptionVersion = ({ dispatch }, { endpoint, startingVersio }) .catch((error) => { dispatch('receiveDescriptionVersionError', error); - Flash(__('Something went wrong while fetching description changes. Please try again.')); + createFlash({ + message: __('Something went wrong while fetching description changes. Please try again.'), + }); }); }; @@ -717,7 +739,9 @@ export const softDeleteDescriptionVersion = ( }) .catch((error) => { dispatch('receiveDeleteDescriptionVersionError', error); - Flash(__('Something went wrong while deleting description changes. Please try again.')); + createFlash({ + message: __('Something went wrong while deleting description changes. Please try again.'), + }); // Throw an error here because a component like SystemNote - // needs to know if the request failed to reset its internal state. |
