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