Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-01-14 12:08:19 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-01-14 12:08:19 +0300
commit02ab65d49fc94be7c91e511899762236c122977d (patch)
tree4d4bf4ec54a95a0d73e039fa1410ea841156ffb2 /app/assets/javascripts/ide/stores
parent4411353300cf8219d2b899785bc5103c549ba8cf (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/ide/stores')
-rw-r--r--app/assets/javascripts/ide/stores/actions.js16
-rw-r--r--app/assets/javascripts/ide/stores/actions/file.js55
2 files changed, 33 insertions, 38 deletions
diff --git a/app/assets/javascripts/ide/stores/actions.js b/app/assets/javascripts/ide/stores/actions.js
index 66a89582da3..7ffb430296b 100644
--- a/app/assets/javascripts/ide/stores/actions.js
+++ b/app/assets/javascripts/ide/stores/actions.js
@@ -16,21 +16,7 @@ export const redirectToUrl = (self, url) => visitUrl(url);
export const setInitialData = ({ commit }, data) => commit(types.SET_INITIAL_DATA, data);
export const discardAllChanges = ({ state, commit, dispatch }) => {
- state.changedFiles.forEach(file => {
- if (file.tempFile || file.prevPath) dispatch('closeFile', file);
-
- if (file.tempFile) {
- dispatch('deleteEntry', file.path);
- } else if (file.prevPath) {
- dispatch('renameEntry', {
- path: file.path,
- name: file.prevName,
- parentPath: file.prevParentPath,
- });
- } else {
- commit(types.DISCARD_FILE_CHANGES, file.path);
- }
- });
+ state.changedFiles.forEach(file => dispatch('restoreOriginalFile', file.path));
commit(types.REMOVE_ALL_CHANGES_FILES);
};
diff --git a/app/assets/javascripts/ide/stores/actions/file.js b/app/assets/javascripts/ide/stores/actions/file.js
index 99e13e32ba4..1bfee7b6be4 100644
--- a/app/assets/javascripts/ide/stores/actions/file.js
+++ b/app/assets/javascripts/ide/stores/actions/file.js
@@ -191,38 +191,47 @@ export const setFileViewMode = ({ commit }, { file, viewMode }) => {
commit(types.SET_FILE_VIEWMODE, { file, viewMode });
};
-export const discardFileChanges = ({ dispatch, state, commit, getters }, path) => {
+export const restoreOriginalFile = ({ dispatch, state, commit }, path) => {
const file = state.entries[path];
+ const isDestructiveDiscard = file.tempFile || file.prevPath;
if (file.deleted && file.parentPath) {
dispatch('restoreTree', file.parentPath);
}
- if (file.tempFile || file.prevPath) {
+ if (isDestructiveDiscard) {
dispatch('closeFile', file);
+ }
- if (file.tempFile) {
- dispatch('deleteEntry', file.path);
- } else {
- commit(types.DISCARD_FILE_CHANGES, file.path);
- dispatch('renameEntry', {
- path: file.path,
- name: file.prevName,
- parentPath: file.prevParentPath,
- });
- }
+ if (file.tempFile) {
+ dispatch('deleteEntry', file.path);
} else {
- commit(types.DISCARD_FILE_CHANGES, path);
-
- if (getters.activeFile && file.path === getters.activeFile.path) {
- dispatch('updateDelayViewerUpdated', true)
- .then(() => {
- router.push(`/project${file.url}`);
- })
- .catch(e => {
- throw e;
- });
- }
+ commit(types.DISCARD_FILE_CHANGES, file.path);
+ }
+
+ if (file.prevPath) {
+ dispatch('renameEntry', {
+ path: file.path,
+ name: file.prevName,
+ parentPath: file.prevParentPath,
+ });
+ }
+};
+
+export const discardFileChanges = ({ dispatch, state, commit, getters }, path) => {
+ const file = state.entries[path];
+ const isDestructiveDiscard = file.tempFile || file.prevPath;
+
+ dispatch('restoreOriginalFile', path);
+
+ if (!isDestructiveDiscard && file.path === getters.activeFile?.path) {
+ dispatch('updateDelayViewerUpdated', true)
+ .then(() => {
+ router.push(`/project${file.url}`);
+ })
+ .catch(e => {
+ throw e;
+ });
}
commit(types.REMOVE_FILE_FROM_CHANGED, path);