Skip to content
Snippets Groups Projects
Commit a64d4eb5 authored by Michael Lunøe's avatar Michael Lunøe Committed by E'zeki&el Kigbo
Browse files

Refactor(createFlash): use non-deprecated function

parent 73aec068
No related branches found
No related tags found
No related merge requests found
Showing
with 165 additions and 80 deletions
import Vue from 'vue';
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import IdeRouter from '~/ide/ide_router_extension';
import { joinPaths } from '~/lib/utils/url_utility';
import { __ } from '~/locale';
Loading
Loading
@@ -111,14 +111,14 @@ export const createRouter = (store, defaultBranch) => {
}
})
.catch((e) => {
flash(
__('Error while loading the project data. Please try again.'),
'alert',
document,
null,
false,
true,
);
createFlash({
message: __('Error while loading the project data. Please try again.'),
type: 'alert',
parent: document,
actionConfig: null,
fadeTransition: false,
addBodyClass: true,
});
throw e;
});
}
Loading
Loading
import { escape } from 'lodash';
import Vue from 'vue';
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import { visitUrl } from '~/lib/utils/url_utility';
import { __, sprintf } from '~/locale';
import {
Loading
Loading
@@ -36,16 +36,17 @@ export const createTempEntry = (
const fullName = name.slice(-1) !== '/' && type === 'tree' ? `${name}/` : name;
 
if (getters.entryExists(name)) {
flash(
sprintf(__('The name "%{name}" is already taken in this directory.'), {
createFlash({
message: sprintf(__('The name "%{name}" is already taken in this directory.'), {
name: name.split('/').pop(),
}),
'alert',
document,
null,
false,
true,
);
type: 'alert',
parent: document,
actionConfig: null,
fadeTransition: false,
addBodyClass: true,
});
 
return undefined;
}
Loading
Loading
@@ -284,14 +285,14 @@ export const getBranchData = ({ commit, state }, { projectId, branchId, force =
if (e.response.status === 404) {
reject(e);
} else {
flash(
__('Error loading branch data. Please try again.'),
'alert',
document,
null,
false,
true,
);
createFlash({
message: __('Error loading branch data. Please try again.'),
type: 'alert',
parent: document,
actionConfig: null,
fadeTransition: false,
addBodyClass: true,
});
 
reject(
new Error(
Loading
Loading
import { escape } from 'lodash';
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import { __, sprintf } from '~/locale';
import api from '../../../api';
import service from '../../services';
Loading
Loading
@@ -19,14 +19,14 @@ export const getProjectData = ({ commit, state }, { namespace, projectId, force
resolve(data);
})
.catch(() => {
flash(
__('Error loading project data. Please try again.'),
'alert',
document,
null,
false,
true,
);
createFlash({
message: __('Error loading project data. Please try again.'),
type: 'alert',
parent: document,
actionConfig: null,
fadeTransition: false,
addBodyClass: true,
});
reject(new Error(`Project not loaded ${namespace}/${projectId}`));
});
} else {
Loading
Loading
@@ -45,7 +45,14 @@ export const refreshLastCommitData = ({ commit }, { projectId, branchId } = {})
});
})
.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;
});
 
Loading
Loading
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import { addNumericSuffix } from '~/ide/utils';
import { sprintf, __ } from '~/locale';
import { leftSidebarViews } from '../../../constants';
Loading
Loading
@@ -143,7 +143,14 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo
commit(types.UPDATE_LOADING, false);
 
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;
}
 
Loading
Loading
import $ from 'jquery';
import { difference, intersection, union } from 'lodash';
import { deprecatedCreateFlash as Flash } from './flash';
import createFlash from './flash';
import axios from './lib/utils/axios_utils';
import { __ } from './locale';
 
Loading
Loading
@@ -32,7 +32,9 @@ export default {
 
onFormSubmitFailure() {
this.form.find('[type="submit"]').enable();
return new Flash(__('Issue update failed'));
return createFlash({
message: __('Issue update failed'),
});
},
 
/**
Loading
Loading
import $ from 'jquery';
import { joinPaths } from '~/lib/utils/url_utility';
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 axios from './lib/utils/axios_utils';
import { addDelimiter } from './lib/utils/text_utility';
Loading
Loading
@@ -68,7 +68,9 @@ export default class Issue {
this.createMergeRequestDropdown.checkAbilityToCreateBranch();
}
} else {
flash(issueFailMessage);
createFlash({
message: issueFailMessage,
});
}
}
 
Loading
Loading
@@ -102,6 +104,10 @@ export default class Issue {
$container.html(data.html);
}
})
.catch(() => flash(__('Failed to load related branches')));
.catch(() =>
createFlash({
message: __('Failed to load related branches'),
}),
);
}
}
Loading
Loading
@@ -6,7 +6,7 @@ import {
GlSafeHtmlDirective as SafeHtml,
} from '@gitlab/ui';
import { toNumber, omit } from 'lodash';
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils';
import {
scrollToElement,
Loading
Loading
@@ -265,7 +265,9 @@ export default {
})
.catch(() => {
this.loading = false;
return flash(__('An error occurred while loading issues'));
return createFlash({
message: __('An error occurred while loading issues'),
});
});
},
getQueryObject() {
Loading
Loading
import Visibility from 'visibilityjs';
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils';
import { setFaviconOverlay, resetFavicon } from '~/lib/utils/favicon';
import httpStatusCodes from '~/lib/utils/http_status';
Loading
Loading
@@ -99,7 +99,9 @@ export const receiveJobSuccess = ({ commit }, data = {}) => {
};
export const receiveJobError = ({ commit }) => {
commit(types.RECEIVE_JOB_ERROR);
flash(__('An error occurred while fetching the job.'));
createFlash({
message: __('An error occurred while fetching the job.'),
});
resetFavicon();
};
 
Loading
Loading
@@ -197,11 +199,15 @@ export const stopPollingTrace = ({ state, commit }) => {
export const receiveTraceSuccess = ({ commit }, log) => commit(types.RECEIVE_TRACE_SUCCESS, log);
export const receiveTraceError = ({ dispatch }) => {
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 }) => {
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
Loading
Loading
@@ -240,7 +246,9 @@ export const receiveJobsForStageSuccess = ({ commit }, data) =>
commit(types.RECEIVE_JOBS_FOR_STAGE_SUCCESS, data);
export const receiveJobsForStageError = ({ commit }) => {
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) => {
Loading
Loading
@@ -254,5 +262,9 @@ export const triggerManualJob = ({ state }, variables) => {
.post(state.job.status.action.path, {
job_variables_attributes: parsedVariables,
})
.catch(() => flash(__('An error occurred while triggering the job.')));
.catch(() =>
createFlash({
message: __('An error occurred while triggering the job.'),
}),
);
};
Loading
Loading
@@ -3,7 +3,7 @@
import $ from 'jquery';
import Sortable from 'sortablejs';
import { dispose } from '~/tooltips';
import { deprecatedCreateFlash as flash } from './flash';
import createFlash from './flash';
import axios from './lib/utils/axios_utils';
import { __ } from './locale';
 
Loading
Loading
@@ -111,7 +111,11 @@ export default class LabelManager {
}
 
onPrioritySortUpdate() {
this.savePrioritySort().catch(() => flash(this.errorMessage));
this.savePrioritySort().catch(() =>
createFlash({
message: this.errorMessage,
}),
);
}
 
savePrioritySort() {
Loading
Loading
@@ -123,7 +127,9 @@ export default class LabelManager {
rollbackLabelPosition($label, originalAction) {
const action = originalAction === 'remove' ? 'add' : 'remove';
this.toggleLabelPriority($label, action, false);
flash(this.errorMessage);
createFlash({
message: this.errorMessage,
});
}
 
getSortedLabelsIds() {
Loading
Loading
Loading
Loading
@@ -8,7 +8,7 @@ import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
import { isScopedLabel } from '~/lib/utils/common_utils';
import boardsStore from './boards/stores/boards_store';
import CreateLabelDropdown from './create_label';
import { deprecatedCreateFlash as flash } from './flash';
import createFlash from './flash';
import IssuableBulkUpdateActions from './issuable_bulk_update_actions';
import axios from './lib/utils/axios_utils';
import { sprintf, __ } from './locale';
Loading
Loading
@@ -148,7 +148,11 @@ export default class LabelsSelect {
container: 'body',
});
})
.catch(() => flash(__('Error saving label update.')));
.catch(() =>
createFlash({
message: __('Error saving label update.'),
}),
);
};
initDeprecatedJQueryDropdown($dropdown, {
showMenuAbove,
Loading
Loading
@@ -183,7 +187,11 @@ export default class LabelsSelect {
$dropdown.data('deprecatedJQueryDropdown').positionMenuAbove();
}
})
.catch(() => flash(__('Error fetching labels.')));
.catch(() =>
createFlash({
message: __('Error fetching labels.'),
}),
);
},
renderRow(label) {
let colorEl;
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
import { GlButton } from '@gitlab/ui';
import { debounce } from 'lodash';
import { mapActions } from 'vuex';
import { deprecatedCreateFlash as flash } from '~/flash';
import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils';
import { __ } from '~/locale';
import { INTERACTIVE_RESOLVE_MODE } from '../constants';
Loading
Loading
@@ -75,7 +75,9 @@ export default {
},
)
.catch(() => {
flash(__('An error occurred while loading the file'));
createFlash({
message: __('An error occurred while loading the file'),
});
});
},
saveDiffResolution() {
Loading
Loading
Loading
Loading
@@ -8,7 +8,7 @@ import createEventHub from '~/helpers/event_hub_factory';
import initAddContextCommitsTriggers from './add_context_commits_modal';
import BlobForkSuggestion from './blob/blob_fork_suggestion';
import Diff from './diff';
import { deprecatedCreateFlash as flash } from './flash';
import createFlash from './flash';
import initChangesDropdown from './init_changes_dropdown';
import axios from './lib/utils/axios_utils';
import {
Loading
Loading
@@ -345,7 +345,9 @@ export default class MergeRequestTabs {
})
.catch(() => {
this.toggleLoading(false);
flash(__('An error occurred while fetching this tab.'));
createFlash({
message: __('An error occurred while fetching this tab.'),
});
});
}
 
Loading
Loading
@@ -446,7 +448,9 @@ export default class MergeRequestTabs {
})
.catch(() => {
this.toggleLoading(false);
flash(__('An error occurred while fetching this tab.'));
createFlash({
message: __('An error occurred while fetching this tab.'),
});
});
}
 
Loading
Loading
import $ from 'jquery';
import { deprecatedCreateFlash as flash } from './flash';
import createFlash from './flash';
import axios from './lib/utils/axios_utils';
import { __ } from './locale';
 
Loading
Loading
@@ -39,7 +39,11 @@ export default class Milestone {
$(tabElId).html(data.html);
$target.addClass('is-loaded');
})
.catch(() => flash(__('Error loading milestone tab')));
.catch(() =>
createFlash({
message: __('Error loading milestone tab'),
}),
);
}
}
}
import $ from 'jquery';
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 { hide } from '~/tooltips';
Loading
Loading
@@ -111,7 +111,11 @@ export default class MirrorRepos {
return axios
.put(this.mirrorEndpoint, payload)
.then(() => this.removeRow($target))
.catch(() => Flash(__('Failed to remove mirror.')));
.catch(() =>
createFlash({
message: __('Failed to remove mirror.'),
}),
);
}
 
/* eslint-disable class-methods-use-this */
Loading
Loading
import $ from 'jquery';
import { escape } from 'lodash';
import { deprecatedCreateFlash as Flash } from '~/flash';
import createFlash from '~/flash';
import axios from '~/lib/utils/axios_utils';
import { backOff } from '~/lib/utils/common_utils';
import { __ } from '~/locale';
Loading
Loading
@@ -115,7 +115,9 @@ export default class SSHMirror {
const failureMessage = response.data
? response.data.message
: __('An error occurred while detecting host keys');
Flash(failureMessage);
createFlash({
message: failureMessage,
});
 
$btnLoadSpinner.addClass('hidden');
this.$btnDetectHostKeys.enable();
Loading
Loading
import { deprecatedCreateFlash as Flash } from '~/flash';
import createFlash from '~/flash';
import { getParameterByName } from '~/lib/utils/common_utils';
import { initRails } from '~/lib/utils/rails_ujs';
import { __, sprintf } from '~/locale';
Loading
Loading
@@ -18,8 +18,10 @@ export default function leaveByUrl(namespaceType) {
if (leaveLink) {
leaveLink.click();
} else {
Flash(
sprintf(__('You do not have permission to leave this %{namespaceType}.'), { namespaceType }),
);
createFlash({
message: sprintf(__('You do not have permission to leave this %{namespaceType}.'), {
namespaceType,
}),
});
}
}
Loading
Loading
@@ -14,7 +14,7 @@ import $ from 'jquery';
import { mapActions, mapGetters, mapState } from 'vuex';
import Autosave from '~/autosave';
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 httpStatusCodes from '~/lib/utils/http_status';
import {
Loading
Loading
@@ -293,7 +293,11 @@ export default {
toggleState()
.then(() => statusBoxState.updateStatus && statusBoxState.updateStatus())
.then(refreshUserMergeRequestCounts)
.catch(() => Flash(constants.toggleStateErrorMessage[this.noteableType][this.openState]));
.catch(() =>
createFlash({
message: constants.toggleStateErrorMessage[this.noteableType][this.openState],
}),
);
},
discard(shouldClear = true) {
// `blur` is needed to clear slash commands autocomplete cache if event fired.
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@ import { GlTooltipDirective, GlIcon, GlButton, GlDropdownItem } from '@gitlab/ui
import { mapActions, mapGetters } from 'vuex';
import Api from '~/api';
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 { __, sprintf } from '~/locale';
import eventHub from '~/sidebar/event_hub';
Loading
Loading
@@ -234,7 +234,11 @@ export default {
assignee_ids: assignees.map((assignee) => assignee.id),
})
.then(() => this.handleAssigneeUpdate(assignees))
.catch(() => flash(__('Something went wrong while updating assignees')));
.catch(() =>
createFlash({
message: __('Something went wrong while updating assignees'),
}),
);
}
},
setAwardEmoji(awardName) {
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
import { mapActions, mapGetters } from 'vuex';
import { __ } from '~/locale';
import AwardsList from '~/vue_shared/components/awards_list.vue';
import { deprecatedCreateFlash as Flash } from '../../flash';
import createFlash from '../../flash';
 
export default {
components: {
Loading
Loading
@@ -48,7 +48,11 @@ export default {
awardName,
};
 
this.toggleAwardRequest(data).catch(() => Flash(__('Something went wrong on our end.')));
this.toggleAwardRequest(data).catch(() =>
createFlash({
message: __('Something went wrong on our end.'),
}),
);
},
},
};
Loading
Loading
Loading
Loading
@@ -6,7 +6,7 @@ import { clearDraft, getDiscussionReplyKey } from '~/lib/utils/autosave';
import { s__, __ } from '~/locale';
import diffLineNoteFormMixin from '~/notes/mixins/diff_line_note_form';
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 eventHub from '../event_hub';
import noteable from '../mixins/noteable';
Loading
Loading
@@ -220,7 +220,11 @@ export default {
const msg = __(
'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;
callback(err);
});
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment