Skip to content
Snippets Groups Projects
Commit 73aec068 authored by E'zeki&el Kigbo's avatar E'zeki&el Kigbo :speech_balloon:
Browse files

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
No related branches found
No related tags found
No related merge requests found
Showing
with 146 additions and 54 deletions
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import { __ } from '~/locale';
import axios from '../lib/utils/axios_utils';
import { buildApiUrl } from './api_utils';
Loading
Loading
@@ -52,7 +52,11 @@ export function getUserProjects(userId, query, options, callback) {
params: { ...defaults, ...options },
})
.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 }) {
Loading
Loading
Loading
Loading
@@ -7,7 +7,7 @@ import { uniq } from 'lodash';
import * as Emoji from '~/emoji';
import { scrollToElement } from '~/lib/utils/common_utils';
import { dispose, fixTitle } from '~/tooltips';
import { deprecatedCreateFlash as flash } from './flash';
import createFlash from './flash';
import axios from './lib/utils/axios_utils';
import { isInVueNoteablePage } from './lib/utils/dom_utils';
import { __ } from './locale';
Loading
Loading
@@ -488,7 +488,11 @@ export class AwardsHandler {
callback();
}
})
.catch(() => flash(__('Something went wrong on our end.')));
.catch(() =>
createFlash({
message: __('Something went wrong on our end.'),
}),
);
}
 
findEmojiIcon(votesBlock, emoji) {
Loading
Loading
import { isEmpty } from 'lodash';
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import { scrollToElement } from '~/lib/utils/common_utils';
import { __ } from '~/locale';
import { CHANGES_TAB, DISCUSSION_TAB, SHOW_TAB } from '../../../constants';
Loading
Loading
@@ -18,7 +18,9 @@ export const addDraftToDiscussion = ({ commit }, { endpoint, data }) =>
return res;
})
.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 }) =>
Loading
Loading
@@ -30,7 +32,9 @@ export const createNewDraft = ({ commit }, { endpoint, data }) =>
return res;
})
.catch(() => {
flash(__('An error occurred adding a new draft.'));
createFlash({
message: __('An error occurred adding a new draft.'),
});
});
 
export const deleteDraft = ({ commit, getters }, draft) =>
Loading
Loading
@@ -39,7 +43,11 @@ export const deleteDraft = ({ commit, getters }, draft) =>
.then(() => {
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 }) =>
service
Loading
Loading
@@ -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) => {
commit(types.REQUEST_PUBLISH_DRAFT, draftId);
Loading
Loading
@@ -111,7 +123,11 @@ export const updateDraft = (
.then((res) => res.data)
.then((data) => commit(types.RECEIVE_DRAFT_UPDATE_SUCCESS, data))
.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) => {
Loading
Loading
import $ from 'jquery';
import { once, countBy } from 'lodash';
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import { darkModeEnabled } from '~/lib/utils/color_utils';
import { __, sprintf } from '~/locale';
 
Loading
Loading
@@ -78,7 +78,9 @@ function importMermaidModule() {
mermaidModule = initMermaid(mermaid);
})
.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
console.error(err);
});
Loading
Loading
@@ -205,7 +207,9 @@ function renderMermaids($els) {
});
})
.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
console.error(err);
});
Loading
Loading
/* eslint-disable func-names */
 
import $ from 'jquery';
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils';
import { __ } from '~/locale';
 
