Commit 6e3a9f1f authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch 'ek-replace-deprecated-create-flash-app-js-files' into 'master'

Replace deprecatedCreateFlash function calls in app/*.js files [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!63123
parents 53b33a09 47b50399
import _ from 'lodash'; import _ from 'lodash';
import Api from '~/api'; import Api from '~/api';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import * as types from './mutation_types'; import * as types from './mutation_types';
...@@ -71,7 +71,9 @@ export const createContextCommits = ({ state }, { commits, forceReload = false } ...@@ -71,7 +71,9 @@ export const createContextCommits = ({ state }, { commits, forceReload = false }
}) })
.catch(() => { .catch(() => {
if (forceReload) { if (forceReload) {
createFlash(s__('ContextCommits|Failed to create context commits. Please try again.')); createFlash({
message: s__('ContextCommits|Failed to create context commits. Please try again.'),
});
} }
return false; return false;
...@@ -111,7 +113,9 @@ export const removeContextCommits = ({ state }, forceReload = false) => ...@@ -111,7 +113,9 @@ export const removeContextCommits = ({ state }, forceReload = false) =>
}) })
.catch(() => { .catch(() => {
if (forceReload) { if (forceReload) {
createFlash(s__('ContextCommits|Failed to delete context commits. Please try again.')); createFlash({
message: s__('ContextCommits|Failed to delete context commits. Please try again.'),
});
} }
return false; return false;
......
import Api from '~/api'; import Api from '~/api';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import * as types from './mutation_types'; import * as types from './mutation_types';
...@@ -21,5 +21,7 @@ export const receiveStatisticsSuccess = ({ commit }, statistics) => ...@@ -21,5 +21,7 @@ export const receiveStatisticsSuccess = ({ commit }, statistics) =>
export const receiveStatisticsError = ({ commit }, error) => { export const receiveStatisticsError = ({ commit }, error) => {
commit(types.RECEIVE_STATISTICS_ERROR, error); commit(types.RECEIVE_STATISTICS_ERROR, error);
createFlash(s__('AdminDashboard|Error loading the statistics. Please try again')); createFlash({
message: s__('AdminDashboard|Error loading the statistics. Please try again'),
});
}; };
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import $ from 'jquery'; import $ from 'jquery';
import initPopover from '~/blob/suggest_gitlab_ci_yml'; import initPopover from '~/blob/suggest_gitlab_ci_yml';
import initCodeQualityWalkthrough from '~/code_quality_walkthrough'; import initCodeQualityWalkthrough from '~/code_quality_walkthrough';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import { disableButtonIfEmptyField, setCookie } from '~/lib/utils/common_utils'; import { disableButtonIfEmptyField, setCookie } from '~/lib/utils/common_utils';
import Tracking from '~/tracking'; import Tracking from '~/tracking';
import BlobFileDropzone from '../blob/blob_file_dropzone'; import BlobFileDropzone from '../blob/blob_file_dropzone';
...@@ -84,7 +84,11 @@ export default () => { ...@@ -84,7 +84,11 @@ export default () => {
initPopovers(); initPopovers();
initCodeQualityWalkthroughStep(); initCodeQualityWalkthroughStep();
}) })
.catch((e) => createFlash(e)); .catch((e) =>
createFlash({
message: e,
}),
);
cancelLink.on('click', () => { cancelLink.on('click', () => {
window.onbeforeunload = null; window.onbeforeunload = null;
......
import $ from 'jquery'; import $ from 'jquery';
import EditorLite from '~/editor/editor_lite'; import EditorLite from '~/editor/editor_lite';
import { FileTemplateExtension } from '~/editor/extensions/editor_file_template_ext'; import { FileTemplateExtension } from '~/editor/extensions/editor_file_template_ext';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { addEditorMarkdownListeners } from '~/lib/utils/text_markdown'; import { addEditorMarkdownListeners } from '~/lib/utils/text_markdown';
import { insertFinalNewline } from '~/lib/utils/text_utility'; import { insertFinalNewline } from '~/lib/utils/text_utility';
...@@ -21,7 +21,11 @@ export default class EditBlob { ...@@ -21,7 +21,11 @@ export default class EditBlob {
this.editor.use(new MarkdownExtension()); this.editor.use(new MarkdownExtension());
addEditorMarkdownListeners(this.editor); addEditorMarkdownListeners(this.editor);
}) })
.catch((e) => createFlash(`${BLOB_EDITOR_ERROR}: ${e}`)); .catch((e) =>
createFlash({
message: `${BLOB_EDITOR_ERROR}: ${e}`,
}),
);
} }
this.initModePanesAndLinks(); this.initModePanesAndLinks();
...@@ -94,7 +98,11 @@ export default class EditBlob { ...@@ -94,7 +98,11 @@ export default class EditBlob {
currentPane.empty().append(data); currentPane.empty().append(data);
currentPane.renderGFM(); currentPane.renderGFM();
}) })
.catch(() => createFlash(BLOB_PREVIEW_ERROR)); .catch(() =>
createFlash({
message: BLOB_PREVIEW_ERROR,
}),
);
} }
this.$toggleButton.show(); this.$toggleButton.show();
......
import Vue from 'vue'; import Vue from 'vue';
import { deprecatedCreateFlash as createFlash } from '../flash'; import createFlash from '../flash';
import axios from '../lib/utils/axios_utils'; import axios from '../lib/utils/axios_utils';
import { __ } from '../locale'; import { __ } from '../locale';
import DivergenceGraph from './components/divergence_graph.vue'; import DivergenceGraph from './components/divergence_graph.vue';
...@@ -51,6 +51,8 @@ export default (endpoint, defaultBranch) => { ...@@ -51,6 +51,8 @@ export default (endpoint, defaultBranch) => {
}); });
}) })
.catch(() => .catch(() =>
createFlash(__('Error fetching diverging counts for branches. Please try again.')), createFlash({
message: __('Error fetching diverging counts for branches. Please try again.'),
}),
); );
}; };
import Api from '~/api'; import Api from '~/api';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { __ } from '~/locale'; import { __ } from '~/locale';
import * as types from './mutation_types'; import * as types from './mutation_types';
...@@ -48,7 +48,9 @@ export const addVariable = ({ state, dispatch }) => { ...@@ -48,7 +48,9 @@ export const addVariable = ({ state, dispatch }) => {
dispatch('fetchVariables'); dispatch('fetchVariables');
}) })
.catch((error) => { .catch((error) => {
createFlash(error.response.data[0]); createFlash({
message: error.response.data[0],
});
dispatch('receiveAddVariableError', error); dispatch('receiveAddVariableError', error);
}); });
}; };
...@@ -78,7 +80,9 @@ export const updateVariable = ({ state, dispatch }) => { ...@@ -78,7 +80,9 @@ export const updateVariable = ({ state, dispatch }) => {
dispatch('fetchVariables'); dispatch('fetchVariables');
}) })
.catch((error) => { .catch((error) => {
createFlash(error.response.data[0]); createFlash({
message: error.response.data[0],
});
dispatch('receiveUpdateVariableError', error); dispatch('receiveUpdateVariableError', error);
}); });
}; };
...@@ -105,7 +109,9 @@ export const fetchVariables = ({ dispatch, state }) => { ...@@ -105,7 +109,9 @@ export const fetchVariables = ({ dispatch, state }) => {
dispatch('receiveVariablesSuccess', prepareDataForDisplay(data.variables)); dispatch('receiveVariablesSuccess', prepareDataForDisplay(data.variables));
}) })
.catch(() => { .catch(() => {
createFlash(__('There was an error fetching the variables.')); createFlash({
message: __('There was an error fetching the variables.'),
});
}); });
}; };
...@@ -133,7 +139,9 @@ export const deleteVariable = ({ dispatch, state }) => { ...@@ -133,7 +139,9 @@ export const deleteVariable = ({ dispatch, state }) => {
dispatch('fetchVariables'); dispatch('fetchVariables');
}) })
.catch((error) => { .catch((error) => {
createFlash(error.response.data[0]); createFlash({
message: error.response.data[0],
});
dispatch('receiveDeleteVariableError', error); dispatch('receiveDeleteVariableError', error);
}); });
}; };
...@@ -154,7 +162,9 @@ export const fetchEnvironments = ({ dispatch, state }) => { ...@@ -154,7 +162,9 @@ export const fetchEnvironments = ({ dispatch, state }) => {
dispatch('receiveEnvironmentsSuccess', prepareEnvironments(res.data)); dispatch('receiveEnvironmentsSuccess', prepareEnvironments(res.data));
}) })
.catch(() => { .catch(() => {
createFlash(__('There was an error fetching the environments information.')); createFlash({
message: __('There was an error fetching the environments information.'),
});
}); });
}; };
......
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import { DEFAULT_REGION } from '../constants'; import { DEFAULT_REGION } from '../constants';
...@@ -102,7 +102,9 @@ export const createClusterSuccess = (_, location) => { ...@@ -102,7 +102,9 @@ export const createClusterSuccess = (_, location) => {
export const createClusterError = ({ commit }, error) => { export const createClusterError = ({ commit }, error) => {
commit(types.CREATE_CLUSTER_ERROR, error); commit(types.CREATE_CLUSTER_ERROR, error);
createFlash(getErrorMessage(error)); createFlash({
message: getErrorMessage(error),
});
}; };
export const setRegion = ({ commit }, payload) => { export const setRegion = ({ commit }, payload) => {
......
import Api from '~/api'; import Api from '~/api';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import * as types from './mutation_types'; import * as types from './mutation_types';
...@@ -26,7 +26,9 @@ const receiveFreezePeriod = (store, request) => { ...@@ -26,7 +26,9 @@ const receiveFreezePeriod = (store, request) => {
dispatch('fetchFreezePeriods'); dispatch('fetchFreezePeriods');
}) })
.catch((error) => { .catch((error) => {
createFlash(__('Error: Unable to create deploy freeze')); createFlash({
message: __('Error: Unable to create deploy freeze'),
});
dispatch('receiveFreezePeriodError', error); dispatch('receiveFreezePeriodError', error);
}); });
}; };
...@@ -58,7 +60,9 @@ export const fetchFreezePeriods = ({ commit, state }) => { ...@@ -58,7 +60,9 @@ export const fetchFreezePeriods = ({ commit, state }) => {
commit(types.RECEIVE_FREEZE_PERIODS_SUCCESS, data); commit(types.RECEIVE_FREEZE_PERIODS_SUCCESS, data);
}) })
.catch(() => { .catch(() => {
createFlash(__('There was an error fetching the deploy freezes.')); createFlash({
message: __('There was an error fetching the deploy freezes.'),
});
}); });
}; };
......
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import Vue from 'vue'; import Vue from 'vue';
import api from '~/api'; import api from '~/api';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import { diffViewerModes } from '~/ide/constants'; import { diffViewerModes } from '~/ide/constants';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { handleLocationHash, historyPushState, scrollToElement } from '~/lib/utils/common_utils'; import { handleLocationHash, historyPushState, scrollToElement } from '~/lib/utils/common_utils';
...@@ -240,7 +240,10 @@ export const fetchCoverageFiles = ({ commit, state }) => { ...@@ -240,7 +240,10 @@ export const fetchCoverageFiles = ({ commit, state }) => {
coveragePoll.stop(); coveragePoll.stop();
} }
}, },
errorCallback: () => createFlash(__('Something went wrong on our end. Please try again!')), errorCallback: () =>
createFlash({
message: __('Something went wrong on our end. Please try again!'),
}),
}); });
coveragePoll.makeRequest(); coveragePoll.makeRequest();
...@@ -504,7 +507,11 @@ export const saveDiffDiscussion = ({ state, dispatch }, { note, formData }) => { ...@@ -504,7 +507,11 @@ export const saveDiffDiscussion = ({ state, dispatch }, { note, formData }) => {
.then((discussion) => dispatch('assignDiscussionsToDiff', [discussion])) .then((discussion) => dispatch('assignDiscussionsToDiff', [discussion]))
.then(() => dispatch('updateResolvableDiscussionsCounts', null, { root: true })) .then(() => dispatch('updateResolvableDiscussionsCounts', null, { root: true }))
.then(() => dispatch('closeDiffFileCommentForm', formData.diffFile.file_hash)) .then(() => dispatch('closeDiffFileCommentForm', formData.diffFile.file_hash))
.catch(() => createFlash(s__('MergeRequests|Saving the comment failed'))); .catch(() =>
createFlash({
message: s__('MergeRequests|Saving the comment failed'),
}),
);
}; };
export const toggleTreeOpen = ({ commit }, path) => { export const toggleTreeOpen = ({ commit }, path) => {
...@@ -595,7 +602,9 @@ export const cacheTreeListWidth = (_, size) => { ...@@ -595,7 +602,9 @@ export const cacheTreeListWidth = (_, size) => {
export const receiveFullDiffError = ({ commit }, filePath) => { export const receiveFullDiffError = ({ commit }, filePath) => {
commit(types.RECEIVE_FULL_DIFF_ERROR, filePath); commit(types.RECEIVE_FULL_DIFF_ERROR, filePath);
createFlash(s__('MergeRequest|Error loading full diff. Please try again.')); createFlash({
message: s__('MergeRequest|Error loading full diff. Please try again.'),
});
}; };
export const setExpandedDiffLines = ({ commit }, { file, data }) => { export const setExpandedDiffLines = ({ commit }, { file, data }) => {
...@@ -727,7 +736,9 @@ export const setSuggestPopoverDismissed = ({ commit, state }) => ...@@ -727,7 +736,9 @@ export const setSuggestPopoverDismissed = ({ commit, state }) =>
commit(types.SET_SHOW_SUGGEST_POPOVER); commit(types.SET_SHOW_SUGGEST_POPOVER);
}) })
.catch(() => { .catch(() => {
createFlash(s__('MergeRequest|Error dismissing suggestion popover. Please try again.')); createFlash({
message: s__('MergeRequest|Error dismissing suggestion popover. Please try again.'),
});
}); });
export function changeCurrentCommit({ dispatch, commit, state }, { commitId }) { export function changeCurrentCommit({ dispatch, commit, state }, { commitId }) {
......
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
import { __ } from '~/locale'; import { __ } from '~/locale';
import service from '../services'; import service from '../services';
...@@ -17,7 +17,11 @@ export const updateStatus = ({ commit }, { endpoint, redirectUrl, status }) => ...@@ -17,7 +17,11 @@ export const updateStatus = ({ commit }, { endpoint, redirectUrl, status }) =>
return resp.data.result; return resp.data.result;
}) })
.catch(() => createFlash(__('Failed to update issue status'))); .catch(() =>
createFlash({
message: __('Failed to update issue status'),
}),
);
export const updateResolveStatus = ({ commit, dispatch }, params) => { export const updateResolveStatus = ({ commit, dispatch }, params) => {
commit(types.SET_UPDATING_RESOLVE_STATUS, true); commit(types.SET_UPDATING_RESOLVE_STATUS, true);
......
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import Poll from '~/lib/utils/poll'; import Poll from '~/lib/utils/poll';
import { __ } from '~/locale'; import { __ } from '~/locale';
import service from '../../services'; import service from '../../services';
...@@ -26,7 +26,9 @@ export function startPollingStacktrace({ commit }, endpoint) { ...@@ -26,7 +26,9 @@ export function startPollingStacktrace({ commit }, endpoint) {
}, },
errorCallback: () => { errorCallback: () => {
commit(types.SET_LOADING_STACKTRACE, false); commit(types.SET_LOADING_STACKTRACE, false);
createFlash(__('Failed to load stacktrace.')); createFlash({
message: __('Failed to load stacktrace.'),
});
}, },
}); });
......
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import Poll from '~/lib/utils/poll'; import Poll from '~/lib/utils/poll';
import { __ } from '~/locale'; import { __ } from '~/locale';
import Service from '../../services'; import Service from '../../services';
...@@ -33,7 +33,9 @@ export function startPolling({ state, commit, dispatch }) { ...@@ -33,7 +33,9 @@ export function startPolling({ state, commit, dispatch }) {
}, },
errorCallback: () => { errorCallback: () => {
commit(types.SET_LOADING, false); commit(types.SET_LOADING, false);
createFlash(__('Failed to load errors from Sentry.')); createFlash({
message: __('Failed to load errors from Sentry.'),
});
}, },
}); });
......
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { refreshCurrentPage } from '~/lib/utils/url_utility'; import { refreshCurrentPage } from '~/lib/utils/url_utility';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -46,7 +46,10 @@ export const requestSettings = ({ commit }) => { ...@@ -46,7 +46,10 @@ export const requestSettings = ({ commit }) => {
export const receiveSettingsError = ({ commit }, { response = {} }) => { export const receiveSettingsError = ({ commit }, { response = {} }) => {
const message = response.data && response.data.message ? response.data.message : ''; const message = response.data && response.data.message ? response.data.message : '';
createFlash(`${__('There was an error saving your changes.')} ${message}`, 'alert'); createFlash({
message: `${__('There was an error saving your changes.')} ${message}`,
type: 'alert',
});
commit(types.UPDATE_SETTINGS_LOADING, false); commit(types.UPDATE_SETTINGS_LOADING, false);
}; };
......
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -55,7 +55,9 @@ export const receiveFeatureFlagSuccess = ({ commit }, response) => ...@@ -55,7 +55,9 @@ export const receiveFeatureFlagSuccess = ({ commit }, response) =>
commit(types.RECEIVE_FEATURE_FLAG_SUCCESS, response); commit(types.RECEIVE_FEATURE_FLAG_SUCCESS, response);
export const receiveFeatureFlagError = ({ commit }) => { export const receiveFeatureFlagError = ({ commit }) => {
commit(types.RECEIVE_FEATURE_FLAG_ERROR); commit(types.RECEIVE_FEATURE_FLAG_ERROR);
createFlash(__('Something went wrong on our end. Please try again!')); createFlash({
message: __('Something went wrong on our end. Please try again!'),
});
}; };
export const toggleActive = ({ commit }, active) => commit(types.TOGGLE_ACTIVE, active); export const toggleActive = ({ commit }, active) => commit(types.TOGGLE_ACTIVE, active);
import { __ } from '~/locale'; import { __ } from '~/locale';
import AjaxFilter from '../droplab/plugins/ajax_filter'; import AjaxFilter from '../droplab/plugins/ajax_filter';
import { deprecatedCreateFlash as createFlash } from '../flash'; import createFlash from '../flash';
import DropdownUtils from './dropdown_utils'; import DropdownUtils from './dropdown_utils';
import FilteredSearchDropdown from './filtered_search_dropdown'; import FilteredSearchDropdown from './filtered_search_dropdown';
import FilteredSearchTokenizer from './filtered_search_tokenizer'; import FilteredSearchTokenizer from './filtered_search_tokenizer';
...@@ -27,7 +27,9 @@ export default class DropdownAjaxFilter extends FilteredSearchDropdown { ...@@ -27,7 +27,9 @@ export default class DropdownAjaxFilter extends FilteredSearchDropdown {
searchValueFunction: this.getSearchInput.bind(this), searchValueFunction: this.getSearchInput.bind(this),
loadingTemplate: this.loadingTemplate, loadingTemplate: this.loadingTemplate,
onError() { onError() {
createFlash(__('An error occurred fetching the dropdown data.')); createFlash({
message: __('An error occurred fetching the dropdown data.'),
});
}, },
}; };
} }
......
import $ from 'jquery'; import $ from 'jquery';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { parseQueryStringIntoObject } from '~/lib/utils/common_utils'; import { parseQueryStringIntoObject } from '~/lib/utils/common_utils';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -16,7 +16,10 @@ export default class GpgBadges { ...@@ -16,7 +16,10 @@ export default class GpgBadges {
badges.html('<span class="gl-spinner gl-spinner-orange gl-spinner-sm"></span>'); badges.html('<span class="gl-spinner gl-spinner-orange gl-spinner-sm"></span>');
badges.children().attr('aria-label', __('Loading')); badges.children().attr('aria-label', __('Loading'));
const displayError = () => createFlash(__('An error occurred while loading commit signatures')); const displayError = () =>
createFlash({
message: __('An error occurred while loading commit signatures'),
});
const endpoint = tag.data('signaturesPath'); const endpoint = tag.data('signaturesPath');
if (!endpoint) { if (!endpoint) {
......
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { refreshCurrentPage } from '~/lib/utils/url_utility'; import { refreshCurrentPage } from '~/lib/utils/url_utility';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -38,5 +38,8 @@ export const receiveGrafanaIntegrationUpdateError = (_, error) => { ...@@ -38,5 +38,8 @@ export const receiveGrafanaIntegrationUpdateError = (_, error) => {
const { response } = error; const { response } = error;
const message = response.data && response.data.message ? response.data.message : ''; const message = response.data && response.data.message ? response.data.message : '';
createFlash(`${__('There was an error saving your changes.')} ${message}`, 'alert'); createFlash({
message: `${__('There was an error saving your changes.')} ${message}`,
type: 'alert',
});
}; };
<script> <script>
import { GlModal, GlButton } from '@gitlab/ui'; import { GlModal, GlButton } from '@gitlab/ui';
import { mapActions, mapState, mapGetters } from 'vuex'; import { mapActions, mapState, mapGetters } from 'vuex';
import { deprecatedCreateFlash as flash } from '~/flash'; import createFlash from '~/flash';
import { __, sprintf, s__ } from '~/locale'; import { __, sprintf, s__ } from '~/locale';
import { modalTypes } from '../../constants'; import { modalTypes } from '../../constants';
import { trimPathComponents, getPathParent } from '../../utils'; import { trimPathComponents, getPathParent } from '../../utils';
...@@ -57,16 +57,16 @@ export default { ...@@ -57,16 +57,16 @@ export default {
if (this.modalType === modalTypes.rename) { if (this.modalType === modalTypes.rename) {
if (this.entries[this.entryName] && !this.entries[this.entryName].deleted) { if (this.entries[this.entryName] && !this.entries[this.entryName].deleted) {
flash( createFlash({
sprintf(s__('The name "%{name}" is already taken in this directory.'), { message: sprintf(s__('The name "%{name}" is already taken in this directory.'), {
name: this.entryName, name: this.entryName,
}), }),
'alert', type: 'alert',
document, parent: document,
null, actionConfig: null,
false, fadeTransition: false,
true, addBodyClass: true,
); });
} else { } else {
let parentPath = this.entryName.split('/'); let parentPath = this.entryName.split('/');
const name = parentPath.pop(); const name = parentPath.pop();
......
import { deprecatedCreateFlash as flash } from '~/flash'; import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { leftSidebarViews, PERMISSION_READ_MR, MAX_MR_FILES_AUTO_OPEN } from '../../constants'; import { leftSidebarViews, PERMISSION_READ_MR, MAX_MR_FILES_AUTO_OPEN } from '../../constants';
import service from '../../services'; import service from '../../services';
...@@ -34,14 +34,14 @@ export const getMergeRequestsForBranch = ( ...@@ -34,14 +34,14 @@ export const getMergeRequestsForBranch = (
} }
}) })
.catch((e) => { .catch((e) => {
flash( createFlash({
__(`Error fetching merge requests for ${branchId}`), message: __(`Error fetching merge requests for ${branchId}`),
'alert', type: 'alert',
document, parent: document,
null, actionConfig: null,
false, fadeTransition: false,
true, addBodyClass: true,
); });
throw e; throw e;
}); });
}; };
...@@ -236,7 +236,7 @@ export const openMergeRequest = async ( ...@@ -236,7 +236,7 @@ export const openMergeRequest = async (
await dispatch('openMergeRequestChanges', changes); await dispatch('openMergeRequestChanges', changes);
} catch (e) { } catch (e) {
flash(__('Error while loading the merge request. Please try again.')); createFlash({ message: __('Error while loading the merge request. Please try again.') });
throw e; throw e;
} }
}; };
import { deprecatedCreateFlash as flash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import httpStatus from '~/lib/utils/http_status'; import httpStatus from '~/lib/utils/http_status';
import * as terminalService from '../../../../services/terminals'; import * as terminalService from '../../../../services/terminals';
...@@ -26,7 +26,7 @@ export const receiveStartSessionSuccess = ({ commit, dispatch }, data) => { ...@@ -26,7 +26,7 @@ export const receiveStartSessionSuccess = ({ commit, dispatch }, data) => {
}; };
export const receiveStartSessionError = ({ dispatch }) => { export const receiveStartSessionError = ({ dispatch }) => {
flash(messages.UNEXPECTED_ERROR_STARTING); createFlash({ message: messages.UNEXPECTED_ERROR_STARTING });
dispatch('killSession'); dispatch('killSession');
}; };
...@@ -59,7 +59,7 @@ export const receiveStopSessionSuccess = ({ dispatch }) => { ...@@ -59,7 +59,7 @@ export const receiveStopSessionSuccess = ({ dispatch }) => {
}; };
export const receiveStopSessionError = ({ dispatch }) => { export const receiveStopSessionError = ({ dispatch }) => {
flash(messages.UNEXPECTED_ERROR_STOPPING); createFlash({ message: messages.UNEXPECTED_ERROR_STOPPING });
dispatch('killSession'); dispatch('killSession');
}; };
......
import { deprecatedCreateFlash as flash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import * as messages from '../messages'; import * as messages from '../messages';
import * as types from '../mutation_types'; import * as types from '../mutation_types';
...@@ -42,7 +42,7 @@ export const receiveSessionStatusSuccess = ({ commit, dispatch }, data) => { ...@@ -42,7 +42,7 @@ export const receiveSessionStatusSuccess = ({ commit, dispatch }, data) => {
}; };
export const receiveSessionStatusError = ({ dispatch }) => { export const receiveSessionStatusError = ({ dispatch }) => {
flash(messages.UNEXPECTED_ERROR_STATUS); createFlash({ message: messages.UNEXPECTED_ERROR_STATUS });
dispatch('killSession'); dispatch('killSession');
}; };
......
import Visibility from 'visibilityjs'; import Visibility from 'visibilityjs';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import httpStatusCodes from '~/lib/utils/http_status'; import httpStatusCodes from '~/lib/utils/http_status';
...@@ -75,19 +75,19 @@ const fetchReposFactory = ({ reposPath = isRequired() }) => ({ state, commit }) ...@@ -75,19 +75,19 @@ const fetchReposFactory = ({ reposPath = isRequired() }) => ({ state, commit })
if (hasRedirectInError(e)) { if (hasRedirectInError(e)) {
redirectToUrlInError(e); redirectToUrlInError(e);
} else if (tooManyRequests(e)) { } else if (tooManyRequests(e)) {
createFlash( createFlash({
sprintf(s__('ImportProjects|%{provider} rate limit exceeded. Try again later'), { message: sprintf(s__('ImportProjects|%{provider} rate limit exceeded. Try again later'), {
provider: capitalizeFirstCharacter(provider), provider: capitalizeFirstCharacter(provider),
}), }),
); });
commit(types.RECEIVE_REPOS_ERROR); commit(types.RECEIVE_REPOS_ERROR);
} else { } else {
createFlash( createFlash({
sprintf(s__('ImportProjects|Requesting your %{provider} repositories failed'), { message: sprintf(s__('ImportProjects|Requesting your %{provider} repositories failed'), {
provider, provider,
}), }),
); });
commit(types.RECEIVE_REPOS_ERROR); commit(types.RECEIVE_REPOS_ERROR);
} }
...@@ -126,7 +126,9 @@ const fetchImportFactory = (importPath = isRequired()) => ({ state, commit, gett ...@@ -126,7 +126,9 @@ const fetchImportFactory = (importPath = isRequired()) => ({ state, commit, gett
) )
: s__('ImportProjects|Importing the project failed'); : s__('ImportProjects|Importing the project failed');
createFlash(flashMessage); createFlash({
message: flashMessage,
});
commit(types.RECEIVE_IMPORT_ERROR, repoId); commit(types.RECEIVE_IMPORT_ERROR, repoId);
}); });
...@@ -149,7 +151,9 @@ export const fetchJobsFactory = (jobsPath = isRequired()) => ({ state, commit, d ...@@ -149,7 +151,9 @@ export const fetchJobsFactory = (jobsPath = isRequired()) => ({ state, commit, d
if (hasRedirectInError(e)) { if (hasRedirectInError(e)) {
redirectToUrlInError(e); redirectToUrlInError(e);
} else { } else {
createFlash(s__('ImportProjects|Update of imported projects with realtime changes failed')); createFlash({
message: s__('ImportProjects|Update of imported projects with realtime changes failed'),
});
} }
}, },
}); });
...@@ -175,7 +179,9 @@ const fetchNamespacesFactory = (namespacesPath = isRequired()) => ({ commit }) = ...@@ -175,7 +179,9 @@ const fetchNamespacesFactory = (namespacesPath = isRequired()) => ({ commit }) =
commit(types.RECEIVE_NAMESPACES_SUCCESS, convertObjectPropsToCamelCase(data, { deep: true })), commit(types.RECEIVE_NAMESPACES_SUCCESS, convertObjectPropsToCamelCase(data, { deep: true })),
) )
.catch(() => { .catch(() => {
createFlash(s__('ImportProjects|Requesting namespaces failed')); createFlash({
message: s__('ImportProjects|Requesting namespaces failed'),
});
commit(types.RECEIVE_NAMESPACES_ERROR); commit(types.RECEIVE_NAMESPACES_ERROR);
}); });
......
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { refreshCurrentPage } from '~/lib/utils/url_utility'; import { refreshCurrentPage } from '~/lib/utils/url_utility';
import { ERROR_MSG } from './constants'; import { ERROR_MSG } from './constants';
...@@ -22,7 +22,10 @@ export default class IncidentsSettingsService { ...@@ -22,7 +22,10 @@ export default class IncidentsSettingsService {
.catch(({ response }) => { .catch(({ response }) => {
const message = response?.data?.message || ''; const message = response?.data?.message || '';
createFlash(`${ERROR_MSG} ${message}`, 'alert'); createFlash({
message: `${ERROR_MSG} ${message}`,
type: 'alert',
});
}); });
} }
......
...@@ -3,7 +3,7 @@ import { ...@@ -3,7 +3,7 @@ import {
getBoardSortableDefaultOptions, getBoardSortableDefaultOptions,
sortableStart, sortableStart,
} from '~/boards/mixins/sortable_default_options'; } from '~/boards/mixins/sortable_default_options';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
...@@ -15,7 +15,9 @@ const updateIssue = (url, issueList, { move_before_id, move_after_id }) => ...@@ -15,7 +15,9 @@ const updateIssue = (url, issueList, { move_before_id, move_after_id }) =>
group_full_path: issueList.dataset.groupFullPath, group_full_path: issueList.dataset.groupFullPath,
}) })
.catch(() => { .catch(() => {
createFlash(s__("ManualOrdering|Couldn't save the order of the issues")); createFlash({
message: s__("ManualOrdering|Couldn't save the order of the issues"),
});
}); });
const initManualOrdering = (draggableSelector = 'li.issue') => { const initManualOrdering = (draggableSelector = 'li.issue') => {
......
/* eslint-disable func-names, no-underscore-dangle, consistent-return */ /* eslint-disable func-names, no-underscore-dangle, consistent-return */
import $ from 'jquery'; import $ from 'jquery';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import eventHub from '~/vue_merge_request_widget/event_hub'; import eventHub from '~/vue_merge_request_widget/event_hub';
import axios from './lib/utils/axios_utils'; import axios from './lib/utils/axios_utils';
...@@ -36,11 +36,11 @@ function MergeRequest(opts) { ...@@ -36,11 +36,11 @@ function MergeRequest(opts) {
document.querySelector('#task_status_short').innerText = result.task_status_short; document.querySelector('#task_status_short').innerText = result.task_status_short;
}, },
onError: () => { onError: () => {
createFlash( createFlash({
__( message: __(
'Someone edited this merge request at the same time you did. Please refresh the page to see changes.', 'Someone edited this merge request at the same time you did. Please refresh the page to see changes.',
), ),
); });
}, },
}); });
} }
...@@ -93,7 +93,9 @@ MergeRequest.prototype.initMRBtnListeners = function () { ...@@ -93,7 +93,9 @@ MergeRequest.prototype.initMRBtnListeners = function () {
}) })
.catch(() => { .catch(() => {
draftToggle.removeAttribute('disabled'); draftToggle.removeAttribute('disabled');
createFlash(__('Something went wrong. Please try again.')); createFlash({
message: __('Something went wrong. Please try again.'),
});
}); });
}); });
}); });
...@@ -169,7 +171,10 @@ MergeRequest.hideCloseButton = function () { ...@@ -169,7 +171,10 @@ MergeRequest.hideCloseButton = function () {
MergeRequest.toggleDraftStatus = function (title, isReady) { MergeRequest.toggleDraftStatus = function (title, isReady) {
if (isReady) { if (isReady) {
createFlash(__('The merge request can now be merged.'), 'notice'); createFlash({
message: __('The merge request can now be merged.'),
type: 'notice',
});
} }
const titleEl = document.querySelector('.merge-request .detail-page-description .title'); const titleEl = document.querySelector('.merge-request .detail-page-description .title');
......
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { convertToFixedRange } from '~/lib/utils/datetime_range'; import { convertToFixedRange } from '~/lib/utils/datetime_range';
import { convertObjectPropsToCamelCase } from '../../lib/utils/common_utils'; import { convertObjectPropsToCamelCase } from '../../lib/utils/common_utils';
...@@ -134,15 +134,17 @@ export const fetchDashboard = ({ state, commit, dispatch, getters }) => { ...@@ -134,15 +134,17 @@ export const fetchDashboard = ({ state, commit, dispatch, getters }) => {
if (state.showErrorBanner) { if (state.showErrorBanner) {
if (error.response.data && error.response.data.message) { if (error.response.data && error.response.data.message) {
const { message } = error.response.data; const { message } = error.response.data;
createFlash( createFlash({
sprintf( message: sprintf(
s__('Metrics|There was an error while retrieving metrics. %{message}'), s__('Metrics|There was an error while retrieving metrics. %{message}'),
{ message }, { message },
false, false,
), ),
); });
} else { } else {
createFlash(s__('Metrics|There was an error while retrieving metrics')); createFlash({
message: s__('Metrics|There was an error while retrieving metrics'),
});
} }
} }
}); });
...@@ -174,7 +176,10 @@ export const fetchDashboardData = ({ state, dispatch, getters }) => { ...@@ -174,7 +176,10 @@ export const fetchDashboardData = ({ state, dispatch, getters }) => {
dispatch('fetchDeploymentsData'); dispatch('fetchDeploymentsData');
if (!state.timeRange) { if (!state.timeRange) {
createFlash(s__(`Metrics|Invalid time range, please verify.`), 'warning'); createFlash({
message: s__(`Metrics|Invalid time range, please verify.`),
type: 'warning',
});
return Promise.reject(); return Promise.reject();
} }
...@@ -202,7 +207,10 @@ export const fetchDashboardData = ({ state, dispatch, getters }) => { ...@@ -202,7 +207,10 @@ export const fetchDashboardData = ({ state, dispatch, getters }) => {
}); });
}) })
.catch(() => { .catch(() => {
createFlash(s__(`Metrics|There was an error while retrieving metrics`), 'warning'); createFlash({
message: s__(`Metrics|There was an error while retrieving metrics`),
type: 'warning',
});
}); });
}; };
...@@ -254,7 +262,9 @@ export const fetchDeploymentsData = ({ state, dispatch }) => { ...@@ -254,7 +262,9 @@ export const fetchDeploymentsData = ({ state, dispatch }) => {
.then((resp) => resp.data) .then((resp) => resp.data)
.then((response) => { .then((response) => {
if (!response || !response.deployments) { if (!response || !response.deployments) {
createFlash(s__('Metrics|Unexpected deployment data response from prometheus endpoint')); createFlash({
message: s__('Metrics|Unexpected deployment data response from prometheus endpoint'),
});
} }
dispatch('receiveDeploymentsDataSuccess', response.deployments); dispatch('receiveDeploymentsDataSuccess', response.deployments);
...@@ -262,7 +272,9 @@ export const fetchDeploymentsData = ({ state, dispatch }) => { ...@@ -262,7 +272,9 @@ export const fetchDeploymentsData = ({ state, dispatch }) => {
.catch((error) => { .catch((error) => {
Sentry.captureException(error); Sentry.captureException(error);
dispatch('receiveDeploymentsDataFailure'); dispatch('receiveDeploymentsDataFailure');
createFlash(s__('Metrics|There was an error getting deployment information.')); createFlash({
message: s__('Metrics|There was an error getting deployment information.'),
});
}); });
}; };
export const receiveDeploymentsDataSuccess = ({ commit }, data) => { export const receiveDeploymentsDataSuccess = ({ commit }, data) => {
...@@ -290,9 +302,11 @@ export const fetchEnvironmentsData = ({ state, dispatch }) => { ...@@ -290,9 +302,11 @@ export const fetchEnvironmentsData = ({ state, dispatch }) => {
) )
.then((environments) => { .then((environments) => {
if (!environments) { if (!environments) {
createFlash( createFlash({
s__('Metrics|There was an error fetching the environments data, please try again'), message: s__(
); 'Metrics|There was an error fetching the environments data, please try again',
),
});
} }
dispatch('receiveEnvironmentsDataSuccess', environments); dispatch('receiveEnvironmentsDataSuccess', environments);
...@@ -300,7 +314,9 @@ export const fetchEnvironmentsData = ({ state, dispatch }) => { ...@@ -300,7 +314,9 @@ export const fetchEnvironmentsData = ({ state, dispatch }) => {
.catch((err) => { .catch((err) => {
Sentry.captureException(err); Sentry.captureException(err);
dispatch('receiveEnvironmentsDataFailure'); dispatch('receiveEnvironmentsDataFailure');
createFlash(s__('Metrics|There was an error getting environments information.')); createFlash({
message: s__('Metrics|There was an error getting environments information.'),
});
}); });
}; };
export const requestEnvironmentsData = ({ commit }) => { export const requestEnvironmentsData = ({ commit }) => {
...@@ -332,7 +348,9 @@ export const fetchAnnotations = ({ state, dispatch, getters }) => { ...@@ -332,7 +348,9 @@ export const fetchAnnotations = ({ state, dispatch, getters }) => {
.then(parseAnnotationsResponse) .then(parseAnnotationsResponse)
.then((annotations) => { .then((annotations) => {
if (!annotations) { if (!annotations) {
createFlash(s__('Metrics|There was an error fetching annotations. Please try again.')); createFlash({
message: s__('Metrics|There was an error fetching annotations. Please try again.'),
});
} }
dispatch('receiveAnnotationsSuccess', annotations); dispatch('receiveAnnotationsSuccess', annotations);
...@@ -340,7 +358,9 @@ export const fetchAnnotations = ({ state, dispatch, getters }) => { ...@@ -340,7 +358,9 @@ export const fetchAnnotations = ({ state, dispatch, getters }) => {
.catch((err) => { .catch((err) => {
Sentry.captureException(err); Sentry.captureException(err);
dispatch('receiveAnnotationsFailure'); dispatch('receiveAnnotationsFailure');
createFlash(s__('Metrics|There was an error getting annotations information.')); createFlash({
message: s__('Metrics|There was an error getting annotations information.'),
});
}); });
}; };
...@@ -377,9 +397,11 @@ export const fetchDashboardValidationWarnings = ({ state, dispatch, getters }) = ...@@ -377,9 +397,11 @@ export const fetchDashboardValidationWarnings = ({ state, dispatch, getters }) =
.catch((err) => { .catch((err) => {
Sentry.captureException(err); Sentry.captureException(err);
dispatch('receiveDashboardValidationWarningsFailure'); dispatch('receiveDashboardValidationWarningsFailure');
createFlash( createFlash({
s__('Metrics|There was an error getting dashboard validation warnings information.'), message: s__(
); 'Metrics|There was an error getting dashboard validation warnings information.',
),
});
}); });
}; };
...@@ -480,11 +502,14 @@ export const fetchVariableMetricLabelValues = ({ state, commit }, { defaultQuery ...@@ -480,11 +502,14 @@ export const fetchVariableMetricLabelValues = ({ state, commit }, { defaultQuery
commit(types.UPDATE_VARIABLE_METRIC_LABEL_VALUES, { variable, label, data }); commit(types.UPDATE_VARIABLE_METRIC_LABEL_VALUES, { variable, label, data });
}) })
.catch(() => { .catch(() => {
createFlash( createFlash({
sprintf(s__('Metrics|There was an error getting options for variable "%{name}".'), { message: sprintf(
name: variable.name, s__('Metrics|There was an error getting options for variable "%{name}".'),
}), {
); name: variable.name,
},
),
});
}); });
optionsRequests.push(optionsRequest); optionsRequests.push(optionsRequest);
} }
......
import { mapActions, mapGetters, mapState } from 'vuex'; import { mapActions, mapGetters, mapState } from 'vuex';
import { getDraftReplyFormData, getDraftFormData } from '~/batch_comments/utils'; import { getDraftReplyFormData, getDraftFormData } from '~/batch_comments/utils';
import { TEXT_DIFF_POSITION_TYPE, IMAGE_DIFF_POSITION_TYPE } from '~/diffs/constants'; import { TEXT_DIFF_POSITION_TYPE, IMAGE_DIFF_POSITION_TYPE } from '~/diffs/constants';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import { clearDraft } from '~/lib/utils/autosave'; import { clearDraft } from '~/lib/utils/autosave';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { formatLineRange } from '~/notes/components/multiline_comment_utils'; import { formatLineRange } from '~/notes/components/multiline_comment_utils';
...@@ -42,7 +42,9 @@ export default { ...@@ -42,7 +42,9 @@ export default {
this.handleClearForm(this.discussion.line_code); this.handleClearForm(this.discussion.line_code);
}) })
.catch(() => { .catch(() => {
createFlash(s__('MergeRequests|An error occurred while saving the draft comment.')); createFlash({
message: s__('MergeRequests|An error occurred while saving the draft comment.'),
});
}); });
}, },
addToReview(note) { addToReview(note) {
...@@ -80,7 +82,9 @@ export default { ...@@ -80,7 +82,9 @@ export default {
} }
}) })
.catch(() => { .catch(() => {
createFlash(s__('MergeRequests|An error occurred while saving the draft comment.')); createFlash({
message: s__('MergeRequests|An error occurred while saving the draft comment.'),
});
}); });
}, },
handleClearForm(lineCode) { handleClearForm(lineCode) {
......
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { refreshCurrentPage } from '~/lib/utils/url_utility'; import { refreshCurrentPage } from '~/lib/utils/url_utility';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -35,5 +35,8 @@ export const receiveSaveChangesError = (_, error) => { ...@@ -35,5 +35,8 @@ export const receiveSaveChangesError = (_, error) => {
const { response = {} } = error; const { response = {} } = error;
const message = response.data && response.data.message ? response.data.message : ''; const message = response.data && response.data.message ? response.data.message : '';
createFlash(`${__('There was an error saving your changes.')} ${message}`, 'alert'); createFlash({
message: `${__('There was an error saving your changes.')} ${message}`,
type: 'alert',
});
}; };
import Api from '~/api'; import Api from '~/api';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { DELETE_PACKAGE_ERROR_MESSAGE } from '~/packages/shared/constants'; import { DELETE_PACKAGE_ERROR_MESSAGE } from '~/packages/shared/constants';
import { import {
...@@ -43,7 +43,9 @@ export const requestPackagesList = ({ dispatch, state }, params = {}) => { ...@@ -43,7 +43,9 @@ export const requestPackagesList = ({ dispatch, state }, params = {}) => {
dispatch('receivePackagesListSuccess', { data, headers }); dispatch('receivePackagesListSuccess', { data, headers });
}) })
.catch(() => { .catch(() => {
createFlash(FETCH_PACKAGES_LIST_ERROR_MESSAGE); createFlash({
message: FETCH_PACKAGES_LIST_ERROR_MESSAGE,
});
}) })
.finally(() => { .finally(() => {
dispatch('setLoading', false); dispatch('setLoading', false);
...@@ -52,7 +54,9 @@ export const requestPackagesList = ({ dispatch, state }, params = {}) => { ...@@ -52,7 +54,9 @@ export const requestPackagesList = ({ dispatch, state }, params = {}) => {
export const requestDeletePackage = ({ dispatch, state }, { _links }) => { export const requestDeletePackage = ({ dispatch, state }, { _links }) => {
if (!_links || !_links.delete_api_path) { if (!_links || !_links.delete_api_path) {
createFlash(DELETE_PACKAGE_ERROR_MESSAGE); createFlash({
message: DELETE_PACKAGE_ERROR_MESSAGE,
});
const error = new Error(MISSING_DELETE_PATH_ERROR); const error = new Error(MISSING_DELETE_PATH_ERROR);
return Promise.reject(error); return Promise.reject(error);
} }
...@@ -65,10 +69,15 @@ export const requestDeletePackage = ({ dispatch, state }, { _links }) => { ...@@ -65,10 +69,15 @@ export const requestDeletePackage = ({ dispatch, state }, { _links }) => {
const page = getNewPaginationPage(currentPage, perPage, total - 1); const page = getNewPaginationPage(currentPage, perPage, total - 1);
dispatch('requestPackagesList', { page }); dispatch('requestPackagesList', { page });
createFlash(DELETE_PACKAGE_SUCCESS_MESSAGE, 'success'); createFlash({
message: DELETE_PACKAGE_SUCCESS_MESSAGE,
type: 'success',
});
}) })
.catch(() => { .catch(() => {
dispatch('setLoading', false); dispatch('setLoading', false);
createFlash(DELETE_PACKAGE_ERROR_MESSAGE); createFlash({
message: DELETE_PACKAGE_ERROR_MESSAGE,
});
}); });
}; };
...@@ -2,7 +2,7 @@ import emojiRegex from 'emoji-regex'; ...@@ -2,7 +2,7 @@ import emojiRegex from 'emoji-regex';
import $ from 'jquery'; import $ from 'jquery';
import GfmAutoComplete from 'ee_else_ce/gfm_auto_complete'; import GfmAutoComplete from 'ee_else_ce/gfm_auto_complete';
import * as Emoji from '~/emoji'; import * as Emoji from '~/emoji';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import EmojiMenu from './emoji_menu'; import EmojiMenu from './emoji_menu';
...@@ -81,4 +81,8 @@ Emoji.initEmojiMap() ...@@ -81,4 +81,8 @@ Emoji.initEmojiMap()
} }
}); });
}) })
.catch(() => createFlash(__('Failed to load emoji list.'))); .catch(() =>
createFlash({
message: __('Failed to load emoji list.'),
}),
);
import Visibility from 'visibilityjs'; import Visibility from 'visibilityjs';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import { historyPushState, buildUrlWithCurrentLocation } from '~/lib/utils/common_utils'; import { historyPushState, buildUrlWithCurrentLocation } from '~/lib/utils/common_utils';
import Poll from '~/lib/utils/poll'; import Poll from '~/lib/utils/poll';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -169,7 +169,11 @@ export default { ...@@ -169,7 +169,11 @@ export default {
this.service this.service
.postAction(endpoint) .postAction(endpoint)
.then(() => this.updateTable()) .then(() => this.updateTable())
.catch(() => createFlash(__('An error occurred while making the request.'))); .catch(() =>
createFlash({
message: __('An error occurred while making the request.'),
}),
);
}, },
/** /**
...@@ -189,9 +193,11 @@ export default { ...@@ -189,9 +193,11 @@ export default {
.runMRPipeline(options) .runMRPipeline(options)
.then(() => this.updateTable()) .then(() => this.updateTable())
.catch(() => { .catch(() => {
createFlash( createFlash({
__('An error occurred while trying to run a new pipeline for this merge request.'), message: __(
); 'An error occurred while trying to run a new pipeline for this merge request.',
),
});
}) })
.finally(() => this.store.toggleIsRunningPipeline(false)); .finally(() => this.store.toggleIsRunningPipeline(false));
}, },
......
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import * as types from './mutation_types'; import * as types from './mutation_types';
...@@ -12,7 +12,9 @@ export const fetchSummary = ({ state, commit, dispatch }) => { ...@@ -12,7 +12,9 @@ export const fetchSummary = ({ state, commit, dispatch }) => {
commit(types.SET_SUMMARY, data); commit(types.SET_SUMMARY, data);
}) })
.catch(() => { .catch(() => {
createFlash(s__('TestReports|There was an error fetching the summary.')); createFlash({
message: s__('TestReports|There was an error fetching the summary.'),
});
}) })
.finally(() => { .finally(() => {
dispatch('toggleLoading'); dispatch('toggleLoading');
...@@ -36,7 +38,9 @@ export const fetchTestSuite = ({ state, commit, dispatch }, index) => { ...@@ -36,7 +38,9 @@ export const fetchTestSuite = ({ state, commit, dispatch }, index) => {
.get(state.suiteEndpoint, { params: { build_ids } }) .get(state.suiteEndpoint, { params: { build_ids } })
.then(({ data }) => commit(types.SET_SUITE, { suite: data, index })) .then(({ data }) => commit(types.SET_SUITE, { suite: data, index }))
.catch(() => { .catch(() => {
createFlash(s__('TestReports|There was an error fetching the test suite.')); createFlash({
message: s__('TestReports|There was an error fetching the test suite.'),
});
}) })
.finally(() => { .finally(() => {
dispatch('toggleLoading'); dispatch('toggleLoading');
......
<script> <script>
import { GlSafeHtmlDirective as SafeHtml, GlButton, GlModal, GlModalDirective } from '@gitlab/ui'; import { GlSafeHtmlDirective as SafeHtml, GlButton, GlModal, GlModalDirective } from '@gitlab/ui';
import { escape } from 'lodash'; import { escape } from 'lodash';
import { deprecatedCreateFlash as Flash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { s__, sprintf } from '~/locale'; import { s__, sprintf } from '~/locale';
...@@ -85,15 +85,16 @@ Please update your Git repository remotes as soon as possible.`), ...@@ -85,15 +85,16 @@ Please update your Git repository remotes as soon as possible.`),
return axios return axios
.put(this.actionUrl, putData) .put(this.actionUrl, putData)
.then((result) => { .then((result) => {
Flash(result.data.message, 'notice'); createFlash({ message: result.data.message, type: 'notice' });
this.username = username; this.username = username;
this.isRequestPending = false; this.isRequestPending = false;
}) })
.catch((error) => { .catch((error) => {
Flash( createFlash({
error?.response?.data?.message || message:
error?.response?.data?.message ||
s__('Profiles|An error occurred while updating your username, please try again.'), s__('Profiles|An error occurred while updating your username, please try again.'),
); });
this.isRequestPending = false; this.isRequestPending = false;
throw error; throw error;
}); });
......
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { joinPaths } from '~/lib/utils/url_utility'; import { joinPaths } from '~/lib/utils/url_utility';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -13,7 +13,9 @@ export default { ...@@ -13,7 +13,9 @@ export default {
commit(types.COMMITS_AUTHORS, authors); commit(types.COMMITS_AUTHORS, authors);
}, },
receiveAuthorsError() { receiveAuthorsError() {
createFlash(__('An error occurred fetching the project authors.')); createFlash({
message: __('An error occurred fetching the project authors.'),
});
}, },
fetchAuthors({ dispatch, state }, author = null) { fetchAuthors({ dispatch, state }, author = null) {
const { projectId } = state; const { projectId } = state;
......
...@@ -23,7 +23,7 @@ Your caret can stop touching a `rawReference` can happen in a variety of ways: ...@@ -23,7 +23,7 @@ Your caret can stop touching a `rawReference` can happen in a variety of ways:
and hide the `AddIssuableForm` area. and hide the `AddIssuableForm` area.
*/ */
import { deprecatedCreateFlash as Flash } from '~/flash'; import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { import {
relatedIssuesRemoveErrorMap, relatedIssuesRemoveErrorMap,
...@@ -122,11 +122,11 @@ export default { ...@@ -122,11 +122,11 @@ export default {
}) })
.catch((res) => { .catch((res) => {
if (res && res.status !== 404) { if (res && res.status !== 404) {
Flash(relatedIssuesRemoveErrorMap[this.issuableType]); createFlash({ message: relatedIssuesRemoveErrorMap[this.issuableType] });
} }
}); });
} else { } else {
Flash(pathIndeterminateErrorMap[this.issuableType]); createFlash({ message: pathIndeterminateErrorMap[this.issuableType] });
} }
}, },
onToggleAddRelatedIssuesForm() { onToggleAddRelatedIssuesForm() {
...@@ -155,7 +155,7 @@ export default { ...@@ -155,7 +155,7 @@ export default {
if (response && response.data && response.data.message) { if (response && response.data && response.data.message) {
errorMessage = response.data.message; errorMessage = response.data.message;
} }
Flash(errorMessage); createFlash({ message: errorMessage });
}) })
.finally(() => { .finally(() => {
this.isSubmitting = false; this.isSubmitting = false;
...@@ -176,7 +176,7 @@ export default { ...@@ -176,7 +176,7 @@ export default {
}) })
.catch(() => { .catch(() => {
this.store.setRelatedIssues([]); this.store.setRelatedIssues([]);
Flash(__('An error occurred while fetching issues.')); createFlash({ message: __('An error occurred while fetching issues.') });
}) })
.finally(() => { .finally(() => {
this.isFetching = false; this.isFetching = false;
...@@ -197,7 +197,7 @@ export default { ...@@ -197,7 +197,7 @@ export default {
} }
}) })
.catch(() => { .catch(() => {
Flash(__('An error occurred while reordering issues.')); createFlash({ message: __('An error occurred while reordering issues.') });
}); });
} }
}, },
......
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { normalizeHeaders } from '~/lib/utils/common_utils'; import { normalizeHeaders } from '~/lib/utils/common_utils';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
...@@ -29,6 +29,8 @@ export const fetchMergeRequests = ({ state, dispatch }) => { ...@@ -29,6 +29,8 @@ export const fetchMergeRequests = ({ state, dispatch }) => {
}) })
.catch(() => { .catch(() => {
dispatch('receiveDataError'); dispatch('receiveDataError');
createFlash(s__('Something went wrong while fetching related merge requests.')); createFlash({
message: s__('Something went wrong while fetching related merge requests.'),
});
}); });
}; };
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import { redirectTo } from '~/lib/utils/url_utility'; import { redirectTo } from '~/lib/utils/url_utility';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import createReleaseMutation from '~/releases/graphql/mutations/create_release.mutation.graphql'; import createReleaseMutation from '~/releases/graphql/mutations/create_release.mutation.graphql';
...@@ -39,7 +39,9 @@ export const fetchRelease = async ({ commit, state }) => { ...@@ -39,7 +39,9 @@ export const fetchRelease = async ({ commit, state }) => {
commit(types.RECEIVE_RELEASE_SUCCESS, release); commit(types.RECEIVE_RELEASE_SUCCESS, release);
} catch (error) { } catch (error) {
commit(types.RECEIVE_RELEASE_ERROR, error); commit(types.RECEIVE_RELEASE_ERROR, error);
createFlash(s__('Release|Something went wrong while getting the release details.')); createFlash({
message: s__('Release|Something went wrong while getting the release details.'),
});
} }
}; };
...@@ -124,7 +126,9 @@ export const createRelease = async ({ commit, dispatch, state, getters }) => { ...@@ -124,7 +126,9 @@ export const createRelease = async ({ commit, dispatch, state, getters }) => {
dispatch('receiveSaveReleaseSuccess', response.data.releaseCreate.release.links.selfUrl); dispatch('receiveSaveReleaseSuccess', response.data.releaseCreate.release.links.selfUrl);
} catch (error) { } catch (error) {
commit(types.RECEIVE_SAVE_RELEASE_ERROR, error); commit(types.RECEIVE_SAVE_RELEASE_ERROR, error);
createFlash(s__('Release|Something went wrong while creating a new release.')); createFlash({
message: s__('Release|Something went wrong while creating a new release.'),
});
} }
}; };
...@@ -214,6 +218,8 @@ export const updateRelease = async ({ commit, dispatch, state, getters }) => { ...@@ -214,6 +218,8 @@ export const updateRelease = async ({ commit, dispatch, state, getters }) => {
dispatch('receiveSaveReleaseSuccess', state.release._links.self); dispatch('receiveSaveReleaseSuccess', state.release._links.self);
} catch (error) { } catch (error) {
commit(types.RECEIVE_SAVE_RELEASE_ERROR, error); commit(types.RECEIVE_SAVE_RELEASE_ERROR, error);
createFlash(s__('Release|Something went wrong while saving the release details.')); createFlash({
message: s__('Release|Something went wrong while saving the release details.'),
});
} }
}; };
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { PAGE_SIZE } from '~/releases/constants'; import { PAGE_SIZE } from '~/releases/constants';
import allReleasesQuery from '~/releases/graphql/queries/all_releases.query.graphql'; import allReleasesQuery from '~/releases/graphql/queries/all_releases.query.graphql';
...@@ -57,7 +57,9 @@ export const fetchReleases = ({ dispatch, commit, state }, { before, after }) => ...@@ -57,7 +57,9 @@ export const fetchReleases = ({ dispatch, commit, state }, { before, after }) =>
export const receiveReleasesError = ({ commit }) => { export const receiveReleasesError = ({ commit }) => {
commit(types.RECEIVE_RELEASES_ERROR); commit(types.RECEIVE_RELEASES_ERROR);
createFlash(__('An error occurred while fetching the releases. Please try again.')); createFlash({
message: __('An error occurred while fetching the releases. Please try again.'),
});
}; };
export const setSorting = ({ commit }, data) => commit(types.SET_SORTING, data); export const setSorting = ({ commit }, data) => commit(types.SET_SORTING, data);
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { backOff } from '~/lib/utils/common_utils'; import { backOff } from '~/lib/utils/common_utils';
import statusCodes from '~/lib/utils/http_status'; import statusCodes from '~/lib/utils/http_status';
...@@ -59,7 +59,9 @@ export const fetchFunctions = ({ dispatch }, { functionsPath }) => { ...@@ -59,7 +59,9 @@ export const fetchFunctions = ({ dispatch }, { functionsPath }) => {
.then((data) => { .then((data) => {
if (data === TIMEOUT) { if (data === TIMEOUT) {
dispatch('receiveFunctionsTimeout'); dispatch('receiveFunctionsTimeout');
createFlash(__('Loading functions timed out. Please reload the page to try again.')); createFlash({
message: __('Loading functions timed out. Please reload the page to try again.'),
});
} else if (data.functions !== null && data.functions.length) { } else if (data.functions !== null && data.functions.length) {
dispatch('receiveFunctionsSuccess', data); dispatch('receiveFunctionsSuccess', data);
} else { } else {
...@@ -68,7 +70,9 @@ export const fetchFunctions = ({ dispatch }, { functionsPath }) => { ...@@ -68,7 +70,9 @@ export const fetchFunctions = ({ dispatch }, { functionsPath }) => {
}) })
.catch((error) => { .catch((error) => {
dispatch('receiveFunctionsError', error); dispatch('receiveFunctionsError', error);
createFlash(error); createFlash({
message: error,
});
}); });
}; };
...@@ -120,6 +124,8 @@ export const fetchMetrics = ({ dispatch }, { metricsPath, hasPrometheus }) => { ...@@ -120,6 +124,8 @@ export const fetchMetrics = ({ dispatch }, { metricsPath, hasPrometheus }) => {
}) })
.catch((error) => { .catch((error) => {
dispatch('receiveMetricsError', error); dispatch('receiveMetricsError', error);
createFlash(error); createFlash({
message: error,
});
}); });
}; };
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import $ from 'jquery'; import $ from 'jquery';
import { spriteIcon } from '~/lib/utils/common_utils'; import { spriteIcon } from '~/lib/utils/common_utils';
import FilesCommentButton from './files_comment_button'; import FilesCommentButton from './files_comment_button';
import { deprecatedCreateFlash as createFlash } from './flash'; import createFlash from './flash';
import initImageDiffHelper from './image_diff/helpers/init_image_diff'; import initImageDiffHelper from './image_diff/helpers/init_image_diff';
import axios from './lib/utils/axios_utils'; import axios from './lib/utils/axios_utils';
import { __ } from './locale'; import { __ } from './locale';
...@@ -95,7 +95,9 @@ export default class SingleFileDiff { ...@@ -95,7 +95,9 @@ export default class SingleFileDiff {
if (cb) cb(); if (cb) cb();
}) })
.catch(() => { .catch(() => {
createFlash(__('An error occurred while retrieving diff')); createFlash({
message: __('An error occurred while retrieving diff'),
});
}); });
} }
} }
<script> <script>
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import BlobHeaderEdit from '~/blob/components/blob_edit_header.vue'; import BlobHeaderEdit from '~/blob/components/blob_edit_header.vue';
import { deprecatedCreateFlash as Flash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { getBaseURL, joinPaths } from '~/lib/utils/url_utility'; import { getBaseURL, joinPaths } from '~/lib/utils/url_utility';
import { sprintf } from '~/locale'; import { sprintf } from '~/locale';
...@@ -63,7 +63,7 @@ export default { ...@@ -63,7 +63,7 @@ export default {
.catch((e) => this.flashAPIFailure(e)); .catch((e) => this.flashAPIFailure(e));
}, },
flashAPIFailure(err) { flashAPIFailure(err) {
Flash(sprintf(SNIPPET_BLOB_CONTENT_FETCH_ERROR, { err })); createFlash({ message: sprintf(SNIPPET_BLOB_CONTENT_FETCH_ERROR, { err }) });
}, },
}, },
}; };
......
import Api from '~/api'; import Api from '~/api';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { __ } from '~/locale'; import { __ } from '~/locale';
import * as types from './mutation_types'; import * as types from './mutation_types';
...@@ -24,7 +24,9 @@ export function fetchBranches({ commit, state }, search = '') { ...@@ -24,7 +24,9 @@ export function fetchBranches({ commit, state }, search = '') {
.catch(({ response }) => { .catch(({ response }) => {
const { status } = response; const { status } = response;
commit(types.RECEIVE_BRANCHES_ERROR, status); commit(types.RECEIVE_BRANCHES_ERROR, status);
createFlash(__('Failed to load branches. Please try again.')); createFlash({
message: __('Failed to load branches. Please try again.'),
});
}); });
} }
...@@ -41,7 +43,9 @@ export const fetchMilestones = ({ commit, state }, search_title = '') => { ...@@ -41,7 +43,9 @@ export const fetchMilestones = ({ commit, state }, search_title = '') => {
.catch(({ response }) => { .catch(({ response }) => {
const { status } = response; const { status } = response;
commit(types.RECEIVE_MILESTONES_ERROR, status); commit(types.RECEIVE_MILESTONES_ERROR, status);
createFlash(__('Failed to load milestones. Please try again.')); createFlash({
message: __('Failed to load milestones. Please try again.'),
});
}); });
}; };
...@@ -57,7 +61,9 @@ export const fetchLabels = ({ commit, state }, search = '') => { ...@@ -57,7 +61,9 @@ export const fetchLabels = ({ commit, state }, search = '') => {
.catch(({ response }) => { .catch(({ response }) => {
const { status } = response; const { status } = response;
commit(types.RECEIVE_LABELS_ERROR, status); commit(types.RECEIVE_LABELS_ERROR, status);
createFlash(__('Failed to load labels. Please try again.')); createFlash({
message: __('Failed to load labels. Please try again.'),
});
}); });
}; };
...@@ -80,7 +86,9 @@ function fetchUser(options = {}) { ...@@ -80,7 +86,9 @@ function fetchUser(options = {}) {
.catch(({ response }) => { .catch(({ response }) => {
const { status } = response; const { status } = response;
commit(`RECEIVE_${action}_ERROR`, status); commit(`RECEIVE_${action}_ERROR`, status);
createFlash(errorMessage); createFlash({
message: errorMessage,
});
}); });
} }
......
...@@ -5,7 +5,7 @@ import * as actions from '~/ci_variable_list/store/actions'; ...@@ -5,7 +5,7 @@ import * as actions from '~/ci_variable_list/store/actions';
import * as types from '~/ci_variable_list/store/mutation_types'; import * as types from '~/ci_variable_list/store/mutation_types';
import getInitialState from '~/ci_variable_list/store/state'; import getInitialState from '~/ci_variable_list/store/state';
import { prepareDataForDisplay, prepareEnvironments } from '~/ci_variable_list/store/utils'; import { prepareDataForDisplay, prepareEnvironments } from '~/ci_variable_list/store/utils';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import mockData from '../services/mock_data'; import mockData from '../services/mock_data';
...@@ -240,7 +240,9 @@ describe('CI variable list store actions', () => { ...@@ -240,7 +240,9 @@ describe('CI variable list store actions', () => {
mock.onGet(state.endpoint).reply(500); mock.onGet(state.endpoint).reply(500);
testAction(actions.fetchVariables, {}, state, [], [{ type: 'requestVariables' }], () => { testAction(actions.fetchVariables, {}, state, [], [{ type: 'requestVariables' }], () => {
expect(createFlash).toHaveBeenCalledWith('There was an error fetching the variables.'); expect(createFlash).toHaveBeenCalledWith({
message: 'There was an error fetching the variables.',
});
done(); done();
}); });
}); });
...@@ -278,9 +280,9 @@ describe('CI variable list store actions', () => { ...@@ -278,9 +280,9 @@ describe('CI variable list store actions', () => {
[], [],
[{ type: 'requestEnvironments' }], [{ type: 'requestEnvironments' }],
() => { () => {
expect(createFlash).toHaveBeenCalledWith( expect(createFlash).toHaveBeenCalledWith({
'There was an error fetching the environments information.', message: 'There was an error fetching the environments information.',
); });
done(); done();
}, },
); );
......
...@@ -24,7 +24,7 @@ import { ...@@ -24,7 +24,7 @@ import {
CREATE_CLUSTER_ERROR, CREATE_CLUSTER_ERROR,
} from '~/create_cluster/eks_cluster/store/mutation_types'; } from '~/create_cluster/eks_cluster/store/mutation_types';
import createState from '~/create_cluster/eks_cluster/store/state'; import createState from '~/create_cluster/eks_cluster/store/state';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
jest.mock('~/flash'); jest.mock('~/flash');
...@@ -358,7 +358,9 @@ describe('EKS Cluster Store Actions', () => { ...@@ -358,7 +358,9 @@ describe('EKS Cluster Store Actions', () => {
testAction(actions.createClusterError, payload, state, [ testAction(actions.createClusterError, payload, state, [
{ type: CREATE_CLUSTER_ERROR, payload }, { type: CREATE_CLUSTER_ERROR, payload },
]).then(() => { ]).then(() => {
expect(createFlash).toHaveBeenCalledWith(payload.name[0]); expect(createFlash).toHaveBeenCalledWith({
message: payload.name[0],
});
})); }));
}); });
}); });
...@@ -4,7 +4,7 @@ import Api from '~/api'; ...@@ -4,7 +4,7 @@ import Api from '~/api';
import * as actions from '~/deploy_freeze/store/actions'; import * as actions from '~/deploy_freeze/store/actions';
import * as types from '~/deploy_freeze/store/mutation_types'; import * as types from '~/deploy_freeze/store/mutation_types';
import getInitialState from '~/deploy_freeze/store/state'; import getInitialState from '~/deploy_freeze/store/state';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { freezePeriodsFixture, timezoneDataFixture } from '../helpers'; import { freezePeriodsFixture, timezoneDataFixture } from '../helpers';
...@@ -189,9 +189,9 @@ describe('deploy freeze store actions', () => { ...@@ -189,9 +189,9 @@ describe('deploy freeze store actions', () => {
[{ type: types.REQUEST_FREEZE_PERIODS }], [{ type: types.REQUEST_FREEZE_PERIODS }],
[], [],
() => () =>
expect(createFlash).toHaveBeenCalledWith( expect(createFlash).toHaveBeenCalledWith({
'There was an error fetching the deploy freezes.', message: 'There was an error fetching the deploy freezes.',
), }),
); );
}); });
}); });
......
...@@ -54,7 +54,7 @@ import { ...@@ -54,7 +54,7 @@ import {
} from '~/diffs/store/actions'; } from '~/diffs/store/actions';
import * as types from '~/diffs/store/mutation_types'; import * as types from '~/diffs/store/mutation_types';
import * as utils from '~/diffs/store/utils'; import * as utils from '~/diffs/store/utils';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import * as commonUtils from '~/lib/utils/common_utils'; import * as commonUtils from '~/lib/utils/common_utils';
import { mergeUrlParams } from '~/lib/utils/url_utility'; import { mergeUrlParams } from '~/lib/utils/url_utility';
...@@ -293,7 +293,9 @@ describe('DiffsStoreActions', () => { ...@@ -293,7 +293,9 @@ describe('DiffsStoreActions', () => {
testAction(fetchCoverageFiles, {}, { endpointCoverage }, [], [], () => { testAction(fetchCoverageFiles, {}, { endpointCoverage }, [], [], () => {
expect(createFlash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
expect(createFlash).toHaveBeenCalledWith(expect.stringMatching('Something went wrong')); expect(createFlash).toHaveBeenCalledWith({
message: expect.stringMatching('Something went wrong'),
});
done(); done();
}); });
}); });
......
...@@ -2,7 +2,7 @@ import MockAdapter from 'axios-mock-adapter'; ...@@ -2,7 +2,7 @@ import MockAdapter from 'axios-mock-adapter';
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import * as actions from '~/error_tracking/store/actions'; import * as actions from '~/error_tracking/store/actions';
import * as types from '~/error_tracking/store/mutation_types'; import * as types from '~/error_tracking/store/mutation_types';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
......
...@@ -2,7 +2,7 @@ import MockAdapter from 'axios-mock-adapter'; ...@@ -2,7 +2,7 @@ import MockAdapter from 'axios-mock-adapter';
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import * as actions from '~/error_tracking/store/details/actions'; import * as actions from '~/error_tracking/store/details/actions';
import * as types from '~/error_tracking/store/details/mutation_types'; import * as types from '~/error_tracking/store/details/mutation_types';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import Poll from '~/lib/utils/poll'; import Poll from '~/lib/utils/poll';
......
...@@ -2,7 +2,7 @@ import MockAdapter from 'axios-mock-adapter'; ...@@ -2,7 +2,7 @@ import MockAdapter from 'axios-mock-adapter';
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import * as actions from '~/error_tracking/store/list/actions'; import * as actions from '~/error_tracking/store/list/actions';
import * as types from '~/error_tracking/store/list/mutation_types'; import * as types from '~/error_tracking/store/list/mutation_types';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import httpStatusCodes from '~/lib/utils/http_status'; import httpStatusCodes from '~/lib/utils/http_status';
......
...@@ -2,7 +2,7 @@ import { GlButton } from '@gitlab/ui'; ...@@ -2,7 +2,7 @@ import { GlButton } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import { mountExtended } from 'helpers/vue_test_utils_helper'; import { mountExtended } from 'helpers/vue_test_utils_helper';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import GrafanaIntegration from '~/grafana_integration/components/grafana_integration.vue'; import GrafanaIntegration from '~/grafana_integration/components/grafana_integration.vue';
import { createStore } from '~/grafana_integration/store'; import { createStore } from '~/grafana_integration/store';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
...@@ -112,10 +112,10 @@ describe('grafana integration component', () => { ...@@ -112,10 +112,10 @@ describe('grafana integration component', () => {
.$nextTick() .$nextTick()
.then(jest.runAllTicks) .then(jest.runAllTicks)
.then(() => .then(() =>
expect(createFlash).toHaveBeenCalledWith( expect(createFlash).toHaveBeenCalledWith({
`There was an error saving your changes. ${message}`, message: `There was an error saving your changes. ${message}`,
'alert', type: 'alert',
), }),
); );
}); });
}); });
......
import Vue from 'vue'; import Vue from 'vue';
import { createComponentWithStore } from 'helpers/vue_mount_component_helper'; import { createComponentWithStore } from 'helpers/vue_mount_component_helper';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import modal from '~/ide/components/new_dropdown/modal.vue'; import modal from '~/ide/components/new_dropdown/modal.vue';
import { createStore } from '~/ide/stores'; import { createStore } from '~/ide/stores';
...@@ -182,14 +182,14 @@ describe('new file modal component', () => { ...@@ -182,14 +182,14 @@ describe('new file modal component', () => {
vm.submitForm(); vm.submitForm();
expect(createFlash).toHaveBeenCalledWith( expect(createFlash).toHaveBeenCalledWith({
'The name "test-path/test" is already taken in this directory.', message: 'The name "test-path/test" is already taken in this directory.',
'alert', type: 'alert',
expect.anything(), parent: expect.anything(),
null, actionConfig: null,
false, fadeTransition: false,
true, addBodyClass: true,
); });
}); });
it('does not throw error when target entry does not exist', () => { it('does not throw error when target entry does not exist', () => {
......
...@@ -2,7 +2,7 @@ import MockAdapter from 'axios-mock-adapter'; ...@@ -2,7 +2,7 @@ import MockAdapter from 'axios-mock-adapter';
import { range } from 'lodash'; import { range } from 'lodash';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import { leftSidebarViews, PERMISSION_READ_MR, MAX_MR_FILES_AUTO_OPEN } from '~/ide/constants'; import { leftSidebarViews, PERMISSION_READ_MR, MAX_MR_FILES_AUTO_OPEN } from '~/ide/constants';
import service from '~/ide/services'; import service from '~/ide/services';
import { createStore } from '~/ide/stores'; import { createStore } from '~/ide/stores';
...@@ -145,7 +145,9 @@ describe('IDE store merge request actions', () => { ...@@ -145,7 +145,9 @@ describe('IDE store merge request actions', () => {
.dispatch('getMergeRequestsForBranch', { projectId: TEST_PROJECT, branchId: 'bar' }) .dispatch('getMergeRequestsForBranch', { projectId: TEST_PROJECT, branchId: 'bar' })
.catch(() => { .catch(() => {
expect(createFlash).toHaveBeenCalled(); expect(createFlash).toHaveBeenCalled();
expect(createFlash.mock.calls[0][0]).toBe('Error fetching merge requests for bar'); expect(createFlash.mock.calls[0][0].message).toBe(
'Error fetching merge requests for bar',
);
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
...@@ -562,7 +564,9 @@ describe('IDE store merge request actions', () => { ...@@ -562,7 +564,9 @@ describe('IDE store merge request actions', () => {
openMergeRequest(store, mr) openMergeRequest(store, mr)
.catch(() => { .catch(() => {
expect(createFlash).toHaveBeenCalledWith(expect.any(String)); expect(createFlash).toHaveBeenCalledWith({
message: expect.any(String),
});
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
......
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import * as actions from '~/ide/stores/modules/terminal/actions/session_controls'; import * as actions from '~/ide/stores/modules/terminal/actions/session_controls';
import { STARTING, PENDING, STOPPING, STOPPED } from '~/ide/stores/modules/terminal/constants'; import { STARTING, PENDING, STOPPING, STOPPED } from '~/ide/stores/modules/terminal/constants';
import * as messages from '~/ide/stores/modules/terminal/messages'; import * as messages from '~/ide/stores/modules/terminal/messages';
...@@ -89,7 +89,9 @@ describe('IDE store terminal session controls actions', () => { ...@@ -89,7 +89,9 @@ describe('IDE store terminal session controls actions', () => {
it('flashes message', () => { it('flashes message', () => {
actions.receiveStartSessionError({ dispatch }); actions.receiveStartSessionError({ dispatch });
expect(createFlash).toHaveBeenCalledWith(messages.UNEXPECTED_ERROR_STARTING); expect(createFlash).toHaveBeenCalledWith({
message: messages.UNEXPECTED_ERROR_STARTING,
});
}); });
it('sets session status', () => { it('sets session status', () => {
...@@ -161,7 +163,9 @@ describe('IDE store terminal session controls actions', () => { ...@@ -161,7 +163,9 @@ describe('IDE store terminal session controls actions', () => {
it('flashes message', () => { it('flashes message', () => {
actions.receiveStopSessionError({ dispatch }); actions.receiveStopSessionError({ dispatch });
expect(createFlash).toHaveBeenCalledWith(messages.UNEXPECTED_ERROR_STOPPING); expect(createFlash).toHaveBeenCalledWith({
message: messages.UNEXPECTED_ERROR_STOPPING,
});
}); });
it('kills the session', () => { it('kills the session', () => {
......
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import * as actions from '~/ide/stores/modules/terminal/actions/session_status'; import * as actions from '~/ide/stores/modules/terminal/actions/session_status';
import { PENDING, RUNNING, STOPPING, STOPPED } from '~/ide/stores/modules/terminal/constants'; import { PENDING, RUNNING, STOPPING, STOPPED } from '~/ide/stores/modules/terminal/constants';
import * as messages from '~/ide/stores/modules/terminal/messages'; import * as messages from '~/ide/stores/modules/terminal/messages';
...@@ -115,7 +115,9 @@ describe('IDE store terminal session controls actions', () => { ...@@ -115,7 +115,9 @@ describe('IDE store terminal session controls actions', () => {
it('flashes message', () => { it('flashes message', () => {
actions.receiveSessionStatusError({ dispatch }); actions.receiveSessionStatusError({ dispatch });
expect(createFlash).toHaveBeenCalledWith(messages.UNEXPECTED_ERROR_STATUS); expect(createFlash).toHaveBeenCalledWith({
message: messages.UNEXPECTED_ERROR_STATUS,
});
}); });
it('kills the session', () => { it('kills the session', () => {
......
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import { STATUSES } from '~/import_entities/constants'; import { STATUSES } from '~/import_entities/constants';
import actionsFactory from '~/import_entities/import_projects/store/actions'; import actionsFactory from '~/import_entities/import_projects/store/actions';
import { getImportTarget } from '~/import_entities/import_projects/store/getters'; import { getImportTarget } from '~/import_entities/import_projects/store/getters';
...@@ -168,7 +168,9 @@ describe('import_projects store actions', () => { ...@@ -168,7 +168,9 @@ describe('import_projects store actions', () => {
[], [],
); );
expect(createFlash).toHaveBeenCalledWith('Provider rate limit exceeded. Try again later'); expect(createFlash).toHaveBeenCalledWith({
message: 'Provider rate limit exceeded. Try again later',
});
}); });
}); });
...@@ -245,7 +247,9 @@ describe('import_projects store actions', () => { ...@@ -245,7 +247,9 @@ describe('import_projects store actions', () => {
[], [],
); );
expect(createFlash).toHaveBeenCalledWith('Importing the project failed'); expect(createFlash).toHaveBeenCalledWith({
message: 'Importing the project failed',
});
}); });
it('commits REQUEST_IMPORT and RECEIVE_IMPORT_ERROR and shows detailed error message on an unsuccessful request with errors fields in response', async () => { it('commits REQUEST_IMPORT and RECEIVE_IMPORT_ERROR and shows detailed error message on an unsuccessful request with errors fields in response', async () => {
...@@ -266,7 +270,9 @@ describe('import_projects store actions', () => { ...@@ -266,7 +270,9 @@ describe('import_projects store actions', () => {
[], [],
); );
expect(createFlash).toHaveBeenCalledWith(`Importing the project failed: ${ERROR_MESSAGE}`); expect(createFlash).toHaveBeenCalledWith({
message: `Importing the project failed: ${ERROR_MESSAGE}`,
});
}); });
}); });
...@@ -365,7 +371,9 @@ describe('import_projects store actions', () => { ...@@ -365,7 +371,9 @@ describe('import_projects store actions', () => {
[], [],
); );
expect(createFlash).toHaveBeenCalledWith('Requesting namespaces failed'); expect(createFlash).toHaveBeenCalledWith({
message: 'Requesting namespaces failed',
});
}); });
}); });
......
import AxiosMockAdapter from 'axios-mock-adapter'; import AxiosMockAdapter from 'axios-mock-adapter';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import { ERROR_MSG } from '~/incidents_settings/constants'; import { ERROR_MSG } from '~/incidents_settings/constants';
import IncidentsSettingsService from '~/incidents_settings/incidents_settings_service'; import IncidentsSettingsService from '~/incidents_settings/incidents_settings_service';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
...@@ -37,7 +37,10 @@ describe('IncidentsSettingsService', () => { ...@@ -37,7 +37,10 @@ describe('IncidentsSettingsService', () => {
mock.onPatch().reply(httpStatusCodes.BAD_REQUEST); mock.onPatch().reply(httpStatusCodes.BAD_REQUEST);
return service.updateSettings({}).then(() => { return service.updateSettings({}).then(() => {
expect(createFlash).toHaveBeenCalledWith(expect.stringContaining(ERROR_MSG), 'alert'); expect(createFlash).toHaveBeenCalledWith({
message: expect.stringContaining(ERROR_MSG),
type: 'alert',
});
}); });
}); });
}); });
......
...@@ -6,7 +6,7 @@ import { ...@@ -6,7 +6,7 @@ import {
issuable1, issuable1,
issuable2, issuable2,
} from 'jest/vue_shared/components/issue/related_issuable_mock_data'; } from 'jest/vue_shared/components/issue/related_issuable_mock_data';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import RelatedIssuesRoot from '~/related_issues/components/related_issues_root.vue'; import RelatedIssuesRoot from '~/related_issues/components/related_issues_root.vue';
import { linkedIssueTypesMap } from '~/related_issues/constants'; import { linkedIssueTypesMap } from '~/related_issues/constants';
...@@ -195,7 +195,9 @@ describe('RelatedIssuesRoot', () => { ...@@ -195,7 +195,9 @@ describe('RelatedIssuesRoot', () => {
wrapper.vm.onPendingFormSubmit(input); wrapper.vm.onPendingFormSubmit(input);
return waitForPromises().then(() => { return waitForPromises().then(() => {
expect(createFlash).toHaveBeenCalledWith(message); expect(createFlash).toHaveBeenCalledWith({
message,
});
}); });
}); });
}); });
......
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import { backoffMockImplementation } from 'helpers/backoff_helper'; import { backoffMockImplementation } from 'helpers/backoff_helper';
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import * as commonUtils from '~/lib/utils/common_utils'; import * as commonUtils from '~/lib/utils/common_utils';
import statusCodes from '~/lib/utils/http_status'; import statusCodes from '~/lib/utils/http_status';
...@@ -257,9 +257,9 @@ describe('Monitoring store actions', () => { ...@@ -257,9 +257,9 @@ describe('Monitoring store actions', () => {
'receiveMetricsDashboardFailure', 'receiveMetricsDashboardFailure',
new Error('Request failed with status code 500'), new Error('Request failed with status code 500'),
); );
expect(createFlash).toHaveBeenCalledWith( expect(createFlash).toHaveBeenCalledWith({
expect.stringContaining(mockDashboardsErrorResponse.message), message: expect.stringContaining(mockDashboardsErrorResponse.message),
); });
done(); done();
}) })
.catch(done.fail); .catch(done.fail);
...@@ -1148,9 +1148,9 @@ describe('Monitoring store actions', () => { ...@@ -1148,9 +1148,9 @@ describe('Monitoring store actions', () => {
return testAction(fetchVariableMetricLabelValues, { defaultQueryParams }, state, [], []).then( return testAction(fetchVariableMetricLabelValues, { defaultQueryParams }, state, [], []).then(
() => { () => {
expect(createFlash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
expect(createFlash).toHaveBeenCalledWith( expect(createFlash).toHaveBeenCalledWith({
expect.stringContaining('error getting options for variable "label1"'), message: expect.stringContaining('error getting options for variable "label1"'),
); });
}, },
); );
}); });
......
import { GlButton, GlLink, GlFormGroup, GlFormInput, GlFormSelect } from '@gitlab/ui'; import { GlButton, GlLink, GlFormGroup, GlFormInput, GlFormSelect } from '@gitlab/ui';
import { mount, shallowMount } from '@vue/test-utils'; import { mount, shallowMount } from '@vue/test-utils';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { refreshCurrentPage } from '~/lib/utils/url_utility'; import { refreshCurrentPage } from '~/lib/utils/url_utility';
import { timezones } from '~/monitoring/format_date'; import { timezones } from '~/monitoring/format_date';
...@@ -203,10 +203,10 @@ describe('operation settings external dashboard component', () => { ...@@ -203,10 +203,10 @@ describe('operation settings external dashboard component', () => {
.$nextTick() .$nextTick()
.then(jest.runAllTicks) .then(jest.runAllTicks)
.then(() => .then(() =>
expect(createFlash).toHaveBeenCalledWith( expect(createFlash).toHaveBeenCalledWith({
`There was an error saving your changes. ${message}`, message: `There was an error saving your changes. ${message}`,
'alert', type: 'alert',
), }),
); );
}); });
}); });
......
...@@ -2,7 +2,7 @@ import axios from 'axios'; ...@@ -2,7 +2,7 @@ import axios from 'axios';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import Api from '~/api'; import Api from '~/api';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import { MISSING_DELETE_PATH_ERROR } from '~/packages/list/constants'; import { MISSING_DELETE_PATH_ERROR } from '~/packages/list/constants';
import * as actions from '~/packages/list/stores/actions'; import * as actions from '~/packages/list/stores/actions';
import * as types from '~/packages/list/stores/mutation_types'; import * as types from '~/packages/list/stores/mutation_types';
...@@ -241,7 +241,9 @@ describe('Actions Package list store', () => { ...@@ -241,7 +241,9 @@ describe('Actions Package list store', () => {
`('should reject and createFlash when $property is missing', ({ actionPayload }, done) => { `('should reject and createFlash when $property is missing', ({ actionPayload }, done) => {
testAction(actions.requestDeletePackage, actionPayload, null, [], []).catch((e) => { testAction(actions.requestDeletePackage, actionPayload, null, [], []).catch((e) => {
expect(e).toEqual(new Error(MISSING_DELETE_PATH_ERROR)); expect(e).toEqual(new Error(MISSING_DELETE_PATH_ERROR));
expect(createFlash).toHaveBeenCalledWith(DELETE_PACKAGE_ERROR_MESSAGE); expect(createFlash).toHaveBeenCalledWith({
message: DELETE_PACKAGE_ERROR_MESSAGE,
});
done(); done();
}); });
}); });
......
...@@ -2,7 +2,7 @@ import MockAdapter from 'axios-mock-adapter'; ...@@ -2,7 +2,7 @@ import MockAdapter from 'axios-mock-adapter';
import { getJSONFixture } from 'helpers/fixtures'; import { getJSONFixture } from 'helpers/fixtures';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import * as actions from '~/pipelines/stores/test_reports/actions'; import * as actions from '~/pipelines/stores/test_reports/actions';
import * as types from '~/pipelines/stores/test_reports/mutation_types'; import * as types from '~/pipelines/stores/test_reports/mutation_types';
......
...@@ -2,7 +2,7 @@ import { GlModal } from '@gitlab/ui'; ...@@ -2,7 +2,7 @@ import { GlModal } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import UpdateUsername from '~/profile/account/components/update_username.vue'; import UpdateUsername from '~/profile/account/components/update_username.vue';
...@@ -146,7 +146,9 @@ describe('UpdateUsername component', () => { ...@@ -146,7 +146,9 @@ describe('UpdateUsername component', () => {
await expect(wrapper.vm.onConfirm()).rejects.toThrow(); await expect(wrapper.vm.onConfirm()).rejects.toThrow();
expect(createFlash).toBeCalledWith('Invalid username'); expect(createFlash).toBeCalledWith({
message: 'Invalid username',
});
}); });
it("shows a fallback error message if the error response doesn't have a `message` property", async () => { it("shows a fallback error message if the error response doesn't have a `message` property", async () => {
...@@ -156,9 +158,9 @@ describe('UpdateUsername component', () => { ...@@ -156,9 +158,9 @@ describe('UpdateUsername component', () => {
await expect(wrapper.vm.onConfirm()).rejects.toThrow(); await expect(wrapper.vm.onConfirm()).rejects.toThrow();
expect(createFlash).toBeCalledWith( expect(createFlash).toBeCalledWith({
'An error occurred while updating your username, please try again.', message: 'An error occurred while updating your username, please try again.',
); });
}); });
}); });
}); });
import axios from 'axios'; import axios from 'axios';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import actions from '~/projects/commits/store/actions'; import actions from '~/projects/commits/store/actions';
import * as types from '~/projects/commits/store/mutation_types'; import * as types from '~/projects/commits/store/mutation_types';
import createState from '~/projects/commits/store/state'; import createState from '~/projects/commits/store/state';
...@@ -39,7 +39,9 @@ describe('Project commits actions', () => { ...@@ -39,7 +39,9 @@ describe('Project commits actions', () => {
actions.receiveAuthorsError(mockDispatchContext); actions.receiveAuthorsError(mockDispatchContext);
expect(createFlash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
expect(createFlash).toHaveBeenCalledWith('An error occurred fetching the project authors.'); expect(createFlash).toHaveBeenCalledWith({
message: 'An error occurred fetching the project authors.',
});
}); });
}); });
......
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import * as actions from '~/related_merge_requests/store/actions'; import * as actions from '~/related_merge_requests/store/actions';
import * as types from '~/related_merge_requests/store/mutation_types'; import * as types from '~/related_merge_requests/store/mutation_types';
...@@ -100,7 +100,9 @@ describe('RelatedMergeRequest store actions', () => { ...@@ -100,7 +100,9 @@ describe('RelatedMergeRequest store actions', () => {
[{ type: 'requestData' }, { type: 'receiveDataError' }], [{ type: 'requestData' }, { type: 'receiveDataError' }],
() => { () => {
expect(createFlash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
expect(createFlash).toHaveBeenCalledWith(expect.stringMatching('Something went wrong')); expect(createFlash).toHaveBeenCalledWith({
message: expect.stringMatching('Something went wrong'),
});
done(); done();
}, },
......
import { cloneDeep } from 'lodash'; import { cloneDeep } from 'lodash';
import { getJSONFixture } from 'helpers/fixtures'; import { getJSONFixture } from 'helpers/fixtures';
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import { redirectTo } from '~/lib/utils/url_utility'; import { redirectTo } from '~/lib/utils/url_utility';
import { ASSET_LINK_TYPE } from '~/releases/constants'; import { ASSET_LINK_TYPE } from '~/releases/constants';
import createReleaseAssetLinkMutation from '~/releases/graphql/mutations/create_release_link.mutation.graphql'; import createReleaseAssetLinkMutation from '~/releases/graphql/mutations/create_release_link.mutation.graphql';
...@@ -151,9 +151,9 @@ describe('Release edit/new actions', () => { ...@@ -151,9 +151,9 @@ describe('Release edit/new actions', () => {
it(`shows a flash message`, () => { it(`shows a flash message`, () => {
return actions.fetchRelease({ commit: jest.fn(), state, rootState: state }).then(() => { return actions.fetchRelease({ commit: jest.fn(), state, rootState: state }).then(() => {
expect(createFlash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
expect(createFlash).toHaveBeenCalledWith( expect(createFlash).toHaveBeenCalledWith({
'Something went wrong while getting the release details.', message: 'Something went wrong while getting the release details.',
); });
}); });
}); });
}); });
...@@ -352,9 +352,9 @@ describe('Release edit/new actions', () => { ...@@ -352,9 +352,9 @@ describe('Release edit/new actions', () => {
.createRelease({ commit: jest.fn(), dispatch: jest.fn(), state, getters: {} }) .createRelease({ commit: jest.fn(), dispatch: jest.fn(), state, getters: {} })
.then(() => { .then(() => {
expect(createFlash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
expect(createFlash).toHaveBeenCalledWith( expect(createFlash).toHaveBeenCalledWith({
'Something went wrong while creating a new release.', message: 'Something went wrong while creating a new release.',
); });
}); });
}); });
}); });
...@@ -483,9 +483,9 @@ describe('Release edit/new actions', () => { ...@@ -483,9 +483,9 @@ describe('Release edit/new actions', () => {
await actions.updateRelease({ commit, dispatch, state, getters }); await actions.updateRelease({ commit, dispatch, state, getters });
expect(createFlash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
expect(createFlash).toHaveBeenCalledWith( expect(createFlash).toHaveBeenCalledWith({
'Something went wrong while saving the release details.', message: 'Something went wrong while saving the release details.',
); });
}); });
}); });
...@@ -503,9 +503,9 @@ describe('Release edit/new actions', () => { ...@@ -503,9 +503,9 @@ describe('Release edit/new actions', () => {
await actions.updateRelease({ commit, dispatch, state, getters }); await actions.updateRelease({ commit, dispatch, state, getters });
expect(createFlash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
expect(createFlash).toHaveBeenCalledWith( expect(createFlash).toHaveBeenCalledWith({
'Something went wrong while saving the release details.', message: 'Something went wrong while saving the release details.',
); });
}); });
}; };
......
...@@ -4,7 +4,7 @@ import AxiosMockAdapter from 'axios-mock-adapter'; ...@@ -4,7 +4,7 @@ import AxiosMockAdapter from 'axios-mock-adapter';
import { TEST_HOST } from 'helpers/test_constants'; import { TEST_HOST } from 'helpers/test_constants';
import waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import BlobHeaderEdit from '~/blob/components/blob_edit_header.vue'; import BlobHeaderEdit from '~/blob/components/blob_edit_header.vue';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { joinPaths } from '~/lib/utils/url_utility'; import { joinPaths } from '~/lib/utils/url_utility';
import SnippetBlobEdit from '~/snippets/components/snippet_blob_edit.vue'; import SnippetBlobEdit from '~/snippets/components/snippet_blob_edit.vue';
...@@ -125,9 +125,9 @@ describe('Snippet Blob Edit component', () => { ...@@ -125,9 +125,9 @@ describe('Snippet Blob Edit component', () => {
it('should call flash', async () => { it('should call flash', async () => {
await waitForPromises(); await waitForPromises();
expect(createFlash).toHaveBeenCalledWith( expect(createFlash).toHaveBeenCalledWith({
"Can't fetch content for the blob: Error: Request failed with status code 500", message: "Can't fetch content for the blob: Error: Request failed with status code 500",
); });
}); });
}); });
......
import Vue from 'vue'; import Vue from 'vue';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import WorkInProgress from '~/vue_merge_request_widget/components/states/work_in_progress.vue'; import WorkInProgress from '~/vue_merge_request_widget/components/states/work_in_progress.vue';
import eventHub from '~/vue_merge_request_widget/event_hub'; import eventHub from '~/vue_merge_request_widget/event_hub';
...@@ -63,10 +63,10 @@ describe('Wip', () => { ...@@ -63,10 +63,10 @@ describe('Wip', () => {
setImmediate(() => { setImmediate(() => {
expect(vm.isMakingRequest).toBeTruthy(); expect(vm.isMakingRequest).toBeTruthy();
expect(eventHub.$emit).toHaveBeenCalledWith('UpdateWidgetData', mrObj); expect(eventHub.$emit).toHaveBeenCalledWith('UpdateWidgetData', mrObj);
expect(createFlash).toHaveBeenCalledWith( expect(createFlash).toHaveBeenCalledWith({
'The merge request can now be merged.', message: 'The merge request can now be merged.',
'notice', type: 'notice',
); });
done(); done();
}); });
}); });
......
...@@ -3,7 +3,7 @@ import MockAdapter from 'axios-mock-adapter'; ...@@ -3,7 +3,7 @@ import MockAdapter from 'axios-mock-adapter';
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import { mockBranches } from 'jest/vue_shared/components/filtered_search_bar/mock_data'; import { mockBranches } from 'jest/vue_shared/components/filtered_search_bar/mock_data';
import Api from '~/api'; import Api from '~/api';
import { deprecatedCreateFlash as createFlash } from '~/flash'; import createFlash from '~/flash';
import httpStatusCodes from '~/lib/utils/http_status'; import httpStatusCodes from '~/lib/utils/http_status';
import * as actions from '~/vue_shared/components/filtered_search_bar/store/modules/filters/actions'; import * as actions from '~/vue_shared/components/filtered_search_bar/store/modules/filters/actions';
import * as types from '~/vue_shared/components/filtered_search_bar/store/modules/filters/mutation_types'; import * as types from '~/vue_shared/components/filtered_search_bar/store/modules/filters/mutation_types';
......
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