summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/stores/mutations/file.js
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-07-26 14:56:56 +0000
committerTim Zallmann <tzallmann@gitlab.com>2018-07-26 14:56:56 +0000
commitcded268ca1d49fe93b8e0940586e9792347c88c3 (patch)
tree9d84a5e8ae38e53514b6ab1f4e99d38ddf2fe138 /app/assets/javascripts/ide/stores/mutations/file.js
parent8873840839811948b2f29175177b91bcf806a3f8 (diff)
downloadgitlab-ce-cded268ca1d49fe93b8e0940586e9792347c88c3.tar.gz
Enable deleting files in the Web IDE
Diffstat (limited to 'app/assets/javascripts/ide/stores/mutations/file.js')
-rw-r--r--app/assets/javascripts/ide/stores/mutations/file.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/app/assets/javascripts/ide/stores/mutations/file.js b/app/assets/javascripts/ide/stores/mutations/file.js
index 46547820425..9a87d50d6d5 100644
--- a/app/assets/javascripts/ide/stores/mutations/file.js
+++ b/app/assets/javascripts/ide/stores/mutations/file.js
@@ -1,5 +1,6 @@
/* eslint-disable no-param-reassign */
import * as types from '../mutation_types';
+import { sortTree } from '../utils';
import { diffModes } from '../../constants';
export default {
@@ -51,9 +52,17 @@ export default {
});
},
[types.SET_FILE_RAW_DATA](state, { file, raw }) {
+ const openPendingFile = state.openFiles.find(
+ f => f.path === file.path && f.pending && !f.tempFile,
+ );
+
Object.assign(state.entries[file.path], {
raw,
});
+
+ if (openPendingFile) {
+ openPendingFile.raw = raw;
+ }
},
[types.SET_FILE_BASE_RAW_DATA](state, { file, baseRaw }) {
Object.assign(state.entries[file.path], {
@@ -109,11 +118,22 @@ export default {
},
[types.DISCARD_FILE_CHANGES](state, path) {
const stagedFile = state.stagedFiles.find(f => f.path === path);
+ const entry = state.entries[path];
+ const { deleted } = entry;
Object.assign(state.entries[path], {
content: stagedFile ? stagedFile.content : state.entries[path].raw,
changed: false,
+ deleted: false,
});
+
+ if (deleted) {
+ const parent = entry.parentPath
+ ? state.entries[entry.parentPath]
+ : state.trees[`${state.currentProjectId}/${state.currentBranchId}`];
+
+ parent.tree = sortTree(parent.tree.concat(entry));
+ }
},
[types.ADD_FILE_TO_CHANGED](state, path) {
Object.assign(state, {