Loading
Loading
@@ -79,7 +79,11 @@ MarkdownPreview.prototype.fetchMarkdownPreview = function (text, url, success) {
};
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) {
Loading
Loading
import { __ } from '~/locale';
import { deprecatedCreateFlash as Flash } from '../flash';
import createFlash from '../flash';
import BalsamiqViewer from './balsamiq/balsamiq_viewer';
 
function onError() {
const flash = new Flash(__('Balsamiq file could not be loaded.'));
const flash = createFlash({
message: __('Balsamiq file could not be loaded.'),
});
 
return flash;
}
Loading
Loading
Loading
Loading
@@ -5,7 +5,7 @@ import initPopover from '~/blob/suggest_gitlab_ci_yml';
import { __ } from '~/locale';
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 DockerfileSelector from './template_selectors/dockerfile_selector';
Loading
Loading
@@ -155,7 +155,11 @@ export default class FileTemplateMediator {
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() {
Loading
Loading
import { SwaggerUIBundle } from 'swagger-ui-dist';
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import { __ } from '~/locale';
 
export default () => {
Loading
Loading
@@ -13,7 +13,9 @@ export default () => {
});
})
.catch((error) => {
flash(__('Something went wrong while initializing the OpenAPI viewer'));
createFlash({
message: __('Something went wrong while initializing the OpenAPI viewer'),
});
throw error;
});
};
Loading
Loading
@@ -8,7 +8,7 @@ import {
} from '~/performance/constants';
import { performanceMarkAndMeasure } from '~/performance/utils';
import { fixTitle } from '~/tooltips';
import { deprecatedCreateFlash as Flash } from '../../flash';
import createFlash from '../../flash';
import axios from '../../lib/utils/axios_utils';
import { handleLocationHash } from '../../lib/utils/common_utils';
import eventHub from '../../notes/event_hub';
Loading
Loading
@@ -38,7 +38,9 @@ export const handleBlobRichViewer = (viewer, type) => {
loadRichBlobViewer(type)
.then((module) => module?.default(viewer))
.catch((error) => {
Flash(__('Error loading file viewer.'));
createFlash({
message: __('Error loading file viewer.'),
});
throw error;
});
};
Loading
Loading
@@ -182,7 +184,11 @@ export default class BlobViewer {
],
});
})
.catch(() => new Flash(__('Error loading viewer')));
.catch(() =>
createFlash({
message: __('Error loading viewer'),
}),
);
}
 
static loadViewer(viewerParam) {
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@
import $ from 'jquery';
import store from '~/boards/stores';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import axios from '~/lib/utils/axios_utils';
import { __ } from '~/locale';
Loading
Loading
@@ -53,7 +53,9 @@ export default function initNewListDropdown() {
data(term, callback) {
const reqFailed = () => {
$dropdownToggle.data('bs.dropdown').hide();
flash(__('Error fetching labels.'));
createFlash({
message: __('Error fetching labels.'),
});
};
 
if (store.getters.shouldUseGraphQL) {
Loading
Loading
/* eslint-disable class-methods-use-this */
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import { __ } from '~/locale';
import boardsStore from '../stores/boards_store';
import ListAssignee from './assignee';
Loading
Loading
@@ -127,7 +127,11 @@ class List {
moveBeforeId,
moveAfterId,
})
.catch(() => flash(__('Something went wrong while moving issues.')));
.catch(() =>
createFlash({
message: __('Something went wrong while moving issues.'),
}),
);
}
 
updateIssueLabel(issue, listFrom, moveBeforeId, moveAfterId) {
Loading
Loading
@@ -145,7 +149,11 @@ class List {
moveBeforeId,
moveAfterId,
})
.catch(() => flash(__('Something went wrong while moving issues.')));
.catch(() =>
createFlash({
message: __('Something went wrong while moving issues.'),
}),
);
}
 
findIssue(id) {
Loading
Loading
Loading
Loading
@@ -4,7 +4,7 @@ import Vue from 'vue';
import AccessorUtilities from '~/lib/utils/accessor';
import initProjectSelectDropdown from '~/project_select';
import initServerlessSurveyBanner from '~/serverless/survey_banner';
import { deprecatedCreateFlash as Flash } from '../flash';
import createFlash from '../flash';
import Poll from '../lib/utils/poll';
import { s__, sprintf } from '../locale';
import PersistentUserCallout from '../persistent_user_callout';
Loading
Loading
@@ -298,7 +298,9 @@ export default class Clusters {
}
 
static handleError() {
Flash(s__('ClusterIntegration|Something went wrong on our end.'));
createFlash({
message: s__('ClusterIntegration|Something went wrong on our end.'),
});
}
 
handleClusterStatusSuccess(data) {
Loading
Loading
@@ -340,7 +342,11 @@ export default class Clusters {
appList: appTitles.join(', '),
},
);
Flash(text, 'notice', this.successApplicationContainer);
createFlash({
message: text,
type: 'notice',
parent: this.successApplicationContainer,
});
}
}
 
