diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-14 12:08:19 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-14 12:08:19 +0300 |
commit | 02ab65d49fc94be7c91e511899762236c122977d (patch) | |
tree | 4d4bf4ec54a95a0d73e039fa1410ea841156ffb2 /app/assets/javascripts/ide/stores/actions | |
parent | 4411353300cf8219d2b899785bc5103c549ba8cf (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/ide/stores/actions')
-rw-r--r-- | app/assets/javascripts/ide/stores/actions/file.js | 55 |
1 files changed, 32 insertions, 23 deletions
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); |