Commit 73aec068 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Merge branch '3895-mlunoe-migrate-away-from-deprecated-create-flash-3' into 'master'

Refactor(createFlash): use non-deprecated function

See merge request gitlab-org/gitlab!63645
parents 35bc89d4 a82c2dd1
import { deprecatedCreateFlash as flash } from '~/flash'; import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import axios from '../lib/utils/axios_utils'; import axios from '../lib/utils/axios_utils';
import { buildApiUrl } from './api_utils'; import { buildApiUrl } from './api_utils';
...@@ -52,7 +52,11 @@ export function getUserProjects(userId, query, options, callback) { ...@@ -52,7 +52,11 @@ export function getUserProjects(userId, query, options, callback) {
params: { ...defaults, ...options }, params: { ...defaults, ...options },
}) })
.then(({ data }) => callback(data)) .then(({ data }) => callback(data))
.catch(() => flash(__('Something went wrong while fetching projects'))); .catch(() =>
createFlash({
message: __('Something went wrong while fetching projects'),
}),
);
} }
export function updateUserStatus({ emoji, message, availability, clearStatusAfter }) { export function updateUserStatus({ emoji, message, availability, clearStatusAfter }) {
......
...@@ -7,7 +7,7 @@ import { uniq } from 'lodash'; ...@@ -7,7 +7,7 @@ import { uniq } from 'lodash';
import * as Emoji from '~/emoji'; import * as Emoji from '~/emoji';
import { scrollToElement } from '~/lib/utils/common_utils'; import { scrollToElement } from '~/lib/utils/common_utils';
import { dispose, fixTitle } from '~/tooltips'; import { dispose, fixTitle } from '~/tooltips';
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 { isInVueNoteablePage } from './lib/utils/dom_utils'; import { isInVueNoteablePage } from './lib/utils/dom_utils';
import { __ } from './locale'; import { __ } from './locale';
...@@ -488,7 +488,11 @@ export class AwardsHandler { ...@@ -488,7 +488,11 @@ export class AwardsHandler {
callback(); callback();
} }
}) })
.catch(() => flash(__('Something went wrong on our end.'))); .catch(() =>
createFlash({
message: __('Something went wrong on our end.'),
}),
);
} }
findEmojiIcon(votesBlock, emoji) { findEmojiIcon(votesBlock, emoji) {
......
import { isEmpty } from 'lodash'; import { isEmpty } from 'lodash';
import { deprecatedCreateFlash as flash } from '~/flash'; import createFlash from '~/flash';
import { scrollToElement } from '~/lib/utils/common_utils'; import { scrollToElement } from '~/lib/utils/common_utils';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { CHANGES_TAB, DISCUSSION_TAB, SHOW_TAB } from '../../../constants'; import { CHANGES_TAB, DISCUSSION_TAB, SHOW_TAB } from '../../../constants';
...@@ -18,7 +18,9 @@ export const addDraftToDiscussion = ({ commit }, { endpoint, data }) => ...@@ -18,7 +18,9 @@ export const addDraftToDiscussion = ({ commit }, { endpoint, data }) =>
return res; return res;
}) })
.catch(() => { .catch(() => {
flash(__('An error occurred adding a draft to the thread.')); createFlash({
message: __('An error occurred adding a draft to the thread.'),
});
}); });
export const createNewDraft = ({ commit }, { endpoint, data }) => export const createNewDraft = ({ commit }, { endpoint, data }) =>
...@@ -30,7 +32,9 @@ export const createNewDraft = ({ commit }, { endpoint, data }) => ...@@ -30,7 +32,9 @@ export const createNewDraft = ({ commit }, { endpoint, data }) =>
return res; return res;
}) })
.catch(() => { .catch(() => {
flash(__('An error occurred adding a new draft.')); createFlash({
message: __('An error occurred adding a new draft.'),
});
}); });
export const deleteDraft = ({ commit, getters }, draft) => export const deleteDraft = ({ commit, getters }, draft) =>
...@@ -39,7 +43,11 @@ export const deleteDraft = ({ commit, getters }, draft) => ...@@ -39,7 +43,11 @@ export const deleteDraft = ({ commit, getters }, draft) =>
.then(() => { .then(() => {
commit(types.DELETE_DRAFT, draft.id); commit(types.DELETE_DRAFT, draft.id);
}) })
.catch(() => flash(__('An error occurred while deleting the comment'))); .catch(() =>
createFlash({
message: __('An error occurred while deleting the comment'),
}),
);
export const fetchDrafts = ({ commit, getters, state, dispatch }) => export const fetchDrafts = ({ commit, getters, state, dispatch }) =>
service service
...@@ -53,7 +61,11 @@ export const fetchDrafts = ({ commit, getters, state, dispatch }) => ...@@ -53,7 +61,11 @@ export const fetchDrafts = ({ commit, getters, state, dispatch }) =>
} }
}); });
}) })
.catch(() => flash(__('An error occurred while fetching pending comments'))); .catch(() =>
createFlash({
message: __('An error occurred while fetching pending comments'),
}),
);
export const publishSingleDraft = ({ commit, dispatch, getters }, draftId) => { export const publishSingleDraft = ({ commit, dispatch, getters }, draftId) => {
commit(types.REQUEST_PUBLISH_DRAFT, draftId); commit(types.REQUEST_PUBLISH_DRAFT, draftId);
...@@ -111,7 +123,11 @@ export const updateDraft = ( ...@@ -111,7 +123,11 @@ export const updateDraft = (
.then((res) => res.data) .then((res) => res.data)
.then((data) => commit(types.RECEIVE_DRAFT_UPDATE_SUCCESS, data)) .then((data) => commit(types.RECEIVE_DRAFT_UPDATE_SUCCESS, data))
.then(callback) .then(callback)
.catch(() => flash(__('An error occurred while updating the comment'))); .catch(() =>
createFlash({
message: __('An error occurred while updating the comment'),
}),
);
}; };
export const scrollToDraft = ({ dispatch, rootGetters }, draft) => { export const scrollToDraft = ({ dispatch, rootGetters }, draft) => {
......
import $ from 'jquery'; import $ from 'jquery';
import { once, countBy } from 'lodash'; import { once, countBy } from 'lodash';
import { deprecatedCreateFlash as flash } from '~/flash'; import createFlash from '~/flash';
import { darkModeEnabled } from '~/lib/utils/color_utils'; import { darkModeEnabled } from '~/lib/utils/color_utils';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
...@@ -78,7 +78,9 @@ function importMermaidModule() { ...@@ -78,7 +78,9 @@ function importMermaidModule() {
mermaidModule = initMermaid(mermaid); mermaidModule = initMermaid(mermaid);
}) })
.catch((err) => { .catch((err) => {
flash(sprintf(__("Can't load mermaid module: %{err}"), { err })); createFlash({
message: sprintf(__("Can't load mermaid module: %{err}"), { err }),
});
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.error(err); console.error(err);
}); });
...@@ -205,7 +207,9 @@ function renderMermaids($els) { ...@@ -205,7 +207,9 @@ function renderMermaids($els) {
}); });
}) })
.catch((err) => { .catch((err) => {
flash(sprintf(__('Encountered an error while rendering: %{err}'), { err })); createFlash({
message: sprintf(__('Encountered an error while rendering: %{err}'), { err }),
});
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.error(err); console.error(err);
}); });
......
/* eslint-disable func-names */ /* eslint-disable func-names */
import $ from 'jquery'; import $ from 'jquery';
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 { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -79,7 +79,11 @@ MarkdownPreview.prototype.fetchMarkdownPreview = function (text, url, success) { ...@@ -79,7 +79,11 @@ MarkdownPreview.prototype.fetchMarkdownPreview = function (text, url, success) {
}; };
success(data); success(data);
}) })
.catch(() => flash(__('An error occurred while fetching markdown preview'))); .catch(() =>
createFlash({
message: __('An error occurred while fetching markdown preview'),
}),
);
}; };
MarkdownPreview.prototype.hideReferencedUsers = function ($form) { MarkdownPreview.prototype.hideReferencedUsers = function ($form) {
......
import { __ } from '~/locale'; import { __ } from '~/locale';
import { deprecatedCreateFlash as Flash } from '../flash'; import createFlash from '../flash';
import BalsamiqViewer from './balsamiq/balsamiq_viewer'; import BalsamiqViewer from './balsamiq/balsamiq_viewer';
function onError() { function onError() {
const flash = new Flash(__('Balsamiq file could not be loaded.')); const flash = createFlash({
message: __('Balsamiq file could not be loaded.'),
});
return flash; return flash;
} }
......
...@@ -5,7 +5,7 @@ import initPopover from '~/blob/suggest_gitlab_ci_yml'; ...@@ -5,7 +5,7 @@ import initPopover from '~/blob/suggest_gitlab_ci_yml';
import { __ } from '~/locale'; import { __ } from '~/locale';
import toast from '~/vue_shared/plugins/global_toast'; import toast from '~/vue_shared/plugins/global_toast';
import { deprecatedCreateFlash as Flash } from '../flash'; import createFlash from '../flash';
import BlobCiYamlSelector from './template_selectors/ci_yaml_selector'; import BlobCiYamlSelector from './template_selectors/ci_yaml_selector';
import DockerfileSelector from './template_selectors/dockerfile_selector'; import DockerfileSelector from './template_selectors/dockerfile_selector';
...@@ -155,7 +155,11 @@ export default class FileTemplateMediator { ...@@ -155,7 +155,11 @@ export default class FileTemplateMediator {
initPopover(suggestCommitChanges); initPopover(suggestCommitChanges);
} }
}) })
.catch((err) => new Flash(`An error occurred while fetching the template: ${err}`)); .catch((err) =>
createFlash({
message: __(`An error occurred while fetching the template: ${err}`),
}),
);
} }
displayMatchedTemplateSelector() { displayMatchedTemplateSelector() {
......
import { SwaggerUIBundle } from 'swagger-ui-dist'; import { SwaggerUIBundle } from 'swagger-ui-dist';
import { deprecatedCreateFlash as flash } from '~/flash'; import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
export default () => { export default () => {
...@@ -13,7 +13,9 @@ export default () => { ...@@ -13,7 +13,9 @@ export default () => {
}); });
}) })
.catch((error) => { .catch((error) => {
flash(__('Something went wrong while initializing the OpenAPI viewer')); createFlash({
message: __('Something went wrong while initializing the OpenAPI viewer'),
});
throw error; throw error;
}); });
}; };
...@@ -8,7 +8,7 @@ import { ...@@ -8,7 +8,7 @@ import {
} from '~/performance/constants'; } from '~/performance/constants';
import { performanceMarkAndMeasure } from '~/performance/utils'; import { performanceMarkAndMeasure } from '~/performance/utils';
import { fixTitle } from '~/tooltips'; import { fixTitle } from '~/tooltips';
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 { handleLocationHash } from '../../lib/utils/common_utils'; import { handleLocationHash } from '../../lib/utils/common_utils';
import eventHub from '../../notes/event_hub'; import eventHub from '../../notes/event_hub';
...@@ -38,7 +38,9 @@ export const handleBlobRichViewer = (viewer, type) => { ...@@ -38,7 +38,9 @@ export const handleBlobRichViewer = (viewer, type) => {
loadRichBlobViewer(type) loadRichBlobViewer(type)
.then((module) => module?.default(viewer)) .then((module) => module?.default(viewer))
.catch((error) => { .catch((error) => {
Flash(__('Error loading file viewer.')); createFlash({
message: __('Error loading file viewer.'),
});
throw error; throw error;
}); });
}; };
...@@ -182,7 +184,11 @@ export default class BlobViewer { ...@@ -182,7 +184,11 @@ export default class BlobViewer {
], ],
}); });
}) })
.catch(() => new Flash(__('Error loading viewer'))); .catch(() =>
createFlash({
message: __('Error loading viewer'),
}),
);
} }
static loadViewer(viewerParam) { static loadViewer(viewerParam) {
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import $ from 'jquery'; import $ from 'jquery';
import store from '~/boards/stores'; import store from '~/boards/stores';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown'; import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
import { deprecatedCreateFlash as flash } from '~/flash'; import createFlash from '~/flash';
import { getIdFromGraphQLId } from '~/graphql_shared/utils'; import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -53,7 +53,9 @@ export default function initNewListDropdown() { ...@@ -53,7 +53,9 @@ export default function initNewListDropdown() {
data(term, callback) { data(term, callback) {
const reqFailed = () => { const reqFailed = () => {
$dropdownToggle.data('bs.dropdown').hide(); $dropdownToggle.data('bs.dropdown').hide();
flash(__('Error fetching labels.')); createFlash({
message: __('Error fetching labels.'),
});
}; };
if (store.getters.shouldUseGraphQL) { if (store.getters.shouldUseGraphQL) {
......
/* eslint-disable class-methods-use-this */ /* eslint-disable class-methods-use-this */
import { deprecatedCreateFlash as flash } from '~/flash'; import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import boardsStore from '../stores/boards_store'; import boardsStore from '../stores/boards_store';
import ListAssignee from './assignee'; import ListAssignee from './assignee';
...@@ -127,7 +127,11 @@ class List { ...@@ -127,7 +127,11 @@ class List {
moveBeforeId, moveBeforeId,
moveAfterId, moveAfterId,
}) })
.catch(() => flash(__('Something went wrong while moving issues.'))); .catch(() =>
createFlash({
message: __('Something went wrong while moving issues.'),
}),
);
} }
updateIssueLabel(issue, listFrom, moveBeforeId, moveAfterId) { updateIssueLabel(issue, listFrom, moveBeforeId, moveAfterId) {
...@@ -145,7 +149,11 @@ class List { ...@@ -145,7 +149,11 @@ class List {
moveBeforeId, moveBeforeId,
moveAfterId, moveAfterId,
}) })
.catch(() => flash(__('Something went wrong while moving issues.'))); .catch(() =>
createFlash({
message: __('Something went wrong while moving issues.'),
}),
);
} }
findIssue(id) { findIssue(id) {
......
...@@ -4,7 +4,7 @@ import Vue from 'vue'; ...@@ -4,7 +4,7 @@ import Vue from 'vue';
import AccessorUtilities from '~/lib/utils/accessor'; import AccessorUtilities from '~/lib/utils/accessor';
import initProjectSelectDropdown from '~/project_select'; import initProjectSelectDropdown from '~/project_select';
import initServerlessSurveyBanner from '~/serverless/survey_banner'; import initServerlessSurveyBanner from '~/serverless/survey_banner';
import { deprecatedCreateFlash as Flash } from '../flash'; import createFlash from '../flash';
import Poll from '../lib/utils/poll'; import Poll from '../lib/utils/poll';
import { s__, sprintf } from '../locale'; import { s__, sprintf } from '../locale';
import PersistentUserCallout from '../persistent_user_callout'; import PersistentUserCallout from '../persistent_user_callout';
...@@ -298,7 +298,9 @@ export default class Clusters { ...@@ -298,7 +298,9 @@ export default class Clusters {
} }
static handleError() { static handleError() {
Flash(s__('ClusterIntegration|Something went wrong on our end.')); createFlash({
message: s__('ClusterIntegration|Something went wrong on our end.'),
});
} }
handleClusterStatusSuccess(data) { handleClusterStatusSuccess(data) {
...@@ -340,7 +342,11 @@ export default class Clusters { ...@@ -340,7 +342,11 @@ export default class Clusters {
appList: appTitles.join(', '), appList: appTitles.join(', '),
}, },
); );
Flash(text, 'notice', this.successApplicationContainer); createFlash({
message: text,
type: 'notice',
parent: this.successApplicationContainer,
});
} }
} }
......
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
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 { parseIntPagination, normalizeHeaders } from '~/lib/utils/common_utils'; import { parseIntPagination, normalizeHeaders } from '~/lib/utils/common_utils';
import Poll from '~/lib/utils/poll'; import Poll from '~/lib/utils/poll';
...@@ -64,7 +64,9 @@ export const fetchClusters = ({ state, commit, dispatch }) => { ...@@ -64,7 +64,9 @@ export const fetchClusters = ({ state, commit, dispatch }) => {
commit(types.SET_LOADING_CLUSTERS, false); commit(types.SET_LOADING_CLUSTERS, false);
commit(types.SET_LOADING_NODES, false); commit(types.SET_LOADING_NODES, false);
flash(__('Clusters|An error occurred while loading clusters')); createFlash({
message: __('Clusters|An error occurred while loading clusters'),
});
dispatch('reportSentryError', { error: response, tag: 'fetchClustersErrorCallback' }); dispatch('reportSentryError', { error: response, tag: 'fetchClustersErrorCallback' });
}, },
......
import { deprecatedCreateFlash as flash } from '~/flash'; import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import service from '../services/contributors_service'; import service from '../services/contributors_service';
import * as types from './mutation_types'; import * as types from './mutation_types';
...@@ -13,5 +13,9 @@ export const fetchChartData = ({ commit }, endpoint) => { ...@@ -13,5 +13,9 @@ export const fetchChartData = ({ commit }, endpoint) => {
commit(types.SET_CHART_DATA, data); commit(types.SET_CHART_DATA, data);
commit(types.SET_LOADING_STATE, false); commit(types.SET_LOADING_STATE, false);
}) })
.catch(() => flash(__('An error occurred while loading chart data'))); .catch(() =>
createFlash({
message: __('An error occurred while loading chart data'),
}),
);
}; };
import Vue from 'vue'; import Vue from 'vue';
import { deprecatedCreateFlash as Flash } from '~/flash'; import createFlash from '~/flash';
import GkeMachineTypeDropdown from './components/gke_machine_type_dropdown.vue'; import GkeMachineTypeDropdown from './components/gke_machine_type_dropdown.vue';
import GkeProjectIdDropdown from './components/gke_project_id_dropdown.vue'; import GkeProjectIdDropdown from './components/gke_project_id_dropdown.vue';
import GkeSubmitButton from './components/gke_submit_button.vue'; import GkeSubmitButton from './components/gke_submit_button.vue';
...@@ -59,7 +59,9 @@ const mountGkeSubmitButton = () => { ...@@ -59,7 +59,9 @@ const mountGkeSubmitButton = () => {
}; };
const gkeDropdownErrorHandler = () => { const gkeDropdownErrorHandler = () => {
Flash(CONSTANTS.GCP_API_ERROR); createFlash({
message: CONSTANTS.GCP_API_ERROR,
});
}; };
const initializeGapiClient = (gapi) => () => { const initializeGapiClient = (gapi) => () => {
......
<script> <script>
import { GlLoadingIcon, GlIcon } from '@gitlab/ui'; import { GlLoadingIcon, GlIcon } from '@gitlab/ui';
import { deprecatedCreateFlash as Flash } from '~/flash'; import createFlash from '~/flash';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import NavigationTabs from '~/vue_shared/components/navigation_tabs.vue'; import NavigationTabs from '~/vue_shared/components/navigation_tabs.vue';
import eventHub from '../eventhub'; import eventHub from '../eventhub';
...@@ -93,14 +93,20 @@ export default { ...@@ -93,14 +93,20 @@ export default {
.catch(() => { .catch(() => {
this.isLoading = false; this.isLoading = false;
this.store.keys = {}; this.store.keys = {};
return new Flash(s__('DeployKeys|Error getting deploy keys')); return createFlash({
message: s__('DeployKeys|Error getting deploy keys'),
});
}); });
}, },
enableKey(deployKey) { enableKey(deployKey) {
this.service this.service
.enableKey(deployKey.id) .enableKey(deployKey.id)
.then(this.fetchKeys) .then(this.fetchKeys)
.catch(() => new Flash(s__('DeployKeys|Error enabling deploy key'))); .catch(() =>
createFlash({
message: s__('DeployKeys|Error enabling deploy key'),
}),
);
}, },
confirmRemoveKey(deployKey, callback) { confirmRemoveKey(deployKey, callback) {
const hideModal = () => { const hideModal = () => {
...@@ -112,7 +118,11 @@ export default { ...@@ -112,7 +118,11 @@ export default {
.disableKey(deployKey.id) .disableKey(deployKey.id)
.then(this.fetchKeys) .then(this.fetchKeys)
.then(hideModal) .then(hideModal)
.catch(() => new Flash(s__('DeployKeys|Error removing deploy key'))); .catch(() =>
createFlash({
message: s__('DeployKeys|Error removing deploy key'),
}),
);
}; };
this.cancel = hideModal; this.cancel = hideModal;
this.confirmModalVisible = true; this.confirmModalVisible = true;
......
import $ from 'jquery'; import $ from 'jquery';
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 { __ } from '~/locale'; import { __ } from '~/locale';
import FilesCommentButton from './files_comment_button'; import FilesCommentButton from './files_comment_button';
...@@ -77,7 +77,11 @@ export default class Diff { ...@@ -77,7 +77,11 @@ export default class Diff {
axios axios
.get(link, { params }) .get(link, { params })
.then(({ data }) => $target.parent().replaceWith(data)) .then(({ data }) => $target.parent().replaceWith(data))
.catch(() => flash(__('An error occurred while loading diff'))); .catch(() =>
createFlash({
message: __('An error occurred while loading diff'),
}),
);
} }
openAnchoredDiff(cb) { openAnchoredDiff(cb) {
......
<script> <script>
import { GlBadge, GlButton, GlModalDirective, GlTab, GlTabs } from '@gitlab/ui'; import { GlBadge, GlButton, GlModalDirective, GlTab, GlTabs } from '@gitlab/ui';
import { deprecatedCreateFlash as Flash } from '~/flash'; import createFlash from '~/flash';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
import environmentsMixin from '../mixins/environments_mixin'; import environmentsMixin from '../mixins/environments_mixin';
...@@ -89,7 +89,9 @@ export default { ...@@ -89,7 +89,9 @@ export default {
.then((response) => this.store.setfolderContent(folder, response.data.environments)) .then((response) => this.store.setfolderContent(folder, response.data.environments))
.then(() => this.store.updateEnvironmentProp(folder, 'isLoadingFolderContent', false)) .then(() => this.store.updateEnvironmentProp(folder, 'isLoadingFolderContent', false))
.catch(() => { .catch(() => {
Flash(s__('Environments|An error occurred while fetching the environments.')); createFlash({
message: s__('Environments|An error occurred while fetching the environments.'),
});
this.store.updateEnvironmentProp(folder, 'isLoadingFolderContent', false); this.store.updateEnvironmentProp(folder, 'isLoadingFolderContent', false);
}); });
}, },
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
*/ */
import { isEqual, isFunction, omitBy } from 'lodash'; import { isEqual, isFunction, omitBy } from 'lodash';
import Visibility from 'visibilityjs'; import Visibility from 'visibilityjs';
import { deprecatedCreateFlash as Flash } from '../../flash'; import createFlash from '../../flash';
import { getParameterByName } from '../../lib/utils/common_utils'; import { getParameterByName } from '../../lib/utils/common_utils';
import Poll from '../../lib/utils/poll'; import Poll from '../../lib/utils/poll';
import { s__ } from '../../locale'; import { s__ } from '../../locale';
...@@ -94,7 +94,9 @@ export default { ...@@ -94,7 +94,9 @@ export default {
errorCallback() { errorCallback() {
this.isLoading = false; this.isLoading = false;
Flash(s__('Environments|An error occurred while fetching the environments.')); createFlash({
message: s__('Environments|An error occurred while fetching the environments.'),
});
}, },
postAction({ postAction({
...@@ -109,7 +111,9 @@ export default { ...@@ -109,7 +111,9 @@ export default {
.then(() => this.fetchEnvironments()) .then(() => this.fetchEnvironments())
.catch((err) => { .catch((err) => {
this.isLoading = false; this.isLoading = false;
Flash(isFunction(errorMessage) ? errorMessage(err.response.data) : errorMessage); createFlash({
message: isFunction(errorMessage) ? errorMessage(err.response.data) : errorMessage,
});
}); });
} }
}, },
...@@ -163,7 +167,9 @@ export default { ...@@ -163,7 +167,9 @@ export default {
window.location.href = url.join('/'); window.location.href = url.join('/');
}) })
.catch(() => { .catch(() => {
Flash(errorMessage); createFlash({
message: errorMessage,
});
}); });
}, },
......
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 { __ } from '../locale'; import { __ } from '../locale';
...@@ -10,10 +10,10 @@ export function dismiss(endpoint, highlightId) { ...@@ -10,10 +10,10 @@ export function dismiss(endpoint, highlightId) {
feature_name: highlightId, feature_name: highlightId,
}) })
.catch(() => .catch(() =>
Flash( createFlash({
__( message: __(
'An error occurred while dismissing the feature highlight. Refresh the page and try dismissing again.', 'An error occurred while dismissing the feature highlight. Refresh the page and try dismissing again.',
), ),
), }),
); );
} }
...@@ -4,7 +4,7 @@ import * as Emoji from '~/emoji'; ...@@ -4,7 +4,7 @@ import * as Emoji from '~/emoji';
import FilteredSearchContainer from '~/filtered_search/container'; import FilteredSearchContainer from '~/filtered_search/container';
import DropdownUtils from '~/filtered_search/dropdown_utils'; import DropdownUtils from '~/filtered_search/dropdown_utils';
import FilteredSearchVisualTokens from '~/filtered_search/filtered_search_visual_tokens'; import FilteredSearchVisualTokens from '~/filtered_search/filtered_search_visual_tokens';
import { deprecatedCreateFlash as Flash } from '~/flash'; import createFlash from '~/flash';
import AjaxCache from '~/lib/utils/ajax_cache'; import AjaxCache from '~/lib/utils/ajax_cache';
import UsersCache from '~/lib/utils/users_cache'; import UsersCache from '~/lib/utils/users_cache';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -83,7 +83,11 @@ export default class VisualTokenValue { ...@@ -83,7 +83,11 @@ export default class VisualTokenValue {
matchingLabel.text_color, matchingLabel.text_color,
); );
}) })
.catch(() => new Flash(__('An error occurred while fetching label colors.'))); .catch(() =>
createFlash({
message: __('An error occurred while fetching label colors.'),
}),
);
} }
updateEpicLabel(tokenValueContainer) { updateEpicLabel(tokenValueContainer) {
...@@ -105,7 +109,11 @@ export default class VisualTokenValue { ...@@ -105,7 +109,11 @@ export default class VisualTokenValue {
VisualTokenValue.replaceEpicTitle(tokenValueContainer, matchingEpic.title, matchingEpic.id); VisualTokenValue.replaceEpicTitle(tokenValueContainer, matchingEpic.title, matchingEpic.id);
}) })
.catch(() => new Flash(__('An error occurred while adding formatted title for epic'))); .catch(() =>
createFlash({
message: __('An error occurred while adding formatted title for epic'),
}),
);
} }
static replaceEpicTitle(tokenValueContainer, epicTitle, epicId) { static replaceEpicTitle(tokenValueContainer, epicTitle, epicId) {
......
import { deprecatedCreateFlash as flash } from '~/flash'; import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import fetchGroupPathAvailability from '~/pages/groups/new/fetch_group_path_availability'; import fetchGroupPathAvailability from '~/pages/groups/new/fetch_group_path_availability';
import { slugify } from './lib/utils/text_utility'; import { slugify } from './lib/utils/text_utility';
...@@ -61,11 +61,15 @@ export default class Group { ...@@ -61,11 +61,15 @@ export default class Group {
element.value = suggestedSlug; element.value = suggestedSlug;
}); });
} else if (exists && !suggests.length) { } else if (exists && !suggests.length) {
flash(__('Unable to suggest a path. Please refresh and try again.')); createFlash({
message: __('Unable to suggest a path. Please refresh and try again.'),
});
} }
}) })
.catch(() => .catch(() =>
flash(__('An error occurred while checking group path. Please refresh and try again.')), createFlash({
message: __('An error occurred while checking group path. Please refresh and try again.'),
}),
); );
} }
} }
import $ from 'jquery'; import $ from 'jquery';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { fixTitle, hide } from '~/tooltips'; import { fixTitle, hide } from '~/tooltips';
import { deprecatedCreateFlash as flash } from './flash'; import createFlash from './flash';
import axios from './lib/utils/axios_utils'; import axios from './lib/utils/axios_utils';
const tooltipTitles = { const tooltipTitles = {
...@@ -30,7 +30,11 @@ export default class GroupLabelSubscription { ...@@ -30,7 +30,11 @@ export default class GroupLabelSubscription {
this.toggleSubscriptionButtons(); this.toggleSubscriptionButtons();
this.$unsubscribeButtons.removeAttr('data-url'); this.$unsubscribeButtons.removeAttr('data-url');
}) })
.catch(() => flash(__('There was an error when unsubscribing from this label.'))); .catch(() =>
createFlash({
message: __('There was an error when unsubscribing from this label.'),
}),
);
} }
subscribe(event) { subscribe(event) {
...@@ -45,7 +49,11 @@ export default class GroupLabelSubscription { ...@@ -45,7 +49,11 @@ export default class GroupLabelSubscription {
.post(url) .post(url)
.then(() => GroupLabelSubscription.setNewTooltip($btn)) .then(() => GroupLabelSubscription.setNewTooltip($btn))
.then(() => this.toggleSubscriptionButtons()) .then(() => this.toggleSubscriptionButtons())
.catch(() => flash(__('There was an error when subscribing to this label.'))); .catch(() =>
createFlash({
message: __('There was an error when subscribing to this label.'),
}),
);
} }
toggleSubscriptionButtons() { toggleSubscriptionButtons() {
......
...@@ -8,7 +8,7 @@ import { ...@@ -8,7 +8,7 @@ import {
} from '~/editor/constants'; } from '~/editor/constants';
import EditorLite from '~/editor/editor_lite'; import EditorLite from '~/editor/editor_lite';
import { EditorWebIdeExtension } from '~/editor/extensions/editor_lite_webide_ext'; import { EditorWebIdeExtension } from '~/editor/extensions/editor_lite_webide_ext';
import { deprecatedCreateFlash as flash } from '~/flash'; import createFlash from '~/flash';
import ModelManager from '~/ide/lib/common/model_manager'; import ModelManager from '~/ide/lib/common/model_manager';
import { defaultDiffEditorOptions, defaultEditorOptions } from '~/ide/lib/editor_options'; import { defaultDiffEditorOptions, defaultEditorOptions } from '~/ide/lib/editor_options';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -250,14 +250,14 @@ export default { ...@@ -250,14 +250,14 @@ export default {
this.createEditorInstance(); this.createEditorInstance();
}) })
.catch((err) => { .catch((err) => {
flash( createFlash({
__('Error setting up editor. Please try again.'), message: __('Error setting up editor. Please try again.'),
'alert', type: 'alert',
document, parent: document,
null, actionConfig: null,
false, fadeTransition: false,
true, addBodyClass: true,
); });
throw err; throw err;
}); });
}, },
......
...@@ -5,7 +5,7 @@ import waitForPromises from 'helpers/wait_for_promises'; ...@@ -5,7 +5,7 @@ import waitForPromises from 'helpers/wait_for_promises';
import { MAX_REQUESTS } from '~/clusters_list/constants'; import { MAX_REQUESTS } from '~/clusters_list/constants';
import * as actions from '~/clusters_list/store/actions'; import * as actions from '~/clusters_list/store/actions';
import * as types from '~/clusters_list/store/mutation_types'; import * as types from '~/clusters_list/store/mutation_types';
import { deprecatedCreateFlash as flashError } 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';
import { apiData } from '../mock_data'; import { apiData } from '../mock_data';
...@@ -101,7 +101,9 @@ describe('Clusters store actions', () => { ...@@ -101,7 +101,9 @@ describe('Clusters store actions', () => {
}, },
], ],
() => { () => {
expect(flashError).toHaveBeenCalledWith(expect.stringMatching('error')); expect(createFlash).toHaveBeenCalledWith({
message: expect.stringMatching('error'),
});
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 '~/contributors/stores/actions'; import * as actions from '~/contributors/stores/actions';
import * as types from '~/contributors/stores/mutation_types'; import * as types from '~/contributors/stores/mutation_types';
import { deprecatedCreateFlash as flashError } from '~/flash'; import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
jest.mock('~/flash.js'); jest.mock('~/flash.js');
...@@ -47,7 +47,9 @@ describe('Contributors store actions', () => { ...@@ -47,7 +47,9 @@ describe('Contributors store actions', () => {
[{ type: types.SET_LOADING_STATE, payload: true }], [{ type: types.SET_LOADING_STATE, payload: true }],
[], [],
() => { () => {
expect(flashError).toHaveBeenCalledWith(expect.stringMatching('error')); expect(createFlash).toHaveBeenCalledWith({
message: expect.stringMatching('error'),
});
mock.restore(); mock.restore();
done(); done();
}, },
......
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import { dismiss } from '~/feature_highlight/feature_highlight_helper'; import { dismiss } from '~/feature_highlight/feature_highlight_helper';
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 httpStatusCodes from '~/lib/utils/http_status'; import httpStatusCodes from '~/lib/utils/http_status';
...@@ -32,9 +32,10 @@ describe('feature highlight helper', () => { ...@@ -32,9 +32,10 @@ describe('feature highlight helper', () => {
await dismiss(endpoint, highlightId); await dismiss(endpoint, highlightId);
expect(Flash).toHaveBeenCalledWith( expect(createFlash).toHaveBeenCalledWith({
'An error occurred while dismissing the feature highlight. Refresh the page and try dismissing again.', message:
); 'An error occurred while dismissing the feature highlight. Refresh the page and try dismissing again.',
});
}); });
}); });
}); });
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