summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/stores/actions.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/ide/stores/actions.js')
-rw-r--r--app/assets/javascripts/ide/stores/actions.js39
1 files changed, 26 insertions, 13 deletions
diff --git a/app/assets/javascripts/ide/stores/actions.js b/app/assets/javascripts/ide/stores/actions.js
index 335882bb6d7..d007d0ae78f 100644
--- a/app/assets/javascripts/ide/stores/actions.js
+++ b/app/assets/javascripts/ide/stores/actions.js
@@ -3,6 +3,7 @@ import { visitUrl } from '../../lib/utils/url_utility';
import flash from '../../flash';
import service from '../services';
import * as types from './mutation_types';
+import { stripHtml } from '../../lib/utils/text_utility';
export const redirectToUrl = (_, url) => visitUrl(url);
@@ -70,7 +71,7 @@ export const setResizingStatus = ({ commit }, resizing) => {
export const checkCommitStatus = ({ state }) =>
service
.getBranchData(state.currentProjectId, state.currentBranchId)
- .then((data) => {
+ .then(({ data }) => {
const { id } = data.commit;
const selectedBranch =
state.projects[state.currentProjectId].branches[state.currentBranchId];
@@ -81,7 +82,7 @@ export const checkCommitStatus = ({ state }) =>
return false;
})
- .catch(() => flash('Error checking branch data. Please try again.'));
+ .catch(() => flash('Error checking branch data. Please try again.', 'alert', document, null, false, true));
export const commitChanges = (
{ commit, state, dispatch, getters },
@@ -89,10 +90,10 @@ export const commitChanges = (
) =>
service
.commit(state.currentProjectId, payload)
- .then((data) => {
+ .then(({ data }) => {
const { branch } = payload;
if (!data.short_id) {
- flash(data.message);
+ flash(data.message, 'alert', document, null, false, true);
return;
}
@@ -105,19 +106,25 @@ export const commitChanges = (
},
};
+ let commitMsg = `Your changes have been committed. Commit ${data.short_id}`;
+ if (data.stats) {
+ commitMsg += ` with ${data.stats.additions} additions, ${data.stats.deletions} deletions.`;
+ }
+
flash(
- `Your changes have been committed. Commit ${data.short_id} with ${
- data.stats.additions
- } additions, ${data.stats.deletions} deletions.`,
+ commitMsg,
'notice',
- );
+ document,
+ null,
+ false,
+ true);
+ window.dispatchEvent(new Event('resize'));
if (newMr) {
+ dispatch('discardAllChanges');
dispatch(
'redirectToUrl',
- `${
- selectedProject.web_url
- }/merge_requests/new?merge_request%5Bsource_branch%5D=${branch}`,
+ `${selectedProject.web_url}/merge_requests/new?merge_request%5Bsource_branch%5D=${branch}`,
);
} else {
commit(types.SET_BRANCH_WORKING_REFERENCE, {
@@ -134,12 +141,18 @@ export const commitChanges = (
});
dispatch('discardAllChanges');
- dispatch('closeAllFiles');
window.scrollTo(0, 0);
}
})
- .catch(() => flash('Error committing changes. Please try again.'));
+ .catch((err) => {
+ let errMsg = 'Error committing changes. Please try again.';
+ if (err.response.data && err.response.data.message) {
+ errMsg += ` (${stripHtml(err.response.data.message)})`;
+ }
+ flash(errMsg, 'alert', document, null, false, true);
+ window.dispatchEvent(new Event('resize'));
+ });
export const createTempEntry = (
{ state, dispatch },