Commit c044eeae authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

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

Refactor(createFlash): use non-deprecated function

See merge request gitlab-org/gitlab!63867
parents 95af2964 a64d4eb5
import Vue from 'vue'; import Vue from 'vue';
import { deprecatedCreateFlash as flash } from '~/flash'; import createFlash from '~/flash';
import IdeRouter from '~/ide/ide_router_extension'; import IdeRouter from '~/ide/ide_router_extension';
import { joinPaths } from '~/lib/utils/url_utility'; import { joinPaths } from '~/lib/utils/url_utility';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -111,14 +111,14 @@ export const createRouter = (store, defaultBranch) => { ...@@ -111,14 +111,14 @@ export const createRouter = (store, defaultBranch) => {
} }
}) })
.catch((e) => { .catch((e) => {
flash( createFlash({
__('Error while loading the project data. Please try again.'), message: __('Error while loading the project data. Please try again.'),
'alert', type: 'alert',
document, parent: document,
null, actionConfig: null,
false, fadeTransition: false,
true, addBodyClass: true,
); });
throw e; throw e;
}); });
} }
......
import { escape } from 'lodash'; import { escape } from 'lodash';
import Vue from 'vue'; import Vue from 'vue';
import { deprecatedCreateFlash as flash } from '~/flash'; import createFlash from '~/flash';
import { visitUrl } from '~/lib/utils/url_utility'; import { visitUrl } from '~/lib/utils/url_utility';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import { import {
...@@ -36,16 +36,17 @@ export const createTempEntry = ( ...@@ -36,16 +36,17 @@ export const createTempEntry = (
const fullName = name.slice(-1) !== '/' && type === 'tree' ? `${name}/` : name; const fullName = name.slice(-1) !== '/' && type === 'tree' ? `${name}/` : name;
if (getters.entryExists(name)) { if (getters.entryExists(name)) {
flash( createFlash({
sprintf(__('The name "%{name}" is already taken in this directory.'), { message: sprintf(__('The name "%{name}" is already taken in this directory.'), {
name: name.split('/').pop(), name: name.split('/').pop(),
}), }),
'alert',
document, type: 'alert',
null, parent: document,
false, actionConfig: null,
true, fadeTransition: false,
); addBodyClass: true,
});
return undefined; return undefined;
} }
...@@ -284,14 +285,14 @@ export const getBranchData = ({ commit, state }, { projectId, branchId, force = ...@@ -284,14 +285,14 @@ export const getBranchData = ({ commit, state }, { projectId, branchId, force =
if (e.response.status === 404) { if (e.response.status === 404) {
reject(e); reject(e);
} else { } else {
flash( createFlash({
__('Error loading branch data. Please try again.'), message: __('Error loading branch data. Please try again.'),
'alert', type: 'alert',
document, parent: document,
null, actionConfig: null,
false, fadeTransition: false,
true, addBodyClass: true,
); });
reject( reject(
new Error( new Error(
......
import { escape } from 'lodash'; import { escape } from 'lodash';
import { deprecatedCreateFlash as flash } from '~/flash'; import createFlash from '~/flash';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import api from '../../../api'; import api from '../../../api';
import service from '../../services'; import service from '../../services';
...@@ -19,14 +19,14 @@ export const getProjectData = ({ commit, state }, { namespace, projectId, force ...@@ -19,14 +19,14 @@ export const getProjectData = ({ commit, state }, { namespace, projectId, force
resolve(data); resolve(data);
}) })
.catch(() => { .catch(() => {
flash( createFlash({
__('Error loading project data. Please try again.'), message: __('Error loading project data. Please try again.'),
'alert', type: 'alert',
document, parent: document,
null, actionConfig: null,
false, fadeTransition: false,
true, addBodyClass: true,
); });
reject(new Error(`Project not loaded ${namespace}/${projectId}`)); reject(new Error(`Project not loaded ${namespace}/${projectId}`));
}); });
} else { } else {
...@@ -45,7 +45,14 @@ export const refreshLastCommitData = ({ commit }, { projectId, branchId } = {}) ...@@ -45,7 +45,14 @@ export const refreshLastCommitData = ({ commit }, { projectId, branchId } = {})
}); });
}) })
.catch((e) => { .catch((e) => {
flash(__('Error loading last commit.'), 'alert', document, null, false, true); createFlash({
message: __('Error loading last commit.'),
type: 'alert',
parent: document,
actionConfig: null,
fadeTransition: false,
addBodyClass: true,
});
throw e; throw e;
}); });
......
import { deprecatedCreateFlash as flash } from '~/flash'; import createFlash from '~/flash';
import { addNumericSuffix } from '~/ide/utils'; import { addNumericSuffix } from '~/ide/utils';
import { sprintf, __ } from '~/locale'; import { sprintf, __ } from '~/locale';
import { leftSidebarViews } from '../../../constants'; import { leftSidebarViews } from '../../../constants';
...@@ -143,7 +143,14 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo ...@@ -143,7 +143,14 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo
commit(types.UPDATE_LOADING, false); commit(types.UPDATE_LOADING, false);
if (!data.short_id) { if (!data.short_id) {
flash(data.message, 'alert', document, null, false, true); createFlash({
message: data.message,
type: 'alert',
parent: document,
actionConfig: null,
fadeTransition: false,
addBodyClass: true,
});
return null; return null;
} }
......
import $ from 'jquery'; import $ from 'jquery';
import { difference, intersection, union } from 'lodash'; import { difference, intersection, union } 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 { __ } from './locale'; import { __ } from './locale';
...@@ -32,7 +32,9 @@ export default { ...@@ -32,7 +32,9 @@ export default {
onFormSubmitFailure() { onFormSubmitFailure() {
this.form.find('[type="submit"]').enable(); this.form.find('[type="submit"]').enable();
return new Flash(__('Issue update failed')); return createFlash({
message: __('Issue update failed'),
});
}, },
/** /**
......
import $ from 'jquery'; import $ from 'jquery';
import { joinPaths } from '~/lib/utils/url_utility'; import { joinPaths } from '~/lib/utils/url_utility';
import CreateMergeRequestDropdown from './create_merge_request_dropdown'; import CreateMergeRequestDropdown from './create_merge_request_dropdown';
import { deprecatedCreateFlash as flash } from './flash'; import createFlash from './flash';
import { EVENT_ISSUABLE_VUE_APP_CHANGE } from './issuable/constants'; import { EVENT_ISSUABLE_VUE_APP_CHANGE } from './issuable/constants';
import axios from './lib/utils/axios_utils'; import axios from './lib/utils/axios_utils';
import { addDelimiter } from './lib/utils/text_utility'; import { addDelimiter } from './lib/utils/text_utility';
...@@ -68,7 +68,9 @@ export default class Issue { ...@@ -68,7 +68,9 @@ export default class Issue {
this.createMergeRequestDropdown.checkAbilityToCreateBranch(); this.createMergeRequestDropdown.checkAbilityToCreateBranch();
} }
} else { } else {
flash(issueFailMessage); createFlash({
message: issueFailMessage,
});
} }
} }
...@@ -102,6 +104,10 @@ export default class Issue { ...@@ -102,6 +104,10 @@ export default class Issue {
$container.html(data.html); $container.html(data.html);
} }
}) })
.catch(() => flash(__('Failed to load related branches'))); .catch(() =>
createFlash({
message: __('Failed to load related branches'),
}),
);
} }
} }
...@@ -6,7 +6,7 @@ import { ...@@ -6,7 +6,7 @@ import {
GlSafeHtmlDirective as SafeHtml, GlSafeHtmlDirective as SafeHtml,
} from '@gitlab/ui'; } from '@gitlab/ui';
import { toNumber, omit } from 'lodash'; import { toNumber, omit } 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 { import {
scrollToElement, scrollToElement,
...@@ -265,7 +265,9 @@ export default { ...@@ -265,7 +265,9 @@ export default {
}) })
.catch(() => { .catch(() => {
this.loading = false; this.loading = false;
return flash(__('An error occurred while loading issues')); return createFlash({
message: __('An error occurred while loading issues'),
});
}); });
}, },
getQueryObject() { getQueryObject() {
......
import Visibility from 'visibilityjs'; import Visibility from 'visibilityjs';
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 { setFaviconOverlay, resetFavicon } from '~/lib/utils/favicon'; import { setFaviconOverlay, resetFavicon } from '~/lib/utils/favicon';
import httpStatusCodes from '~/lib/utils/http_status'; import httpStatusCodes from '~/lib/utils/http_status';
...@@ -99,7 +99,9 @@ export const receiveJobSuccess = ({ commit }, data = {}) => { ...@@ -99,7 +99,9 @@ export const receiveJobSuccess = ({ commit }, data = {}) => {
}; };
export const receiveJobError = ({ commit }) => { export const receiveJobError = ({ commit }) => {
commit(types.RECEIVE_JOB_ERROR); commit(types.RECEIVE_JOB_ERROR);
flash(__('An error occurred while fetching the job.')); createFlash({
message: __('An error occurred while fetching the job.'),
});
resetFavicon(); resetFavicon();
}; };
...@@ -197,11 +199,15 @@ export const stopPollingTrace = ({ state, commit }) => { ...@@ -197,11 +199,15 @@ export const stopPollingTrace = ({ state, commit }) => {
export const receiveTraceSuccess = ({ commit }, log) => commit(types.RECEIVE_TRACE_SUCCESS, log); export const receiveTraceSuccess = ({ commit }, log) => commit(types.RECEIVE_TRACE_SUCCESS, log);
export const receiveTraceError = ({ dispatch }) => { export const receiveTraceError = ({ dispatch }) => {
dispatch('stopPollingTrace'); dispatch('stopPollingTrace');
flash(__('An error occurred while fetching the job log.')); createFlash({
message: __('An error occurred while fetching the job log.'),
});
}; };
export const receiveTraceUnauthorizedError = ({ dispatch }) => { export const receiveTraceUnauthorizedError = ({ dispatch }) => {
dispatch('stopPollingTrace'); dispatch('stopPollingTrace');
flash(__('The current user is not authorized to access the job log.')); createFlash({
message: __('The current user is not authorized to access the job log.'),
});
}; };
/** /**
* When the user clicks a collapsible line in the job * When the user clicks a collapsible line in the job
...@@ -240,7 +246,9 @@ export const receiveJobsForStageSuccess = ({ commit }, data) => ...@@ -240,7 +246,9 @@ export const receiveJobsForStageSuccess = ({ commit }, data) =>
commit(types.RECEIVE_JOBS_FOR_STAGE_SUCCESS, data); commit(types.RECEIVE_JOBS_FOR_STAGE_SUCCESS, data);
export const receiveJobsForStageError = ({ commit }) => { export const receiveJobsForStageError = ({ commit }) => {
commit(types.RECEIVE_JOBS_FOR_STAGE_ERROR); commit(types.RECEIVE_JOBS_FOR_STAGE_ERROR);
flash(__('An error occurred while fetching the jobs.')); createFlash({
message: __('An error occurred while fetching the jobs.'),
});
}; };
export const triggerManualJob = ({ state }, variables) => { export const triggerManualJob = ({ state }, variables) => {
...@@ -254,5 +262,9 @@ export const triggerManualJob = ({ state }, variables) => { ...@@ -254,5 +262,9 @@ export const triggerManualJob = ({ state }, variables) => {
.post(state.job.status.action.path, { .post(state.job.status.action.path, {
job_variables_attributes: parsedVariables, job_variables_attributes: parsedVariables,
}) })
.catch(() => flash(__('An error occurred while triggering the job.'))); .catch(() =>
createFlash({
message: __('An error occurred while triggering the job.'),
}),
);
}; };
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
import $ from 'jquery'; import $ from 'jquery';
import Sortable from 'sortablejs'; import Sortable from 'sortablejs';
import { dispose } from '~/tooltips'; import { dispose } 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 { __ } from './locale'; import { __ } from './locale';
...@@ -111,7 +111,11 @@ export default class LabelManager { ...@@ -111,7 +111,11 @@ export default class LabelManager {
} }
onPrioritySortUpdate() { onPrioritySortUpdate() {
this.savePrioritySort().catch(() => flash(this.errorMessage)); this.savePrioritySort().catch(() =>
createFlash({
message: this.errorMessage,
}),
);
} }
savePrioritySort() { savePrioritySort() {
...@@ -123,7 +127,9 @@ export default class LabelManager { ...@@ -123,7 +127,9 @@ export default class LabelManager {
rollbackLabelPosition($label, originalAction) { rollbackLabelPosition($label, originalAction) {
const action = originalAction === 'remove' ? 'add' : 'remove'; const action = originalAction === 'remove' ? 'add' : 'remove';
this.toggleLabelPriority($label, action, false); this.toggleLabelPriority($label, action, false);
flash(this.errorMessage); createFlash({
message: this.errorMessage,
});
} }
getSortedLabelsIds() { getSortedLabelsIds() {
......
...@@ -8,7 +8,7 @@ import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown'; ...@@ -8,7 +8,7 @@ import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
import { isScopedLabel } from '~/lib/utils/common_utils'; import { isScopedLabel } from '~/lib/utils/common_utils';
import boardsStore from './boards/stores/boards_store'; import boardsStore from './boards/stores/boards_store';
import CreateLabelDropdown from './create_label'; import CreateLabelDropdown from './create_label';
import { deprecatedCreateFlash as flash } from './flash'; import createFlash from './flash';
import IssuableBulkUpdateActions from './issuable_bulk_update_actions'; import IssuableBulkUpdateActions from './issuable_bulk_update_actions';
import axios from './lib/utils/axios_utils'; import axios from './lib/utils/axios_utils';
import { sprintf, __ } from './locale'; import { sprintf, __ } from './locale';
...@@ -148,7 +148,11 @@ export default class LabelsSelect { ...@@ -148,7 +148,11 @@ export default class LabelsSelect {
container: 'body', container: 'body',
}); });
}) })
.catch(() => flash(__('Error saving label update.'))); .catch(() =>
createFlash({
message: __('Error saving label update.'),
}),
);
}; };
initDeprecatedJQueryDropdown($dropdown, { initDeprecatedJQueryDropdown($dropdown, {
showMenuAbove, showMenuAbove,
...@@ -183,7 +187,11 @@ export default class LabelsSelect { ...@@ -183,7 +187,11 @@ export default class LabelsSelect {
$dropdown.data('deprecatedJQueryDropdown').positionMenuAbove(); $dropdown.data('deprecatedJQueryDropdown').positionMenuAbove();
} }
}) })
.catch(() => flash(__('Error fetching labels.'))); .catch(() =>
createFlash({
message: __('Error fetching labels.'),
}),
);
}, },
renderRow(label) { renderRow(label) {
let colorEl; let colorEl;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { GlButton } from '@gitlab/ui'; import { GlButton } from '@gitlab/ui';
import { debounce } from 'lodash'; import { debounce } from 'lodash';
import { mapActions } from 'vuex'; import { mapActions } from 'vuex';
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 { INTERACTIVE_RESOLVE_MODE } from '../constants'; import { INTERACTIVE_RESOLVE_MODE } from '../constants';
...@@ -75,7 +75,9 @@ export default { ...@@ -75,7 +75,9 @@ export default {
}, },
) )
.catch(() => { .catch(() => {
flash(__('An error occurred while loading the file')); createFlash({
message: __('An error occurred while loading the file'),
});
}); });
}, },
saveDiffResolution() { saveDiffResolution() {
......
...@@ -8,7 +8,7 @@ import createEventHub from '~/helpers/event_hub_factory'; ...@@ -8,7 +8,7 @@ import createEventHub from '~/helpers/event_hub_factory';
import initAddContextCommitsTriggers from './add_context_commits_modal'; import initAddContextCommitsTriggers from './add_context_commits_modal';
import BlobForkSuggestion from './blob/blob_fork_suggestion'; import BlobForkSuggestion from './blob/blob_fork_suggestion';
import Diff from './diff'; import Diff from './diff';
import { deprecatedCreateFlash as flash } from './flash'; import createFlash from './flash';
import initChangesDropdown from './init_changes_dropdown'; import initChangesDropdown from './init_changes_dropdown';
import axios from './lib/utils/axios_utils'; import axios from './lib/utils/axios_utils';
import { import {
...@@ -345,7 +345,9 @@ export default class MergeRequestTabs { ...@@ -345,7 +345,9 @@ export default class MergeRequestTabs {
}) })
.catch(() => { .catch(() => {
this.toggleLoading(false); this.toggleLoading(false);
flash(__('An error occurred while fetching this tab.')); createFlash({
message: __('An error occurred while fetching this tab.'),
});
}); });
} }
...@@ -446,7 +448,9 @@ export default class MergeRequestTabs { ...@@ -446,7 +448,9 @@ export default class MergeRequestTabs {
}) })
.catch(() => { .catch(() => {
this.toggleLoading(false); this.toggleLoading(false);
flash(__('An error occurred while fetching this tab.')); createFlash({
message: __('An error occurred while fetching this tab.'),
});
}); });
} }
......
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';
...@@ -39,7 +39,11 @@ export default class Milestone { ...@@ -39,7 +39,11 @@ export default class Milestone {
$(tabElId).html(data.html); $(tabElId).html(data.html);
$target.addClass('is-loaded'); $target.addClass('is-loaded');
}) })
.catch(() => flash(__('Error loading milestone tab'))); .catch(() =>
createFlash({
message: __('Error loading milestone tab'),
}),
);
} }
} }
} }
import $ from 'jquery'; import $ from 'jquery';
import { debounce } from 'lodash'; import { debounce } 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 { __ } from '~/locale'; import { __ } from '~/locale';
import { hide } from '~/tooltips'; import { hide } from '~/tooltips';
...@@ -111,7 +111,11 @@ export default class MirrorRepos { ...@@ -111,7 +111,11 @@ export default class MirrorRepos {
return axios return axios
.put(this.mirrorEndpoint, payload) .put(this.mirrorEndpoint, payload)
.then(() => this.removeRow($target)) .then(() => this.removeRow($target))
.catch(() => Flash(__('Failed to remove mirror.'))); .catch(() =>
createFlash({
message: __('Failed to remove mirror.'),
}),
);
} }
/* eslint-disable class-methods-use-this */ /* eslint-disable class-methods-use-this */
......
import $ from 'jquery'; import $ from 'jquery';
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 { backOff } from '~/lib/utils/common_utils'; import { backOff } from '~/lib/utils/common_utils';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -115,7 +115,9 @@ export default class SSHMirror { ...@@ -115,7 +115,9 @@ export default class SSHMirror {
const failureMessage = response.data const failureMessage = response.data
? response.data.message ? response.data.message
: __('An error occurred while detecting host keys'); : __('An error occurred while detecting host keys');
Flash(failureMessage); createFlash({
message: failureMessage,
});
$btnLoadSpinner.addClass('hidden'); $btnLoadSpinner.addClass('hidden');
this.$btnDetectHostKeys.enable(); this.$btnDetectHostKeys.enable();
......
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 { initRails } from '~/lib/utils/rails_ujs'; import { initRails } from '~/lib/utils/rails_ujs';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
...@@ -18,8 +18,10 @@ export default function leaveByUrl(namespaceType) { ...@@ -18,8 +18,10 @@ export default function leaveByUrl(namespaceType) {
if (leaveLink) { if (leaveLink) {
leaveLink.click(); leaveLink.click();
} else { } else {
Flash( createFlash({
sprintf(__('You do not have permission to leave this %{namespaceType}.'), { namespaceType }), message: sprintf(__('You do not have permission to leave this %{namespaceType}.'), {
); namespaceType,
}),
});
} }
} }
...@@ -14,7 +14,7 @@ import $ from 'jquery'; ...@@ -14,7 +14,7 @@ import $ from 'jquery';
import { mapActions, mapGetters, mapState } from 'vuex'; import { mapActions, mapGetters, mapState } from 'vuex';
import Autosave from '~/autosave'; import Autosave from '~/autosave';
import { refreshUserMergeRequestCounts } from '~/commons/nav/user_merge_requests'; import { refreshUserMergeRequestCounts } from '~/commons/nav/user_merge_requests';
import { deprecatedCreateFlash as Flash } from '~/flash'; import createFlash from '~/flash';
import { statusBoxState } from '~/issuable/components/status_box.vue'; import { statusBoxState } from '~/issuable/components/status_box.vue';
import httpStatusCodes from '~/lib/utils/http_status'; import httpStatusCodes from '~/lib/utils/http_status';
import { import {
...@@ -293,7 +293,11 @@ export default { ...@@ -293,7 +293,11 @@ export default {
toggleState() toggleState()
.then(() => statusBoxState.updateStatus && statusBoxState.updateStatus()) .then(() => statusBoxState.updateStatus && statusBoxState.updateStatus())
.then(refreshUserMergeRequestCounts) .then(refreshUserMergeRequestCounts)
.catch(() => Flash(constants.toggleStateErrorMessage[this.noteableType][this.openState])); .catch(() =>
createFlash({
message: constants.toggleStateErrorMessage[this.noteableType][this.openState],
}),
);
}, },
discard(shouldClear = true) { discard(shouldClear = true) {
// `blur` is needed to clear slash commands autocomplete cache if event fired. // `blur` is needed to clear slash commands autocomplete cache if event fired.
......
...@@ -3,7 +3,7 @@ import { GlTooltipDirective, GlIcon, GlButton, GlDropdownItem } from '@gitlab/ui ...@@ -3,7 +3,7 @@ import { GlTooltipDirective, GlIcon, GlButton, GlDropdownItem } from '@gitlab/ui
import { mapActions, mapGetters } from 'vuex'; import { mapActions, mapGetters } from 'vuex';
import Api from '~/api'; import Api from '~/api';
import resolvedStatusMixin from '~/batch_comments/mixins/resolved_status'; import resolvedStatusMixin from '~/batch_comments/mixins/resolved_status';
import { deprecatedCreateFlash as flash } from '~/flash'; import createFlash from '~/flash';
import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants'; import { BV_HIDE_TOOLTIP } from '~/lib/utils/constants';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import eventHub from '~/sidebar/event_hub'; import eventHub from '~/sidebar/event_hub';
...@@ -234,7 +234,11 @@ export default { ...@@ -234,7 +234,11 @@ export default {
assignee_ids: assignees.map((assignee) => assignee.id), assignee_ids: assignees.map((assignee) => assignee.id),
}) })
.then(() => this.handleAssigneeUpdate(assignees)) .then(() => this.handleAssigneeUpdate(assignees))
.catch(() => flash(__('Something went wrong while updating assignees'))); .catch(() =>
createFlash({
message: __('Something went wrong while updating assignees'),
}),
);
} }
}, },
setAwardEmoji(awardName) { setAwardEmoji(awardName) {
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { mapActions, mapGetters } from 'vuex'; import { mapActions, mapGetters } from 'vuex';
import { __ } from '~/locale'; import { __ } from '~/locale';
import AwardsList from '~/vue_shared/components/awards_list.vue'; import AwardsList from '~/vue_shared/components/awards_list.vue';
import { deprecatedCreateFlash as Flash } from '../../flash'; import createFlash from '../../flash';
export default { export default {
components: { components: {
...@@ -48,7 +48,11 @@ export default { ...@@ -48,7 +48,11 @@ export default {
awardName, awardName,
}; };
this.toggleAwardRequest(data).catch(() => Flash(__('Something went wrong on our end.'))); this.toggleAwardRequest(data).catch(() =>
createFlash({
message: __('Something went wrong on our end.'),
}),
);
}, },
}, },
}; };
......
...@@ -6,7 +6,7 @@ import { clearDraft, getDiscussionReplyKey } from '~/lib/utils/autosave'; ...@@ -6,7 +6,7 @@ import { clearDraft, getDiscussionReplyKey } from '~/lib/utils/autosave';
import { s__, __ } from '~/locale'; import { s__, __ } from '~/locale';
import diffLineNoteFormMixin from '~/notes/mixins/diff_line_note_form'; import diffLineNoteFormMixin from '~/notes/mixins/diff_line_note_form';
import TimelineEntryItem from '~/vue_shared/components/notes/timeline_entry_item.vue'; import TimelineEntryItem from '~/vue_shared/components/notes/timeline_entry_item.vue';
import { deprecatedCreateFlash as Flash } from '../../flash'; import createFlash from '../../flash';
import userAvatarLink from '../../vue_shared/components/user_avatar/user_avatar_link.vue'; import userAvatarLink from '../../vue_shared/components/user_avatar/user_avatar_link.vue';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
import noteable from '../mixins/noteable'; import noteable from '../mixins/noteable';
...@@ -220,7 +220,11 @@ export default { ...@@ -220,7 +220,11 @@ export default {
const msg = __( const msg = __(
'Your comment could not be submitted! Please check your network connection and try again.', 'Your comment could not be submitted! Please check your network connection and try again.',
); );
Flash(msg, 'alert', this.$el); createFlash({
message: msg,
type: 'alert',
parent: this.$el,
});
this.$refs.noteForm.note = noteText; this.$refs.noteForm.note = noteText;
callback(err); callback(err);
}); });
......
...@@ -7,7 +7,7 @@ import { INLINE_DIFF_LINES_KEY } from '~/diffs/constants'; ...@@ -7,7 +7,7 @@ import { INLINE_DIFF_LINES_KEY } from '~/diffs/constants';
import httpStatusCodes from '~/lib/utils/http_status'; import httpStatusCodes from '~/lib/utils/http_status';
import { truncateSha } from '~/lib/utils/text_utility'; import { truncateSha } from '~/lib/utils/text_utility';
import TimelineEntryItem from '~/vue_shared/components/notes/timeline_entry_item.vue'; import TimelineEntryItem from '~/vue_shared/components/notes/timeline_entry_item.vue';
import { deprecatedCreateFlash as Flash } from '../../flash'; import createFlash from '../../flash';
import { __, s__, sprintf } from '../../locale'; import { __, s__, sprintf } from '../../locale';
import userAvatarLink from '../../vue_shared/components/user_avatar/user_avatar_link.vue'; import userAvatarLink from '../../vue_shared/components/user_avatar/user_avatar_link.vue';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
...@@ -247,7 +247,9 @@ export default { ...@@ -247,7 +247,9 @@ export default {
this.isDeleting = false; this.isDeleting = false;
}) })
.catch(() => { .catch(() => {
Flash(__('Something went wrong while deleting your note. Please try again.')); createFlash({
message: __('Something went wrong while deleting your note. Please try again.'),
});
this.isDeleting = false; this.isDeleting = false;
}); });
} }
...@@ -316,7 +318,11 @@ export default { ...@@ -316,7 +318,11 @@ export default {
this.setSelectedCommentPositionHover(); this.setSelectedCommentPositionHover();
this.$nextTick(() => { this.$nextTick(() => {
const msg = __('Something went wrong while editing your comment. Please try again.'); const msg = __('Something went wrong while editing your comment. Please try again.');
Flash(msg, 'alert', this.$el); createFlash({
message: msg,
type: 'alert',
parent: this.$el,
});
this.recoverNoteContent(noteText); this.recoverNoteContent(noteText);
callback(); callback();
}); });
......
...@@ -7,7 +7,7 @@ import TimelineEntryItem from '~/vue_shared/components/notes/timeline_entry_item ...@@ -7,7 +7,7 @@ import TimelineEntryItem from '~/vue_shared/components/notes/timeline_entry_item
import OrderedLayout from '~/vue_shared/components/ordered_layout.vue'; import OrderedLayout from '~/vue_shared/components/ordered_layout.vue';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import draftNote from '../../batch_comments/components/draft_note.vue'; import draftNote from '../../batch_comments/components/draft_note.vue';
import { deprecatedCreateFlash as Flash } from '../../flash'; import createFlash from '../../flash';
import { getLocationHash, doesHashExistInUrl } from '../../lib/utils/url_utility'; import { getLocationHash, doesHashExistInUrl } from '../../lib/utils/url_utility';
import placeholderNote from '../../vue_shared/components/notes/placeholder_note.vue'; import placeholderNote from '../../vue_shared/components/notes/placeholder_note.vue';
import placeholderSystemNote from '../../vue_shared/components/notes/placeholder_system_note.vue'; import placeholderSystemNote from '../../vue_shared/components/notes/placeholder_system_note.vue';
...@@ -216,7 +216,9 @@ export default { ...@@ -216,7 +216,9 @@ export default {
.catch(() => { .catch(() => {
this.setLoadingState(false); this.setLoadingState(false);
this.setNotesFetchedState(true); this.setNotesFetchedState(true);
Flash(__('Something went wrong while fetching comments. Please try again.')); createFlash({
message: __('Something went wrong while fetching comments. Please try again.'),
});
}); });
}, },
initPolling() { initPolling() {
......
import { deprecatedCreateFlash as Flash } from '~/flash'; import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
export default { export default {
...@@ -46,7 +46,11 @@ export default { ...@@ -46,7 +46,11 @@ export default {
this.isResolving = false; this.isResolving = false;
const msg = __('Something went wrong while resolving this discussion. Please try again.'); const msg = __('Something went wrong while resolving this discussion. Please try again.');
Flash(msg, 'alert', this.$el); createFlash({
message: msg,
type: 'alert',
parent: this.$el,
});
}); });
}, },
}, },
......
...@@ -9,7 +9,7 @@ import { confidentialWidget } from '~/sidebar/components/confidential/sidebar_co ...@@ -9,7 +9,7 @@ import { confidentialWidget } from '~/sidebar/components/confidential/sidebar_co
import updateIssueLockMutation from '~/sidebar/components/lock/mutations/update_issue_lock.mutation.graphql'; import updateIssueLockMutation from '~/sidebar/components/lock/mutations/update_issue_lock.mutation.graphql';
import updateMergeRequestLockMutation from '~/sidebar/components/lock/mutations/update_merge_request_lock.mutation.graphql'; import updateMergeRequestLockMutation from '~/sidebar/components/lock/mutations/update_merge_request_lock.mutation.graphql';
import loadAwardsHandler from '../../awards_handler'; import loadAwardsHandler from '../../awards_handler';
import { deprecatedCreateFlash as Flash } from '../../flash'; import createFlash from '../../flash';
import { isInViewport, scrollToElement, isInMRPage } from '../../lib/utils/common_utils'; import { isInViewport, scrollToElement, isInMRPage } from '../../lib/utils/common_utils';
import Poll from '../../lib/utils/poll'; import Poll from '../../lib/utils/poll';
import { create } from '../../lib/utils/recurrence'; import { create } from '../../lib/utils/recurrence';
...@@ -354,7 +354,11 @@ export const saveNote = ({ commit, dispatch }, noteData) => { ...@@ -354,7 +354,11 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
$('.js-gfm-input').trigger('clear-commands-cache.atwho'); $('.js-gfm-input').trigger('clear-commands-cache.atwho');
Flash(message || __('Commands applied'), 'notice', noteData.flashContainer); createFlash({
message: message || __('Commands applied'),
type: 'notice',
parent: noteData.flashContainer,
});
} }
return res; return res;
...@@ -375,11 +379,11 @@ export const saveNote = ({ commit, dispatch }, noteData) => { ...@@ -375,11 +379,11 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
awardsHandler.scrollToAwards(); awardsHandler.scrollToAwards();
}) })
.catch(() => { .catch(() => {
Flash( createFlash({
__('Something went wrong while adding your award. Please try again.'), message: __('Something went wrong while adding your award. Please try again.'),
'alert', type: 'alert',
noteData.flashContainer, parent: noteData.flashContainer,
); });
}) })
.then(() => res); .then(() => res);
}; };
...@@ -417,7 +421,11 @@ export const saveNote = ({ commit, dispatch }, noteData) => { ...@@ -417,7 +421,11 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
const errorMsg = sprintf(__('Your comment could not be submitted because %{error}'), { const errorMsg = sprintf(__('Your comment could not be submitted because %{error}'), {
error: base[0].toLowerCase(), error: base[0].toLowerCase(),
}); });
Flash(errorMsg, 'alert', noteData.flashContainer); createFlash({
message: errorMsg,
type: 'alert',
parent: noteData.flashContainer,
});
return { ...data, hasFlash: true }; return { ...data, hasFlash: true };
} }
} }
...@@ -480,7 +488,9 @@ export const poll = ({ commit, state, getters, dispatch }) => { ...@@ -480,7 +488,9 @@ export const poll = ({ commit, state, getters, dispatch }) => {
}); });
notePollOccurrenceTracking.handle(2, () => { notePollOccurrenceTracking.handle(2, () => {
// On the second failure in a row, show the alert and try one more time (hoping to succeed and clear the error) // On the second failure in a row, show the alert and try one more time (hoping to succeed and clear the error)
flashContainer = Flash(__('Something went wrong while fetching latest comments.')); flashContainer = createFlash({
message: __('Something went wrong while fetching latest comments.'),
});
setTimeout(() => eTagPoll.restart(), NOTES_POLLING_INTERVAL); setTimeout(() => eTagPoll.restart(), NOTES_POLLING_INTERVAL);
}); });
...@@ -570,7 +580,9 @@ export const filterDiscussion = ({ dispatch }, { path, filter, persistFilter }) ...@@ -570,7 +580,9 @@ export const filterDiscussion = ({ dispatch }, { path, filter, persistFilter })
.catch(() => { .catch(() => {
dispatch('setLoadingState', false); dispatch('setLoadingState', false);
dispatch('setNotesFetchedState', true); dispatch('setNotesFetchedState', true);
Flash(__('Something went wrong while fetching comments. Please try again.')); createFlash({
message: __('Something went wrong while fetching comments. Please try again.'),
});
}); });
}; };
...@@ -613,7 +625,11 @@ export const submitSuggestion = ( ...@@ -613,7 +625,11 @@ export const submitSuggestion = (
const flashMessage = errorMessage || defaultMessage; const flashMessage = errorMessage || defaultMessage;
Flash(__(flashMessage), 'alert', flashContainer); createFlash({
message: __(flashMessage),
type: 'alert',
parent: flashContainer,
});
}) })
.finally(() => { .finally(() => {
commit(types.SET_RESOLVING_DISCUSSION, false); commit(types.SET_RESOLVING_DISCUSSION, false);
...@@ -646,7 +662,11 @@ export const submitSuggestionBatch = ({ commit, dispatch, state }, { flashContai ...@@ -646,7 +662,11 @@ export const submitSuggestionBatch = ({ commit, dispatch, state }, { flashContai
const flashMessage = errorMessage || defaultMessage; const flashMessage = errorMessage || defaultMessage;
Flash(__(flashMessage), 'alert', flashContainer); createFlash({
message: __(flashMessage),
type: 'alert',
parent: flashContainer,
});
}) })
.finally(() => { .finally(() => {
commit(types.SET_APPLYING_BATCH_STATE, false); commit(types.SET_APPLYING_BATCH_STATE, false);
...@@ -685,7 +705,9 @@ export const fetchDescriptionVersion = ({ dispatch }, { endpoint, startingVersio ...@@ -685,7 +705,9 @@ export const fetchDescriptionVersion = ({ dispatch }, { endpoint, startingVersio
}) })
.catch((error) => { .catch((error) => {
dispatch('receiveDescriptionVersionError', error); dispatch('receiveDescriptionVersionError', error);
Flash(__('Something went wrong while fetching description changes. Please try again.')); createFlash({
message: __('Something went wrong while fetching description changes. Please try again.'),
});
}); });
}; };
...@@ -717,7 +739,9 @@ export const softDeleteDescriptionVersion = ( ...@@ -717,7 +739,9 @@ export const softDeleteDescriptionVersion = (
}) })
.catch((error) => { .catch((error) => {
dispatch('receiveDeleteDescriptionVersionError', error); dispatch('receiveDeleteDescriptionVersionError', error);
Flash(__('Something went wrong while deleting description changes. Please try again.')); createFlash({
message: __('Something went wrong while deleting description changes. Please try again.'),
});
// Throw an error here because a component like SystemNote - // Throw an error here because a component like SystemNote -
// needs to know if the request failed to reset its internal state. // needs to know if the request failed to reset its internal state.
......
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';
...@@ -38,7 +38,9 @@ export default class PayloadPreviewer { ...@@ -38,7 +38,9 @@ export default class PayloadPreviewer {
}) })
.catch(() => { .catch(() => {
this.spinner.classList.remove('d-inline-flex'); this.spinner.classList.remove('d-inline-flex');
flash(__('Error fetching payload data.')); createFlash({
message: __('Error fetching payload data.'),
});
}); });
} }
......
import $ from 'jquery'; import $ from 'jquery';
import { debounce } from 'lodash'; import { debounce } 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 { textColorForBackground } from '~/lib/utils/color_utils'; import { textColorForBackground } from '~/lib/utils/color_utils';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -30,7 +30,11 @@ export default () => { ...@@ -30,7 +30,11 @@ export default () => {
.then(({ data }) => { .then(({ data }) => {
$jsBroadcastMessagePreview.html(data.message); $jsBroadcastMessagePreview.html(data.message);
}) })
.catch(() => flash(__('An error occurred while rendering preview broadcast message'))); .catch(() =>
createFlash({
message: __('An error occurred while rendering preview broadcast message'),
}),
);
} }
}; };
......
...@@ -4,7 +4,7 @@ import $ from 'jquery'; ...@@ -4,7 +4,7 @@ import $ from 'jquery';
import { getGroups } from '~/api/groups_api'; import { getGroups } from '~/api/groups_api';
import { getProjects } from '~/api/projects_api'; import { getProjects } from '~/api/projects_api';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown'; import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
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 { isMetaClick } from '~/lib/utils/common_utils'; import { isMetaClick } from '~/lib/utils/common_utils';
import { addDelimiter } from '~/lib/utils/text_utility'; import { addDelimiter } from '~/lib/utils/text_utility';
...@@ -103,7 +103,9 @@ export default class Todos { ...@@ -103,7 +103,9 @@ export default class Todos {
}) })
.catch(() => { .catch(() => {
this.updateRowState(target, true); this.updateRowState(target, true);
return flash(__('Error updating status of to-do item.')); return createFlash({
message: __('Error updating status of to-do item.'),
});
}); });
} }
...@@ -145,7 +147,11 @@ export default class Todos { ...@@ -145,7 +147,11 @@ export default class Todos {
this.updateAllState(target, data); this.updateAllState(target, data);
this.updateBadges(data); this.updateBadges(data);
}) })
.catch(() => flash(__('Error updating status for all to-do items.'))); .catch(() =>
createFlash({
message: __('Error updating status for all to-do items.'),
}),
);
} }
updateAllState(target, data) { updateAllState(target, data) {
......
import { debounce } from 'lodash'; import { debounce } from 'lodash';
import { deprecatedCreateFlash as flash } from '~/flash'; import createFlash from '~/flash';
import { __ } from '~/locale'; import { __ } from '~/locale';
import InputValidator from '~/validators/input_validator'; import InputValidator from '~/validators/input_validator';
import fetchGroupPathAvailability from './fetch_group_path_availability'; import fetchGroupPathAvailability from './fetch_group_path_availability';
...@@ -60,7 +60,11 @@ export default class GroupPathValidator extends InputValidator { ...@@ -60,7 +60,11 @@ export default class GroupPathValidator extends InputValidator {
GroupPathValidator.showSuggestions(inputDomElement, data.suggests); GroupPathValidator.showSuggestions(inputDomElement, data.suggests);
} }
}) })
.catch(() => flash(__('An error occurred while validating group path'))); .catch(() =>
createFlash({
message: __('An error occurred while validating group path'),
}),
);
} }
} }
......
<script> <script>
import { GlSafeHtmlDirective as SafeHtml, GlModal } from '@gitlab/ui'; import { GlSafeHtmlDirective as SafeHtml, GlModal } from '@gitlab/ui';
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 { redirectTo } from '~/lib/utils/url_utility'; import { redirectTo } from '~/lib/utils/url_utility';
...@@ -98,17 +98,17 @@ Once deleted, it cannot be undone or recovered.`), ...@@ -98,17 +98,17 @@ Once deleted, it cannot be undone or recovered.`),
}); });
if (error.response && error.response.status === 404) { if (error.response && error.response.status === 404) {
Flash( createFlash({
sprintf(s__('Milestones|Milestone %{milestoneTitle} was not found'), { message: sprintf(s__('Milestones|Milestone %{milestoneTitle} was not found'), {
milestoneTitle: this.milestoneTitle, milestoneTitle: this.milestoneTitle,
}), }),
); });
} else { } else {
Flash( createFlash({
sprintf(s__('Milestones|Failed to delete milestone %{milestoneTitle}'), { message: sprintf(s__('Milestones|Failed to delete milestone %{milestoneTitle}'), {
milestoneTitle: this.milestoneTitle, milestoneTitle: this.milestoneTitle,
}), }),
); });
} }
throw error; throw error;
}); });
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import $ from 'jquery'; import $ from 'jquery';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown'; import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
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 { capitalizeFirstCharacter } from '~/lib/utils/text_utility'; import { capitalizeFirstCharacter } from '~/lib/utils/text_utility';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -37,7 +37,11 @@ export default function initCompareAutocomplete(limitTo = null, clickHandler = ( ...@@ -37,7 +37,11 @@ export default function initCompareAutocomplete(limitTo = null, clickHandler = (
callback(data); callback(data);
} }
}) })
.catch(() => flash(__('Error fetching refs'))); .catch(() =>
createFlash({
message: __('Error fetching refs'),
}),
);
}, },
selectable: true, selectable: true,
filterable: true, filterable: true,
......
...@@ -8,7 +8,7 @@ import axios from 'axios'; ...@@ -8,7 +8,7 @@ import axios from 'axios';
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 waitForPromises from 'helpers/wait_for_promises'; import waitForPromises from 'helpers/wait_for_promises';
import { deprecatedCreateFlash as flash } from '~/flash'; import createFlash from '~/flash';
import Issuable from '~/issues_list/components/issuable.vue'; import Issuable from '~/issues_list/components/issuable.vue';
import IssuablesListApp from '~/issues_list/components/issuables_list_app.vue'; import IssuablesListApp from '~/issues_list/components/issuables_list_app.vue';
import { PAGE_SIZE, PAGE_SIZE_MANUAL, RELATIVE_POSITION } from '~/issues_list/constants'; import { PAGE_SIZE, PAGE_SIZE_MANUAL, RELATIVE_POSITION } from '~/issues_list/constants';
...@@ -104,7 +104,7 @@ describe('Issuables list component', () => { ...@@ -104,7 +104,7 @@ describe('Issuables list component', () => {
}); });
it('flashes an error', () => { it('flashes an error', () => {
expect(flash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
}); });
}); });
......
...@@ -7,7 +7,7 @@ import Vuex from 'vuex'; ...@@ -7,7 +7,7 @@ import Vuex from 'vuex';
import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import { extendedWrapper } from 'helpers/vue_test_utils_helper';
import batchComments from '~/batch_comments/stores/modules/batch_comments'; import batchComments from '~/batch_comments/stores/modules/batch_comments';
import { refreshUserMergeRequestCounts } from '~/commons/nav/user_merge_requests'; import { refreshUserMergeRequestCounts } from '~/commons/nav/user_merge_requests';
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 CommentForm from '~/notes/components/comment_form.vue'; import CommentForm from '~/notes/components/comment_form.vue';
import * as constants from '~/notes/constants'; import * as constants from '~/notes/constants';
...@@ -464,9 +464,9 @@ describe('issue_comment_form component', () => { ...@@ -464,9 +464,9 @@ describe('issue_comment_form component', () => {
await wrapper.vm.$nextTick; await wrapper.vm.$nextTick;
await wrapper.vm.$nextTick; await wrapper.vm.$nextTick;
expect(flash).toHaveBeenCalledWith( expect(createFlash).toHaveBeenCalledWith({
`Something went wrong while closing the ${type}. Please try again later.`, message: `Something went wrong while closing the ${type}. Please try again later.`,
); });
}); });
}); });
...@@ -500,9 +500,9 @@ describe('issue_comment_form component', () => { ...@@ -500,9 +500,9 @@ describe('issue_comment_form component', () => {
await wrapper.vm.$nextTick; await wrapper.vm.$nextTick;
await wrapper.vm.$nextTick; await wrapper.vm.$nextTick;
expect(flash).toHaveBeenCalledWith( expect(createFlash).toHaveBeenCalledWith({
`Something went wrong while reopening the ${type}. Please try again later.`, message: `Something went wrong while reopening the ${type}. Please try again later.`,
); });
}); });
}); });
......
...@@ -2,7 +2,7 @@ import AxiosMockAdapter from 'axios-mock-adapter'; ...@@ -2,7 +2,7 @@ import AxiosMockAdapter from 'axios-mock-adapter';
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import { TEST_HOST } from 'spec/test_constants'; import { TEST_HOST } from 'spec/test_constants';
import Api from '~/api'; import Api from '~/api';
import { deprecatedCreateFlash as Flash } from '~/flash'; import createFlash from '~/flash';
import { EVENT_ISSUABLE_VUE_APP_CHANGE } from '~/issuable/constants'; import { EVENT_ISSUABLE_VUE_APP_CHANGE } from '~/issuable/constants';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import * as notesConstants from '~/notes/constants'; import * as notesConstants from '~/notes/constants';
...@@ -33,10 +33,7 @@ jest.mock('~/flash', () => { ...@@ -33,10 +33,7 @@ jest.mock('~/flash', () => {
}; };
}); });
return { return flash;
createFlash: flash,
deprecatedCreateFlash: flash,
};
}); });
describe('Actions Notes Store', () => { describe('Actions Notes Store', () => {
...@@ -348,13 +345,13 @@ describe('Actions Notes Store', () => { ...@@ -348,13 +345,13 @@ describe('Actions Notes Store', () => {
await startPolling(); await startPolling();
expect(axiosMock.history.get).toHaveLength(1); expect(axiosMock.history.get).toHaveLength(1);
expect(Flash).not.toHaveBeenCalled(); expect(createFlash).not.toHaveBeenCalled();
await advanceXMoreIntervals(1); await advanceXMoreIntervals(1);
expect(axiosMock.history.get).toHaveLength(2); expect(axiosMock.history.get).toHaveLength(2);
expect(Flash).toHaveBeenCalled(); expect(createFlash).toHaveBeenCalled();
expect(Flash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
}); });
it('resets the failure counter on success', async () => { it('resets the failure counter on success', async () => {
...@@ -375,14 +372,14 @@ describe('Actions Notes Store', () => { ...@@ -375,14 +372,14 @@ describe('Actions Notes Store', () => {
await advanceXMoreIntervals(1); // Failure #2 await advanceXMoreIntervals(1); // Failure #2
// That was the first failure AFTER a success, so we should NOT see the error displayed // That was the first failure AFTER a success, so we should NOT see the error displayed
expect(Flash).not.toHaveBeenCalled(); expect(createFlash).not.toHaveBeenCalled();
// Now we'll allow another failure // Now we'll allow another failure
await advanceXMoreIntervals(1); // Failure #3 await advanceXMoreIntervals(1); // Failure #3
// Since this is the second failure in a row, the error should happen // Since this is the second failure in a row, the error should happen
expect(Flash).toHaveBeenCalled(); expect(createFlash).toHaveBeenCalled();
expect(Flash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
}); });
it('hides the error display if it exists on success', async () => { it('hides the error display if it exists on success', async () => {
...@@ -393,8 +390,8 @@ describe('Actions Notes Store', () => { ...@@ -393,8 +390,8 @@ describe('Actions Notes Store', () => {
await advanceXMoreIntervals(2); await advanceXMoreIntervals(2);
// After two errors, the error should be displayed // After two errors, the error should be displayed
expect(Flash).toHaveBeenCalled(); expect(createFlash).toHaveBeenCalled();
expect(Flash).toHaveBeenCalledTimes(1); expect(createFlash).toHaveBeenCalledTimes(1);
axiosMock.reset(); axiosMock.reset();
successMock(); successMock();
...@@ -906,7 +903,7 @@ describe('Actions Notes Store', () => { ...@@ -906,7 +903,7 @@ describe('Actions Notes Store', () => {
.then(() => done.fail('Expected error to be thrown!')) .then(() => done.fail('Expected error to be thrown!'))
.catch((err) => { .catch((err) => {
expect(err).toBe(error); expect(err).toBe(error);
expect(Flash).not.toHaveBeenCalled(); expect(createFlash).not.toHaveBeenCalled();
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
...@@ -928,11 +925,11 @@ describe('Actions Notes Store', () => { ...@@ -928,11 +925,11 @@ describe('Actions Notes Store', () => {
) )
.then((resp) => { .then((resp) => {
expect(resp.hasFlash).toBe(true); expect(resp.hasFlash).toBe(true);
expect(Flash).toHaveBeenCalledWith( expect(createFlash).toHaveBeenCalledWith({
'Your comment could not be submitted because something went wrong', message: 'Your comment could not be submitted because something went wrong',
'alert', type: 'alert',
flashContainer, parent: flashContainer,
); });
}) })
.catch(() => done.fail('Expected success response!')) .catch(() => done.fail('Expected success response!'))
.then(done) .then(done)
...@@ -954,7 +951,7 @@ describe('Actions Notes Store', () => { ...@@ -954,7 +951,7 @@ describe('Actions Notes Store', () => {
) )
.then((data) => { .then((data) => {
expect(data).toBe(res); expect(data).toBe(res);
expect(Flash).not.toHaveBeenCalled(); expect(createFlash).not.toHaveBeenCalled();
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
...@@ -997,7 +994,7 @@ describe('Actions Notes Store', () => { ...@@ -997,7 +994,7 @@ describe('Actions Notes Store', () => {
['resolveDiscussion', { discussionId }], ['resolveDiscussion', { discussionId }],
['restartPolling'], ['restartPolling'],
]); ]);
expect(Flash).not.toHaveBeenCalled(); expect(createFlash).not.toHaveBeenCalled();
}); });
}); });
...@@ -1012,7 +1009,11 @@ describe('Actions Notes Store', () => { ...@@ -1012,7 +1009,11 @@ describe('Actions Notes Store', () => {
[mutationTypes.SET_RESOLVING_DISCUSSION, false], [mutationTypes.SET_RESOLVING_DISCUSSION, false],
]); ]);
expect(dispatch.mock.calls).toEqual([['stopPolling'], ['restartPolling']]); expect(dispatch.mock.calls).toEqual([['stopPolling'], ['restartPolling']]);
expect(Flash).toHaveBeenCalledWith(TEST_ERROR_MESSAGE, 'alert', flashContainer); expect(createFlash).toHaveBeenCalledWith({
message: TEST_ERROR_MESSAGE,
type: 'alert',
parent: flashContainer,
});
}); });
}); });
...@@ -1027,11 +1028,11 @@ describe('Actions Notes Store', () => { ...@@ -1027,11 +1028,11 @@ describe('Actions Notes Store', () => {
[mutationTypes.SET_RESOLVING_DISCUSSION, false], [mutationTypes.SET_RESOLVING_DISCUSSION, false],
]); ]);
expect(dispatch.mock.calls).toEqual([['stopPolling'], ['restartPolling']]); expect(dispatch.mock.calls).toEqual([['stopPolling'], ['restartPolling']]);
expect(Flash).toHaveBeenCalledWith( expect(createFlash).toHaveBeenCalledWith({
'Something went wrong while applying the suggestion. Please try again.', message: 'Something went wrong while applying the suggestion. Please try again.',
'alert', type: 'alert',
flashContainer, parent: flashContainer,
); });
}); });
}); });
...@@ -1039,7 +1040,7 @@ describe('Actions Notes Store', () => { ...@@ -1039,7 +1040,7 @@ describe('Actions Notes Store', () => {
dispatch.mockReturnValue(Promise.reject()); dispatch.mockReturnValue(Promise.reject());
testSubmitSuggestion(done, () => { testSubmitSuggestion(done, () => {
expect(Flash).not.toHaveBeenCalled(); expect(createFlash).not.toHaveBeenCalled();
}); });
}); });
}); });
...@@ -1083,7 +1084,7 @@ describe('Actions Notes Store', () => { ...@@ -1083,7 +1084,7 @@ describe('Actions Notes Store', () => {
['restartPolling'], ['restartPolling'],
]); ]);
expect(Flash).not.toHaveBeenCalled(); expect(createFlash).not.toHaveBeenCalled();
}); });
}); });
...@@ -1101,7 +1102,11 @@ describe('Actions Notes Store', () => { ...@@ -1101,7 +1102,11 @@ describe('Actions Notes Store', () => {
]); ]);
expect(dispatch.mock.calls).toEqual([['stopPolling'], ['restartPolling']]); expect(dispatch.mock.calls).toEqual([['stopPolling'], ['restartPolling']]);
expect(Flash).toHaveBeenCalledWith(TEST_ERROR_MESSAGE, 'alert', flashContainer); expect(createFlash).toHaveBeenCalledWith({
message: TEST_ERROR_MESSAGE,
type: 'alert',
parent: flashContainer,
});
}); });
}); });
...@@ -1119,11 +1124,12 @@ describe('Actions Notes Store', () => { ...@@ -1119,11 +1124,12 @@ describe('Actions Notes Store', () => {
]); ]);
expect(dispatch.mock.calls).toEqual([['stopPolling'], ['restartPolling']]); expect(dispatch.mock.calls).toEqual([['stopPolling'], ['restartPolling']]);
expect(Flash).toHaveBeenCalledWith( expect(createFlash).toHaveBeenCalledWith({
message:
'Something went wrong while applying the batch of suggestions. Please try again.', 'Something went wrong while applying the batch of suggestions. Please try again.',
'alert', type: 'alert',
flashContainer, parent: flashContainer,
); });
}); });
}); });
...@@ -1139,7 +1145,7 @@ describe('Actions Notes Store', () => { ...@@ -1139,7 +1145,7 @@ describe('Actions Notes Store', () => {
[mutationTypes.SET_RESOLVING_DISCUSSION, false], [mutationTypes.SET_RESOLVING_DISCUSSION, false],
]); ]);
expect(Flash).not.toHaveBeenCalled(); expect(createFlash).not.toHaveBeenCalled();
}); });
}); });
}); });
...@@ -1283,7 +1289,7 @@ describe('Actions Notes Store', () => { ...@@ -1283,7 +1289,7 @@ describe('Actions Notes Store', () => {
) )
.then(() => done.fail('Expected error to be thrown')) .then(() => done.fail('Expected error to be thrown'))
.catch(() => { .catch(() => {
expect(Flash).toHaveBeenCalled(); expect(createFlash).toHaveBeenCalled();
done(); done();
}); });
}); });
......
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