Commit 44638c2d authored by Michael Lunøe's avatar Michael Lunøe Committed by Enrique Alcántara

Refactor(createFlash): use non-deprecated function

Migrate away from `deprecatedCreateFlash` and use
`createFlash` instead.

Manual changes

Epic:
https://gitlab.com/groups/gitlab-org/-/epics/3895
parent 3b1e7b04
/* eslint-disable no-new */
import { debounce } from 'lodash'; import { debounce } from 'lodash';
import { import {
init as initConfidentialMergeRequest, init as initConfidentialMergeRequest,
...@@ -8,7 +7,7 @@ import { ...@@ -8,7 +7,7 @@ import {
import confidentialMergeRequestState from './confidential_merge_request/state'; import confidentialMergeRequestState from './confidential_merge_request/state';
import DropLab from './droplab/drop_lab'; import DropLab from './droplab/drop_lab';
import ISetter from './droplab/plugins/input_setter'; import ISetter from './droplab/plugins/input_setter';
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 } from './locale'; import { __, sprintf } from './locale';
...@@ -132,7 +131,9 @@ export default class CreateMergeRequestDropdown { ...@@ -132,7 +131,9 @@ export default class CreateMergeRequestDropdown {
.catch(() => { .catch(() => {
this.unavailable(); this.unavailable();
this.disable(); this.disable();
Flash(__('Failed to check related branches.')); createFlash({
message: __('Failed to check related branches.'),
});
}); });
} }
...@@ -147,7 +148,11 @@ export default class CreateMergeRequestDropdown { ...@@ -147,7 +148,11 @@ export default class CreateMergeRequestDropdown {
this.branchCreated = true; this.branchCreated = true;
window.location.href = data.url; window.location.href = data.url;
}) })
.catch(() => Flash(__('Failed to create a branch for this issue. Please try again.'))); .catch(() =>
createFlash({
message: __('Failed to create a branch for this issue. Please try again.'),
}),
);
} }
createMergeRequest() { createMergeRequest() {
...@@ -163,7 +168,11 @@ export default class CreateMergeRequestDropdown { ...@@ -163,7 +168,11 @@ export default class CreateMergeRequestDropdown {
this.mergeRequestCreated = true; this.mergeRequestCreated = true;
window.location.href = data.url; window.location.href = data.url;
}) })
.catch(() => Flash(__('Failed to create Merge Request. Please try again.'))); .catch(() =>
createFlash({
message: __('Failed to create Merge Request. Please try again.'),
}),
);
} }
disable() { disable() {
...@@ -256,7 +265,9 @@ export default class CreateMergeRequestDropdown { ...@@ -256,7 +265,9 @@ export default class CreateMergeRequestDropdown {
.catch(() => { .catch(() => {
this.unavailable(); this.unavailable();
this.disable(); this.disable();
new Flash(__('Failed to get ref.')); createFlash({
message: __('Failed to get ref.'),
});
this.isGettingRef = false; this.isGettingRef = false;
......
import { __ } from '~/locale'; import { __ } from '~/locale';
import Ajax from '../droplab/plugins/ajax'; import Ajax from '../droplab/plugins/ajax';
import Filter from '../droplab/plugins/filter'; import Filter from '../droplab/plugins/filter';
import { deprecatedCreateFlash as Flash } from '../flash'; import createFlash from '../flash';
import DropdownUtils from './dropdown_utils'; import DropdownUtils from './dropdown_utils';
import FilteredSearchDropdown from './filtered_search_dropdown'; import FilteredSearchDropdown from './filtered_search_dropdown';
...@@ -14,9 +14,9 @@ export default class DropdownEmoji extends FilteredSearchDropdown { ...@@ -14,9 +14,9 @@ export default class DropdownEmoji extends FilteredSearchDropdown {
method: 'setData', method: 'setData',
loadingTemplate: this.loadingTemplate, loadingTemplate: this.loadingTemplate,
onError() { onError() {
/* eslint-disable no-new */ createFlash({
new Flash(__('An error occurred fetching the dropdown data.')); message: __('An error occurred fetching the dropdown data.'),
/* eslint-enable no-new */ });
}, },
}, },
Filter: { Filter: {
......
import { __ } from '~/locale'; import { __ } from '~/locale';
import Ajax from '../droplab/plugins/ajax'; import Ajax from '../droplab/plugins/ajax';
import Filter from '../droplab/plugins/filter'; import Filter from '../droplab/plugins/filter';
import { deprecatedCreateFlash as Flash } from '../flash'; import createFlash from '../flash';
import DropdownUtils from './dropdown_utils'; import DropdownUtils from './dropdown_utils';
import FilteredSearchDropdown from './filtered_search_dropdown'; import FilteredSearchDropdown from './filtered_search_dropdown';
...@@ -17,9 +17,9 @@ export default class DropdownNonUser extends FilteredSearchDropdown { ...@@ -17,9 +17,9 @@ export default class DropdownNonUser extends FilteredSearchDropdown {
loadingTemplate: this.loadingTemplate, loadingTemplate: this.loadingTemplate,
preprocessing, preprocessing,
onError() { onError() {
/* eslint-disable no-new */ createFlash({
new Flash(__('An error occurred fetching the dropdown data.')); message: __('An error occurred fetching the dropdown data.'),
/* eslint-enable no-new */ });
}, },
}, },
Filter: { Filter: {
......
...@@ -10,7 +10,7 @@ import { ...@@ -10,7 +10,7 @@ import {
DOWN_KEY_CODE, DOWN_KEY_CODE,
} from '~/lib/utils/keycodes'; } from '~/lib/utils/keycodes';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { deprecatedCreateFlash as Flash } from '../flash'; import createFlash from '../flash';
import { addClassIfElementExists } from '../lib/utils/dom_utils'; import { addClassIfElementExists } from '../lib/utils/dom_utils';
import { visitUrl } from '../lib/utils/url_utility'; import { visitUrl } from '../lib/utils/url_utility';
import FilteredSearchContainer from './container'; import FilteredSearchContainer from './container';
...@@ -92,8 +92,9 @@ export default class FilteredSearchManager { ...@@ -92,8 +92,9 @@ export default class FilteredSearchManager {
.fetch() .fetch()
.catch((error) => { .catch((error) => {
if (error.name === 'RecentSearchesServiceError') return undefined; if (error.name === 'RecentSearchesServiceError') return undefined;
// eslint-disable-next-line no-new createFlash({
new Flash(__('An error occurred while parsing recent searches')); message: __('An error occurred while parsing recent searches'),
});
// Gracefully fail to empty array // Gracefully fail to empty array
return []; return [];
}) })
......
...@@ -22,7 +22,7 @@ import syntaxHighlight from '~/syntax_highlight'; ...@@ -22,7 +22,7 @@ import syntaxHighlight from '~/syntax_highlight';
import Autosave from './autosave'; import Autosave from './autosave';
import loadAwardsHandler from './awards_handler'; import loadAwardsHandler from './awards_handler';
import CommentTypeToggle from './comment_type_toggle'; import CommentTypeToggle from './comment_type_toggle';
import { deprecatedCreateFlash as Flash } from './flash'; import createFlash from './flash';
import { defaultAutocompleteConfig } from './gfm_auto_complete'; import { defaultAutocompleteConfig } from './gfm_auto_complete';
import GLForm from './gl_form'; import GLForm from './gl_form';
import axios from './lib/utils/axios_utils'; import axios from './lib/utils/axios_utils';
...@@ -399,7 +399,11 @@ export default class Notes { ...@@ -399,7 +399,11 @@ export default class Notes {
if (noteEntity.commands_changes && Object.keys(noteEntity.commands_changes).length > 0) { if (noteEntity.commands_changes && Object.keys(noteEntity.commands_changes).length > 0) {
$notesList.find('.system-note.being-posted').remove(); $notesList.find('.system-note.being-posted').remove();
} }
this.addFlash(noteEntity.errors.commands_only, 'notice', this.parentTimeline.get(0)); this.addFlash({
message: noteEntity.errors.commands_only,
type: 'notice',
parent: this.parentTimeline.get(0),
});
this.refresh(); this.refresh();
} }
return; return;
...@@ -620,20 +624,21 @@ export default class Notes { ...@@ -620,20 +624,21 @@ export default class Notes {
} else if ($form.hasClass('js-discussion-note-form')) { } else if ($form.hasClass('js-discussion-note-form')) {
formParentTimeline = $form.closest('.discussion-notes').find('.notes'); formParentTimeline = $form.closest('.discussion-notes').find('.notes');
} }
return this.addFlash( return this.addFlash({
__( message: __(
'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.',
), ),
'alert', type: 'alert',
formParentTimeline.get(0), parent: formParentTimeline.get(0),
); });
} }
updateNoteError() { updateNoteError() {
// eslint-disable-next-line no-new createFlash({
new Flash( message: __(
__('Your comment could not be updated! Please check your network connection and try again.'), 'Your comment could not be updated! Please check your network connection and try again.',
); ),
});
} }
/** /**
...@@ -1289,7 +1294,7 @@ export default class Notes { ...@@ -1289,7 +1294,7 @@ export default class Notes {
} }
addFlash(...flashParams) { addFlash(...flashParams) {
this.flashContainer = new Flash(...flashParams); this.flashContainer = createFlash(...flashParams);
} }
clearFlash() { clearFlash() {
......
...@@ -15,10 +15,10 @@ import { isEmpty } from 'lodash'; ...@@ -15,10 +15,10 @@ import { isEmpty } from 'lodash';
import readyToMergeMixin from 'ee_else_ce/vue_merge_request_widget/mixins/ready_to_merge'; import readyToMergeMixin from 'ee_else_ce/vue_merge_request_widget/mixins/ready_to_merge';
import readyToMergeQuery from 'ee_else_ce/vue_merge_request_widget/queries/states/ready_to_merge.query.graphql'; import readyToMergeQuery from 'ee_else_ce/vue_merge_request_widget/queries/states/ready_to_merge.query.graphql';
import { refreshUserMergeRequestCounts } from '~/commons/nav/user_merge_requests'; import { refreshUserMergeRequestCounts } from '~/commons/nav/user_merge_requests';
import createFlash from '~/flash';
import simplePoll from '~/lib/utils/simple_poll'; import simplePoll from '~/lib/utils/simple_poll';
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 MergeRequest from '../../../merge_request'; import MergeRequest from '../../../merge_request';
import { AUTO_MERGE_STRATEGIES, DANGER, INFO, WARNING } from '../../constants'; import { AUTO_MERGE_STRATEGIES, DANGER, INFO, WARNING } from '../../constants';
import eventHub from '../../event_hub'; import eventHub from '../../event_hub';
...@@ -351,7 +351,9 @@ export default { ...@@ -351,7 +351,9 @@ export default {
}) })
.catch(() => { .catch(() => {
this.isMakingRequest = false; this.isMakingRequest = false;
new Flash(__('Something went wrong. Please try again.')); // eslint-disable-line createFlash({
message: __('Something went wrong. Please try again.'),
});
}); });
}, },
handleMergeImmediatelyButtonClick() { handleMergeImmediatelyButtonClick() {
...@@ -402,7 +404,9 @@ export default { ...@@ -402,7 +404,9 @@ export default {
} }
}) })
.catch(() => { .catch(() => {
new Flash(__('Something went wrong while merging this merge request. Please try again.')); // eslint-disable-line createFlash({
message: __('Something went wrong while merging this merge request. Please try again.'),
});
stopPolling(); stopPolling();
}); });
}, },
...@@ -432,7 +436,9 @@ export default { ...@@ -432,7 +436,9 @@ export default {
} }
}) })
.catch(() => { .catch(() => {
new Flash(__('Something went wrong while deleting the source branch. Please try again.')); // eslint-disable-line createFlash({
message: __('Something went wrong while deleting the source branch. Please try again.'),
});
}); });
}, },
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment