Commit b8a59dec authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

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

Refactor(createFlash): use non-deprecated function

See merge request gitlab-org/gitlab!63902
parents 169165d2 cac31ccf
......@@ -4,7 +4,7 @@ import $ from 'jquery';
import Cookies from 'js-cookie';
import initClonePanel from '~/clone_panel';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils';
import { serializeForm } from '~/lib/utils/forms';
import { mergeUrlParams } from '~/lib/utils/url_utility';
......@@ -78,7 +78,11 @@ export default class Project {
},
})
.then(({ data }) => callback(data))
.catch(() => flash(__('An error occurred while getting projects')));
.catch(() =>
createFlash({
message: __('An error occurred while getting projects'),
}),
);
},
selectable: true,
filterable: true,
......
import { debounce } from 'lodash';
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils';
import { __ } from '~/locale';
import InputValidator from '~/validators/input_validator';
......@@ -50,7 +50,11 @@ export default class UsernameValidator extends InputValidator {
usernameTaken ? unavailableMessageSelector : successMessageSelector,
);
})
.catch(() => flash(__('An error occurred while validating username')));
.catch(() =>
createFlash({
message: __('An error occurred while validating username'),
}),
);
}
}
......
......@@ -2,7 +2,7 @@ import { select } from 'd3-selection';
import dateFormat from 'dateformat';
import $ from 'jquery';
import { last } from 'lodash';
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils';
import { getDayName, getDayDifference } from '~/lib/utils/datetime_utility';
import { n__, s__, __ } from '~/locale';
......@@ -295,7 +295,11 @@ export default class ActivityCalendar {
responseType: 'text',
})
.then(({ data }) => $(this.activitiesContainer).html(data))
.catch(() => flash(__('An error occurred while retrieving calendar activity')));
.catch(() =>
createFlash({
message: __('An error occurred while retrieving calendar activity'),
}),
);
} else {
this.currentSelectedDate = '';
$(this.activitiesContainer).html('');
......
import { deprecatedCreateFlash as Flash } from './flash';
import createFlash from './flash';
import axios from './lib/utils/axios_utils';
import { parseBoolean } from './lib/utils/common_utils';
import { __ } from './locale';
......@@ -62,7 +62,11 @@ export default class PersistentUserCallout {
}
})
.catch(() => {
Flash(__('An error occurred while dismissing the alert. Refresh the page and try again.'));
createFlash({
message: __(
'An error occurred while dismissing the alert. Refresh the page and try again.',
),
});
});
}
......@@ -79,11 +83,11 @@ export default class PersistentUserCallout {
window.location.assign(href);
})
.catch(() => {
Flash(
__(
createFlash({
message: __(
'An error occurred while acknowledging the notification. Refresh the page and try again.',
),
);
});
});
}
......
......@@ -13,7 +13,7 @@
*/
import { GlDropdown, GlLoadingIcon, GlTooltipDirective, GlIcon } from '@gitlab/ui';
import { deprecatedCreateFlash as Flash } from '~/flash';
import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils';
import { __ } from '~/locale';
import eventHub from '../../event_hub';
......@@ -83,7 +83,9 @@ export default {
this.$refs.dropdown.hide();
this.isLoading = false;
Flash(__('Something went wrong on our end.'));
createFlash({
message: __('Something went wrong on our end.'),
});
});
},
isDropdownOpen() {
......
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import { __ } from '~/locale';
export default {
......@@ -13,7 +13,9 @@ export default {
})
.catch(() => {
this.mediator.store.toggleLoading(pipeline);
flash(__('An error occurred while fetching the pipeline.'));
createFlash({
message: __('An error occurred while fetching the pipeline.'),
});
});
},
/**
......@@ -53,9 +55,11 @@ export default {
requestRefreshPipelineGraph() {
// When an action is clicked
// (whether in the dropdown or in the main nodes, we refresh the big graph)
this.mediator
.refreshPipeline()
.catch(() => flash(__('An error occurred while making the request.')));
this.mediator.refreshPipeline().catch(() =>
createFlash({
message: __('An error occurred while making the request.'),
}),
);
},
},
};
import Vue from 'vue';
import { deprecatedCreateFlash as Flash } from '~/flash';
import createFlash from '~/flash';
import { parseBoolean } from '~/lib/utils/common_utils';
import { __ } from '~/locale';
import Translate from '~/vue_shared/translate';
......@@ -96,14 +96,18 @@ export default async function initPipelineDetailsBundle() {
try {
createPipelineHeaderApp(SELECTORS.PIPELINE_HEADER, apolloProvider, dataset.graphqlResourceEtag);
} catch {
Flash(__('An error occurred while loading a section of this page.'));
createFlash({
message: __('An error occurred while loading a section of this page.'),
});
}
if (canShowNewPipelineDetails) {
try {
createPipelinesDetailApp(SELECTORS.PIPELINE_GRAPH, apolloProvider, dataset);
} catch {
Flash(__('An error occurred while loading the pipeline.'));
createFlash({
message: __('An error occurred while loading the pipeline.'),
});
}
} else {
const { default: PipelinesMediator } = await import(
......
import Visibility from 'visibilityjs';
import { deprecatedCreateFlash as Flash } from '../flash';
import createFlash from '../flash';
import Poll from '../lib/utils/poll';
import { __ } from '../locale';
import PipelineService from './services/pipeline_service';
......@@ -47,7 +47,9 @@ export default class pipelinesMediator {
errorCallback() {
this.state.isLoading = false;
Flash(__('An error occurred while fetching the pipeline.'));
createFlash({
message: __('An error occurred while fetching the pipeline.'),
});
}
refreshPipeline() {
......
......@@ -5,7 +5,7 @@ import { Rails } from '~/lib/utils/rails_ujs';
import TimezoneDropdown, {
formatTimezone,
} from '~/pages/projects/pipeline_schedules/shared/components/timezone_dropdown';
import { deprecatedCreateFlash as flash } from '../flash';
import createFlash from '../flash';
export default class Profile {
constructor({ form } = {}) {
......@@ -83,14 +83,21 @@ export default class Profile {
this.updateHeaderAvatar();
}
flash(data.message, 'notice');
createFlash({
message: data.message,
type: 'notice',
});
})
.then(() => {
window.scrollTo(0, 0);
// Enable submit button after requests ends
self.form.find(':input[disabled]').enable();
})
.catch((error) => flash(error.message));
.catch((error) =>
createFlash({
message: error.message,
}),
);
}
updateHeaderAvatar() {
......
......@@ -2,7 +2,7 @@
import fuzzaldrinPlus from 'fuzzaldrin-plus';
import $ from 'jquery';
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import { sanitize } from '~/lib/dompurify';
import axios from '~/lib/utils/axios_utils';
import { spriteIcon } from '~/lib/utils/common_utils';
......@@ -88,7 +88,11 @@ export default class ProjectFindFile {
this.findFile();
this.element.find('.files-slider tr.tree-item').eq(0).addClass('selected').focus();
})
.catch(() => flash(__('An error occurred while loading filenames')));
.catch(() =>
createFlash({
message: __('An error occurred while loading filenames'),
}),
);
}
// render result
......
import $ from 'jquery';
import { fixTitle } from '~/tooltips';
import { deprecatedCreateFlash as flash } from './flash';
import createFlash from './flash';
import axios from './lib/utils/axios_utils';
import { __ } from './locale';
......@@ -60,7 +60,11 @@ export default class ProjectLabelSubscription {
return button;
});
})
.catch(() => flash(__('There was an error subscribing to this label.')));
.catch(() =>
createFlash({
message: __('There was an error subscribing to this label.'),
}),
);
}
static setNewTitle($button, originalTitle, newStatus) {
......
<script>
import { GlLoadingIcon, GlTooltipDirective } from '@gitlab/ui';
import Visibility from 'visibilityjs';
import { deprecatedCreateFlash as Flash } from '~/flash';
import createFlash from '~/flash';
import Poll from '~/lib/utils/poll';
import { __, s__, sprintf } from '~/locale';
import ciIcon from '~/vue_shared/components/ci_icon.vue';
......@@ -57,7 +57,9 @@ export default {
group: 'notfound',
};
this.isLoading = false;
Flash(s__('Something went wrong on our end'));
createFlash({
message: s__('Something went wrong on our end'),
});
},
initPolling() {
this.poll = new Poll({
......
import $ from 'jquery';
import CreateItemDropdown from '~/create_item_dropdown';
import { deprecatedCreateFlash as Flash } from '~/flash';
import createFlash from '~/flash';
import AccessorUtilities from '~/lib/utils/accessor';
import axios from '~/lib/utils/axios_utils';
import { __ } from '~/locale';
......@@ -135,6 +135,10 @@ export default class ProtectedBranchCreate {
.then(() => {
window.location.reload();
})
.catch(() => Flash(__('Failed to protect the branch')));
.catch(() =>
createFlash({
message: __('Failed to protect the branch'),
}),
);
}
}
import { deprecatedCreateFlash as flash } from '../flash';
import createFlash from '../flash';
import axios from '../lib/utils/axios_utils';
import { FAILED_TO_UPDATE_TAG_MESSAGE } from './constants';
import ProtectedTagAccessDropdown from './protected_tag_access_dropdown';
......@@ -49,7 +49,9 @@ export default class ProtectedTagEdit {
this.$allowedToCreateDropdownButton.enable();
window.scrollTo({ top: 0, behavior: 'smooth' });
flash(FAILED_TO_UPDATE_TAG_MESSAGE);
createFlash({
message: FAILED_TO_UPDATE_TAG_MESSAGE,
});
});
}
}
......@@ -3,7 +3,7 @@
import $ from 'jquery';
import Cookies from 'js-cookie';
import { fixTitle, hide } from '~/tooltips';
import { deprecatedCreateFlash as flash } from './flash';
import createFlash from './flash';
import axios from './lib/utils/axios_utils';
import { sprintf, s__, __ } from './locale';
......@@ -98,12 +98,12 @@ Sidebar.prototype.toggleTodo = function (e) {
this.todoUpdateDone(data);
})
.catch(() =>
flash(
sprintf(__('There was an error %{message} todo.'), {
createFlash({
message: sprintf(__('There was an error %{message} todo.'), {
message:
ajaxType === 'post' ? s__('RightSidebar|adding a') : s__('RightSidebar|deleting the'),
}),
),
}),
);
};
......
<script>
import { refreshUserMergeRequestCounts } from '~/commons/nav/user_merge_requests';
import { deprecatedCreateFlash as Flash } from '~/flash';
import createFlash from '~/flash';
import { __ } from '~/locale';
import eventHub from '~/sidebar/event_hub';
import Store from '~/sidebar/stores/sidebar_store';
......@@ -113,7 +113,9 @@ export default {
})
.catch(() => {
this.loading = false;
return new Flash(__('Error occurred when saving assignees'));
return createFlash({
message: __('Error occurred when saving assignees'),
});
});
},
exposeAvailabilityStatus(users) {
......
......@@ -2,7 +2,7 @@
import { GlButton } from '@gitlab/ui';
import $ from 'jquery';
import { mapActions } from 'vuex';
import { deprecatedCreateFlash as Flash } from '~/flash';
import createFlash from '~/flash';
import { __, sprintf } from '../../../locale';
import eventHub from '../../event_hub';
......@@ -52,7 +52,9 @@ export default {
const flashMessage = __(
'Something went wrong trying to change the locked state of this %{issuableDisplayName}',
);
Flash(sprintf(flashMessage, { issuableDisplayName: this.issuableDisplayName }));
createFlash({
message: sprintf(flashMessage, { issuableDisplayName: this.issuableDisplayName }),
});
})
.finally(() => {
this.closeForm();
......
......@@ -2,7 +2,7 @@
// NOTE! For the first iteration, we are simply copying the implementation of Assignees
// It will soon be overhauled in Issue https://gitlab.com/gitlab-org/gitlab/-/issues/233736
import { refreshUserMergeRequestCounts } from '~/commons/nav/user_merge_requests';
import { deprecatedCreateFlash as Flash } from '~/flash';
import createFlash from '~/flash';
import { __ } from '~/locale';
import eventHub from '~/sidebar/event_hub';
import Store from '~/sidebar/stores/sidebar_store';
......@@ -80,7 +80,9 @@ export default {
})
.catch(() => {
this.loading = false;
return new Flash(__('Error occurred when saving reviewers'));
return createFlash({
message: __('Error occurred when saving reviewers'),
});
});
},
requestReview(data) {
......
import Store from 'ee_else_ce/sidebar/stores/sidebar_store';
import { __ } from '~/locale';
import toast from '~/vue_shared/plugins/global_toast';
import { deprecatedCreateFlash as Flash } from '../flash';
import createFlash from '../flash';
import { visitUrl } from '../lib/utils/url_utility';
import Service from './services/sidebar_service';
......@@ -74,7 +74,11 @@ export default class SidebarMediator {
.then(([restResponse, graphQlResponse]) => {
this.processFetchedData(restResponse.data, graphQlResponse.data);
})
.catch(() => new Flash(__('Error occurred when fetching sidebar data')));
.catch(() =>
createFlash({
message: __('Error occurred when fetching sidebar data'),
}),
);
}
processFetchedData(data) {
......
......@@ -2,7 +2,7 @@
import { GlButton, GlLoadingIcon } from '@gitlab/ui';
import eventHub from '~/blob/components/eventhub';
import { deprecatedCreateFlash as Flash } from '~/flash';
import createFlash from '~/flash';
import { redirectTo, joinPaths } from '~/lib/utils/url_utility';
import { __, sprintf } from '~/locale';
import {
......@@ -135,7 +135,9 @@ export default {
const defaultErrorMsg = this.newSnippet
? SNIPPET_CREATE_MUTATION_ERROR
: SNIPPET_UPDATE_MUTATION_ERROR;
Flash(sprintf(defaultErrorMsg, { err }));
createFlash({
message: sprintf(defaultErrorMsg, { err }),
});
this.isUpdating = false;
},
getAttachedFiles() {
......
import $ from 'jquery';
import { deprecatedCreateFlash as Flash } from './flash';
import createFlash from './flash';
import axios from './lib/utils/axios_utils';
import { spriteIcon } from './lib/utils/common_utils';
import { __, s__ } from './locale';
......@@ -28,7 +28,11 @@ export default class Star {
$this.prepend(spriteIcon('star', iconClasses));
}
})
.catch(() => Flash(__('Star toggle failed. Try again later.')));
.catch(() =>
createFlash({
message: __('Star toggle failed. Try again later.'),
}),
);
});
}
}
import { deprecatedCreateFlash as Flash } from '~/flash';
import createFlash from '~/flash';
import { __ } from '~/locale';
import { getBinary } from './services/image_service';
const imageRepository = () => {
const images = new Map();
const flash = (message) => new Flash(message);
const flash = (message) =>
createFlash({
message,
});
const add = (file, url) => {
getBinary(file)
......
import $ from 'jquery';
import 'deckar01-task_list';
import { __ } from '~/locale';
import { deprecatedCreateFlash as Flash } from './flash';
import createFlash from './flash';
import axios from './lib/utils/axios_utils';
export default class TaskList {
......@@ -22,7 +22,10 @@ export default class TaskList {
errorMessages = e.response.data.errors.join(' ');
}
return new Flash(errorMessages || __('Update failed'), 'alert');
return createFlash({
message: errorMessages || __('Update failed'),
type: 'alert',
});
};
this.init();
......
import $ from 'jquery';
import { deprecatedCreateFlash as Flash } from './flash';
import createFlash from './flash';
import { parseBoolean } from './lib/utils/common_utils';
import { __ } from './locale';
......@@ -42,7 +42,9 @@ function onToggleClicked(toggle, input, clickCallback) {
$(input).trigger('trigger-change');
})
.catch(() => {
Flash(__('Something went wrong when toggling the button'));
createFlash({
message: __('Something went wrong when toggling the button'),
});
});
}
......
import $ from 'jquery';
import { deprecatedCreateFlash as Flash, hideFlash } from './flash';
import createFlash, { hideFlash } from './flash';
import axios from './lib/utils/axios_utils';
import { parseBoolean } from './lib/utils/common_utils';
import { __ } from './locale';
......@@ -26,7 +26,9 @@ export default () => {
})
.catch(() => {
hideConsentMessage();
Flash(__('Something went wrong. Try again later.'));
createFlash({
message: __('Something went wrong. Try again later.'),
});
});
});
};
......@@ -5,7 +5,7 @@ import autoMergeEnabledQuery from 'ee_else_ce/vue_merge_request_widget/queries/s
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { __ } from '~/locale';
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { deprecatedCreateFlash as Flash } from '../../../flash';
import createFlash from '../../../flash';
import { AUTO_MERGE_STRATEGIES } from '../../constants';
import eventHub from '../../event_hub';
import mergeRequestQueryVariablesMixin from '../../mixins/merge_request_query_variables';
......@@ -109,7 +109,9 @@ export default {
})
.catch(() => {
this.isCancellingAutoMerge = false;
Flash(__('Something went wrong. Please try again.'));
createFlash({
message: __('Something went wrong. Please try again.'),
});
});
},
removeSourceBranch() {
......@@ -135,7 +137,9 @@ export default {
})
.catch(() => {
this.isRemovingSourceBranch = false;
Flash(__('Something went wrong. Please try again.'));
createFlash({
message: __('Something went wrong. Please try again.'),
});
});
},
},
......
<script>
/* eslint-disable @gitlab/vue-require-i18n-strings */
import { GlLoadingIcon, GlButton, GlTooltipDirective } from '@gitlab/ui';
import { deprecatedCreateFlash as Flash } from '~/flash';
import createFlash from '~/flash';
import { s__, __ } from '~/locale';
import { OPEN_REVERT_MODAL, OPEN_CHERRY_PICK_MODAL } from '~/projects/commit/constants';
import modalEventHub from '~/projects/commit/event_hub';
......@@ -100,7 +100,9 @@ export default {
})
.catch(() => {
this.isMakingRequest = false;
Flash(__('Something went wrong. Please try again.'));
createFlash({
message: __('Something went wrong. Please try again.'),
});
});
},
openRevertModal() {
......
......@@ -4,7 +4,7 @@ import { GlButton, GlSkeletonLoader } from '@gitlab/ui';
import { escape } from 'lodash';
import { __, sprintf } from '~/locale';
import glFeatureFlagMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import { deprecatedCreateFlash as Flash } from '../../../flash';
import createFlash from '../../../flash';
import simplePoll from '../../../lib/utils/simple_poll';
import eventHub from '../../event_hub';
import mergeRequestQueryVariablesMixin from '../../mixins/merge_request_query_variables';
......@@ -113,7 +113,9 @@ export default {
if (error.response && error.response.data && error.response.data.merge_error) {
this.rebasingError = error.response.data.merge_error;
} else {
Flash(__('Something went wrong. Please try again.'));
createFlash({
message: __('Something went wrong. Please try again.'),
});
}
});
},
......@@ -129,7 +131,9 @@ export default {
if (res.merge_error && res.merge_error.length) {
this.rebasingError = res.merge_error;
Flash(__('Something went wrong. Please try again.'));
createFlash({
message: __('Something went wrong. Please try again.'),
});
}
eventHub.$emit('MRWidgetRebaseSuccess');
......@@ -138,7 +142,9 @@ export default {
})
.catch(() => {
this.isMakingRequest = false;
Flash(__('Something went wrong. Please try again.'));
createFlash({
message: __('Something went wrong. Please try again.'),
});
stopPolling();
});
},
......
......@@ -4,7 +4,7 @@ import { GlIcon } from '@gitlab/ui';
import $ from 'jquery';
import '~/behaviors/markdown/render_gfm';
import { unescape } from 'lodash';
import { deprecatedCreateFlash as Flash } from '~/flash';
import createFlash from '~/flash';
import GLForm from '~/gl_form';
import axios from '~/lib/utils/axios_utils';
import { stripHtml } from '~/lib/utils/text_utility';
......@@ -222,7 +222,11 @@ export default {
axios
.post(this.markdownPreviewPath, { text: this.textareaValue })
.then((response) => this.renderMarkdown(response.data))
.catch(() => new Flash(__('Error loading markdown preview')));
.catch(() =>
createFlash({
message: __('Error loading markdown preview'),
}),
);
} else {
this.renderMarkdown();
}
......@@ -245,7 +249,11 @@ export default {
this.$nextTick()
.then(() => $(this.$refs['markdown-preview']).renderGFM())
.catch(() => new Flash(__('Error rendering markdown preview')));
.catch(() =>
createFlash({
message: __('Error rendering markdown preview'),
}),
);
},
},
};
......
<script>
import { GlSafeHtmlDirective as SafeHtml } from '@gitlab/ui';
import Vue from 'vue';
import { deprecatedCreateFlash as Flash } from '~/flash';
import createFlash from '~/flash';
import { __ } from '~/locale';
import SuggestionDiff from './suggestion_diff.vue';
......@@ -79,7 +79,11 @@ export default {
const suggestionElements = container.querySelectorAll('.js-render-suggestion');
if (this.lineType === 'old') {
Flash(__('Unable to apply suggestions to a deleted line.'), 'alert', this.$el);
createFlash({
message: __('Unable to apply suggestions to a deleted line.'),
type: 'alert',
parent: this.$el,
});
}
suggestionElements.forEach((suggestionEl, i) => {
......
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils';
import { __ } from '~/locale';
import * as types from './mutation_types';
......@@ -16,7 +16,9 @@ export const receiveLabelsSuccess = ({ commit }, labels) =>
commit(types.RECEIVE_SET_LABELS_SUCCESS, labels);
export const receiveLabelsFailure = ({ commit }) => {
commit(types.RECEIVE_SET_LABELS_FAILURE);
flash(__('Error fetching labels.'));
createFlash({
message: __('Error fetching labels.'),
});
};
export const fetchLabels = ({ state, dispatch }) => {
dispatch('requestLabels');
......@@ -32,7 +34,9 @@ export const requestCreateLabel = ({ commit }) => commit(types.REQUEST_CREATE_LA
export const receiveCreateLabelSuccess = ({ commit }) => commit(types.RECEIVE_CREATE_LABEL_SUCCESS);
export const receiveCreateLabelFailure = ({ commit }) => {
commit(types.RECEIVE_CREATE_LABEL_FAILURE);
flash(__('Error creating label.'));
createFlash({
message: __('Error creating label.'),
});
};
export const createLabel = ({ state, dispatch }, label) => {
dispatch('requestCreateLabel');
......
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils';
import { __ } from '~/locale';
import * as types from './mutation_types';
......@@ -16,7 +16,9 @@ export const receiveLabelsSuccess = ({ commit }, labels) =>
commit(types.RECEIVE_SET_LABELS_SUCCESS, labels);
export const receiveLabelsFailure = ({ commit }) => {
commit(types.RECEIVE_SET_LABELS_FAILURE);
flash(__('Error fetching labels.'));
createFlash({
message: __('Error fetching labels.'),
});
};
export const fetchLabels = ({ state, dispatch }) => {
dispatch('requestLabels');
......
......@@ -2,7 +2,7 @@ import { GlLoadingIcon } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import Visibility from 'visibilityjs';
import { getJSONFixture } from 'helpers/fixtures';
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import Poll from '~/lib/utils/poll';
import CommitPipelineStatus from '~/projects/tree/components/commit_pipeline_status_component.vue';
import CiIcon from '~/vue_shared/components/ci_icon.vue';
......@@ -170,7 +170,7 @@ describe('Commit pipeline status component', () => {
});
it('displays flash error message', () => {
expect(flash).toHaveBeenCalled();
expect(createFlash).toHaveBeenCalled();
});
});
});
......
import MockAdapter from 'axios-mock-adapter';
import testAction from 'helpers/vuex_action_helper';
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils';
import { convertToFixedRange } from '~/lib/utils/datetime_range';
import { TOKEN_TYPE_POD_NAME } from '~/logs/constants';
......@@ -76,7 +76,7 @@ describe('Logs Store actions', () => {
});
afterEach(() => {
flash.mockClear();
createFlash.mockClear();
});
describe('setInitData', () => {
......
import MockAdapter from 'axios-mock-adapter';
import waitForPromises from 'helpers/wait_for_promises';
import { deprecatedCreateFlash as Flash } from '~/flash';
import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils';
import PersistentUserCallout from '~/persistent_user_callout';
......@@ -96,9 +96,9 @@ describe('PersistentUserCallout', () => {
return waitForPromises().then(() => {
expect(persistentUserCallout.container.remove).not.toHaveBeenCalled();
expect(Flash).toHaveBeenCalledWith(
'An error occurred while dismissing the alert. Refresh the page and try again.',
);
expect(createFlash).toHaveBeenCalledWith({
message: 'An error occurred while dismissing the alert. Refresh the page and try again.',
});
});
});
});
......@@ -203,9 +203,10 @@ describe('PersistentUserCallout', () => {
return waitForPromises().then(() => {
expect(window.location.assign).not.toHaveBeenCalled();
expect(Flash).toHaveBeenCalledWith(
expect(createFlash).toHaveBeenCalledWith({
message:
'An error occurred while acknowledging the notification. Refresh the page and try again.',
);
});
});
});
});
......
import { mount } from '@vue/test-utils';
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import { createStore as createMrStore } from '~/mr_notes/stores';
import createStore from '~/notes/stores';
import EditFormButtons from '~/sidebar/components/lock/edit_form_buttons.vue';
......@@ -130,7 +130,7 @@ describe('EditFormButtons', () => {
});
it('does not flash an error message', () => {
expect(flash).not.toHaveBeenCalled();
expect(createFlash).not.toHaveBeenCalled();
});
});
......@@ -165,9 +165,9 @@ describe('EditFormButtons', () => {
});
it('calls flash with the correct message', () => {
expect(flash).toHaveBeenCalledWith(
`Something went wrong trying to change the locked state of this ${issuableDisplayName}`,
);
expect(createFlash).toHaveBeenCalledWith({
message: `Something went wrong trying to change the locked state of this ${issuableDisplayName}`,
});
});
});
});
......
......@@ -8,7 +8,7 @@ import createMockApollo from 'helpers/mock_apollo_helper';
import waitForPromises from 'helpers/wait_for_promises';
import GetSnippetQuery from 'shared_queries/snippet/snippet.query.graphql';
import UnsolvedCaptchaError from '~/captcha/unsolved_captcha_error';
import { deprecatedCreateFlash as Flash } from '~/flash';
import createFlash from '~/flash';
import * as urlUtils from '~/lib/utils/url_utility';
import SnippetEditApp from '~/snippets/components/edit.vue';
import SnippetBlobActionsEdit from '~/snippets/components/snippet_blob_actions_edit.vue';
......@@ -319,7 +319,9 @@ describe('Snippet Edit app', () => {
});
expect(urlUtils.redirectTo).not.toHaveBeenCalled();
expect(Flash).toHaveBeenCalledWith(expectMessage);
expect(createFlash).toHaveBeenCalledWith({
message: expectMessage,
});
},
);
......@@ -337,9 +339,9 @@ describe('Snippet Edit app', () => {
it('should flash', () => {
// Apollo automatically wraps the resolver's error in a NetworkError
expect(Flash).toHaveBeenCalledWith(
`Can't update snippet: Network error: ${error.message}`,
);
expect(createFlash).toHaveBeenCalledWith({
message: `Can't update snippet: Network error: ${error.message}`,
});
});
it('should console error', () => {
......
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