import SourceViewer from './../../../components/SourceViewer/SourceViewer';
import Search from './Search';
import ListFooter from '../../../components/controls/ListFooter';
-import {
- retrieveComponentChildren,
- retrieveComponent,
- loadMoreChildren,
- parseError
-} from '../utils';
+import { retrieveComponentChildren, retrieveComponent, loadMoreChildren } from '../utils';
+import { parseError } from '../../../helpers/request';
import { addComponent, addComponentBreadcrumbs, clearBucket } from '../bucket';
import { getBranchName } from '../../../helpers/branches';
import { translate } from '../../../helpers/l10n';
import * as classNames from 'classnames';
import Components from './Components';
import { getTree } from '../../../api/components';
-import { parseError } from '../utils';
+import { parseError } from '../../../helpers/request';
import { getProjectUrl } from '../../../helpers/urls';
import { Component } from '../types';
import SearchBox from '../../../components/controls/SearchBox';
} from './bucket';
import { Breadcrumb, Component } from './types';
import { getChildren, getComponent, getBreadcrumbs } from '../../api/components';
-import { translate } from '../../helpers/l10n';
const METRICS = [
'ncloc',
return r;
});
}
-
-/** Parse response of failed request */
-export function parseError(error: { response: Response }): Promise<string> {
- const DEFAULT_MESSAGE = translate('default_error_message');
-
- try {
- return error.response
- .json()
- .then(r => r.errors.map((error: any) => error.msg).join('. '))
- .catch(() => DEFAULT_MESSAGE);
- } catch (ex) {
- return Promise.resolve(DEFAULT_MESSAGE);
- }
-}
*/
import FormView from './FormView';
import { createPermissionTemplate } from '../../../api/permissions';
-import { parseError } from '../../code/utils';
+import { parseError } from '../../../helpers/request';
export default FormView.extend({
sendRequest() {
import ModalForm from '../../../components/common/modal-form';
import { deletePermissionTemplate } from '../../../api/permissions';
import Template from '../templates/permission-templates-delete.hbs';
-import { parseError } from '../../code/utils';
+import { parseError } from '../../../helpers/request';
export default ModalForm.extend({
template: Template,
*/
import FormView from './FormView';
import { updatePermissionTemplate } from '../../../api/permissions';
-import { parseError } from '../../code/utils';
+import { parseError } from '../../../helpers/request';
export default FormView.extend({
sendRequest() {
*/
// @flow
import * as api from '../../../../api/permissions';
-import { parseError } from '../../../code/utils';
+import { parseError } from '../../../../helpers/request';
import {
raiseError,
REQUEST_HOLDERS,
import BulkUpdateResults from './BulkUpdateResults';
import { translate, translateWithParameters } from '../../../helpers/l10n';
import { bulkChangeKey } from '../../../api/components';
-import { parseError } from '../../code/utils';
+import { parseError } from '../../../helpers/request';
import {
addGlobalErrorMessage,
addGlobalSuccessMessage,
closeAllGlobalMessages,
addGlobalSuccessMessage
} from '../../../store/globalMessages/duck';
-import { parseError } from '../../code/utils';
+import { parseError } from '../../../helpers/request';
import { reloadUpdateKeyPage } from './utils';
import RecentHistory from '../../../app/components/RecentHistory';
import { getProjectAdminProjectModules } from '../../../store/rootReducer';
*/
import ModalForm from '../../../../components/common/modal-form';
import Template from './CreationModalTemplate.hbs';
-import { parseError } from '../../../code/utils';
+import { parseError } from '../../../../helpers/request';
export default ModalForm.extend({
template: Template,
import ModalForm from '../../../../components/common/modal-form';
import Template from './DeletionModalTemplate.hbs';
import { deleteLink } from '../../../../api/projectLinks';
-import { parseError } from '../../../code/utils';
+import { parseError } from '../../../../helpers/request';
export default ModalForm.extend({
template: Template,
import ModalForm from '../../../components/common/modal-form';
import Template from '../templates/quality-gate-form.hbs';
import { copyQualityGate } from '../../../api/quality-gates';
-import { parseError } from '../../code/utils';
+import { parseError } from '../../../helpers/request';
export default ModalForm.extend({
template: Template,
import ModalForm from '../../../components/common/modal-form';
import Template from '../templates/quality-gate-form.hbs';
import { createQualityGate } from '../../../api/quality-gates';
-import { parseError } from '../../code/utils';
+import { parseError } from '../../../helpers/request';
export default ModalForm.extend({
template: Template,
import ModalForm from '../../../components/common/modal-form';
import Template from '../templates/quality-gates-delete.hbs';
import { deleteQualityGate } from '../../../api/quality-gates';
-import { parseError } from '../../code/utils';
+import { parseError } from '../../../helpers/request';
export default ModalForm.extend({
template: Template,
import Template from '../templates/quality-gates-condition-delete.hbs';
import { deleteCondition } from '../../../api/quality-gates';
import { getLocalizedMetricName } from '../../../helpers/l10n';
-import { parseError } from '../../code/utils';
+import { parseError } from '../../../helpers/request';
export default ModalForm.extend({
template: Template,
import ModalForm from '../../../components/common/modal-form';
import Template from '../templates/quality-gate-form.hbs';
import { renameQualityGate } from '../../../api/quality-gates';
-import { parseError } from '../../code/utils';
+import { parseError } from '../../../helpers/request';
export default ModalForm.extend({
template: Template,
import { connect } from 'react-redux';
import { translate, translateWithParameters } from '../../../helpers/l10n';
import { sendTestEmail } from '../../../api/settings';
-import { parseError } from '../../code/utils';
+import { parseError } from '../../../helpers/request';
import { getCurrentUser } from '../../../store/rootReducer';
class EmailForm extends React.PureComponent {
import { receiveValues } from './values/actions';
import { receiveDefinitions } from './definitions/actions';
import { startLoading, stopLoading } from './settingsPage/loading/actions';
-import { parseError } from '../../code/utils';
+import { parseError } from '../../../helpers/request';
import { addGlobalErrorMessage, closeAllGlobalMessages } from '../../../store/globalMessages/duck';
import { passValidation, failValidation } from './settingsPage/validationMessages/actions';
import { cancelChange } from './settingsPage/changedValues/actions';
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import * as api from '../../../../api/settings';
-import { parseError } from '../../../code/utils';
+import { parseError } from '../../../../helpers/request';
import {
addGlobalErrorMessage,
closeAllGlobalMessages
import * as actionCreators from '../../store/favorites/duck';
import * as api from '../../api/favorites';
import { addGlobalErrorMessage } from '../../store/globalMessages/duck';
-import { parseError } from '../../apps/code/utils';
+import { parseError } from '../../helpers/request';
const addFavorite = (componentKey: string) => (dispatch: Function) => {
// optimistic update
import { stringify } from 'querystring';
import { omitBy, isNil } from 'lodash';
import { getCookie } from './cookies';
+import { translate } from './l10n';
export function getCSRFTokenName(): string {
return 'X-XSRF-TOKEN';
return response.json();
}
+/**
+ * Parse response of failed request
+ */
+export function parseError(error: { response: Response }): Promise<string> {
+ const DEFAULT_MESSAGE = translate('default_error_message');
+
+ try {
+ return error.response
+ .json()
+ .then(r => r.errors.map((error: any) => error.msg).join('. '))
+ .catch(() => DEFAULT_MESSAGE);
+ } catch (ex) {
+ return Promise.resolve(DEFAULT_MESSAGE);
+ }
+}
+
/**
* Shortcut to do a GET request and return response json
*/
import { receiveLanguages } from './languages/actions';
import { receiveMetrics } from './metrics/actions';
import { addGlobalErrorMessage } from './globalMessages/duck';
-import { parseError } from '../apps/code/utils';
+import { parseError } from '../helpers/request';
import { setAppState } from './appState/duck';
import { receiveOrganizations } from './organizations/duck';