summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/stores/modules/commit/actions.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/ide/stores/modules/commit/actions.js')
-rw-r--r--app/assets/javascripts/ide/stores/modules/commit/actions.js36
1 files changed, 17 insertions, 19 deletions
diff --git a/app/assets/javascripts/ide/stores/modules/commit/actions.js b/app/assets/javascripts/ide/stores/modules/commit/actions.js
index 505daa8834d..592c7e15918 100644
--- a/app/assets/javascripts/ide/stores/modules/commit/actions.js
+++ b/app/assets/javascripts/ide/stores/modules/commit/actions.js
@@ -1,6 +1,6 @@
-import $ from 'jquery';
import { sprintf, __ } from '~/locale';
import flash from '~/flash';
+import httpStatusCodes from '~/lib/utils/http_status';
import * as rootTypes from '../../mutation_types';
import { createCommitPayload, createNewMergeRequestUrl } from '../../utils';
import router from '../../../ide_router';
@@ -215,25 +215,23 @@ export const commitChanges = ({ commit, state, getters, dispatch, rootState, roo
);
})
.catch(err => {
- if (err.response.status === 400) {
- $('#ide-create-branch-modal').modal('show');
- } else {
- dispatch(
- 'setErrorMessage',
- {
- text: __('An error occurred while committing your changes.'),
- action: () =>
- dispatch('commitChanges').then(() =>
- dispatch('setErrorMessage', null, { root: true }),
- ),
- actionText: __('Please try again'),
- },
- { root: true },
- );
- window.dispatchEvent(new Event('resize'));
- }
-
commit(types.UPDATE_LOADING, false);
+
+ // don't catch bad request errors, let the view handle them
+ if (err.response.status === httpStatusCodes.BAD_REQUEST) throw err;
+
+ dispatch(
+ 'setErrorMessage',
+ {
+ text: __('An error occurred while committing your changes.'),
+ action: () =>
+ dispatch('commitChanges').then(() => dispatch('setErrorMessage', null, { root: true })),
+ actionText: __('Please try again'),
+ },
+ { root: true },
+ );
+
+ window.dispatchEvent(new Event('resize'));
});
};