Loading
Loading
import * as Sentry from '@sentry/browser';
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils';
import { parseIntPagination, normalizeHeaders } from '~/lib/utils/common_utils';
import Poll from '~/lib/utils/poll';
Loading
Loading
@@ -64,7 +64,9 @@ export const fetchClusters = ({ state, commit, dispatch }) => {
 
commit(types.SET_LOADING_CLUSTERS, 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' });
},
Loading
Loading
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import { __ } from '~/locale';
import service from '../services/contributors_service';
import * as types from './mutation_types';
Loading
Loading
@@ -13,5 +13,9 @@ export const fetchChartData = ({ commit }, endpoint) => {
commit(types.SET_CHART_DATA, data);
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 { deprecatedCreateFlash as Flash } from '~/flash';
import createFlash from '~/flash';
import GkeMachineTypeDropdown from './components/gke_machine_type_dropdown.vue';
import GkeProjectIdDropdown from './components/gke_project_id_dropdown.vue';
import GkeSubmitButton from './components/gke_submit_button.vue';
Loading
Loading
@@ -59,7 +59,9 @@ const mountGkeSubmitButton = () => {
};
 
const gkeDropdownErrorHandler = () => {
Flash(CONSTANTS.GCP_API_ERROR);
createFlash({
message: CONSTANTS.GCP_API_ERROR,
});
};
 
const initializeGapiClient = (gapi) => () => {
Loading
Loading
<script>
import { GlLoadingIcon, GlIcon } from '@gitlab/ui';
import { deprecatedCreateFlash as Flash } from '~/flash';
import createFlash from '~/flash';
import { s__ } from '~/locale';
import NavigationTabs from '~/vue_shared/components/navigation_tabs.vue';
import eventHub from '../eventhub';
Loading
Loading
@@ -93,14 +93,20 @@ export default {
.catch(() => {
this.isLoading = false;
this.store.keys = {};
return new Flash(s__('DeployKeys|Error getting deploy keys'));
return createFlash({
message: s__('DeployKeys|Error getting deploy keys'),
});
});
},
enableKey(deployKey) {
this.service
.enableKey(deployKey.id)
.then(this.fetchKeys)
.catch(() => new Flash(s__('DeployKeys|Error enabling deploy key')));
.catch(() =>
createFlash({
message: s__('DeployKeys|Error enabling deploy key'),
}),
);
},
confirmRemoveKey(deployKey, callback) {
const hideModal = () => {
Loading
Loading
@@ -112,7 +118,11 @@ export default {
.disableKey(deployKey.id)
.then(this.fetchKeys)
.then(hideModal)
.catch(() => new Flash(s__('DeployKeys|Error removing deploy key')));
.catch(() =>
createFlash({
message: s__('DeployKeys|Error removing deploy key'),
}),
);
};
this.cancel = hideModal;
this.confirmModalVisible = true;
Loading
Loading
import $ from 'jquery';
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils';
import { __ } from '~/locale';
import FilesCommentButton from './files_comment_button';
Loading
Loading
@@ -77,7 +77,11 @@ export default class Diff {
axios
.get(link, { params })
.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) {
Loading
Loading
<script>
import { GlBadge, GlButton, GlModalDirective, GlTab, GlTabs } from '@gitlab/ui';
import { deprecatedCreateFlash as Flash } from '~/flash';
import createFlash from '~/flash';
import { s__ } from '~/locale';
import eventHub from '../event_hub';
import environmentsMixin from '../mixins/environments_mixin';
Loading
Loading
@@ -89,7 +89,9 @@ export default {
.then((response) => this.store.setfolderContent(folder, response.data.environments))
.then(() => this.store.updateEnvironmentProp(folder, 'isLoadingFolderContent', false))
.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);
});
},
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@
*/
import { isEqual, isFunction, omitBy } from 'lodash';
import Visibility from 'visibilityjs';
import { deprecatedCreateFlash as Flash } from '../../flash';
import createFlash from '../../flash';
import { getParameterByName } from '../../lib/utils/common_utils';
import Poll from '../../lib/utils/poll';
import { s__ } from '../../locale';
Loading
Loading
@@ -94,7 +94,9 @@ export default {
 
errorCallback() {
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({
Loading
Loading
@@ -109,7 +111,9 @@ export default {
.then(() => this.fetchEnvironments())
.catch((err) => {
this.isLoading = false;
Flash(isFunction(errorMessage) ? errorMessage(err.response.data) : errorMessage);
createFlash({
message: isFunction(errorMessage) ? errorMessage(err.response.data) : errorMessage,
});
});
}
},
Loading
Loading
@@ -163,7 +167,9 @@ export default {
window.location.href = url.join('/');
})
.catch(() => {
Flash(errorMessage);
createFlash({
message: errorMessage,
});
});
},
 
Loading
Loading
import { deprecatedCreateFlash as Flash } from '~/flash';
import createFlash from '~/flash';
import axios from '../lib/utils/axios_utils';
import { __ } from '../locale';
 
Loading
Loading
@@ -10,10 +10,10 @@ export function dismiss(endpoint, highlightId) {
feature_name: highlightId,
})
.catch(() =>
Flash(
__(
createFlash({
message: __(
'An error occurred while dismissing the feature highlight. Refresh the page and try dismissing again.',
),
),
}),
);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment