summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-07-30 10:39:55 +0100
committerPhil Hughes <me@iamphill.com>2018-07-30 11:45:16 +0100
commit89c56c1fe4e8b9d0815fa768e8609383defb8677 (patch)
tree1d9dd1a99a5db586f14b1050cda73434253adc04 /app/assets/javascripts/ide
parente7fe50bf6cd2d4019790c644b570042b70a3a7d7 (diff)
downloadgitlab-ce-89c56c1fe4e8b9d0815fa768e8609383defb8677.tar.gz
fixed folders not being renamed
Diffstat (limited to 'app/assets/javascripts/ide')
-rw-r--r--app/assets/javascripts/ide/components/repo_file.vue2
-rw-r--r--app/assets/javascripts/ide/stores/actions.js13
-rw-r--r--app/assets/javascripts/ide/stores/mutations.js32
-rw-r--r--app/assets/javascripts/ide/stores/utils.js2
4 files changed, 32 insertions, 17 deletions
diff --git a/app/assets/javascripts/ide/components/repo_file.vue b/app/assets/javascripts/ide/components/repo_file.vue
index 36e7cbf93b5..dbdf0be2809 100644
--- a/app/assets/javascripts/ide/components/repo_file.vue
+++ b/app/assets/javascripts/ide/components/repo_file.vue
@@ -193,7 +193,7 @@ export default {
data-container="body"
data-placement="right"
name="file-modified"
- css-classes="prepend-left-5 multi-file-modified"
+ css-classes="prepend-left-5 ide-file-modified"
/>
</span>
<changed-file-icon
diff --git a/app/assets/javascripts/ide/stores/actions.js b/app/assets/javascripts/ide/stores/actions.js
index 36ac76cb42e..6f70f297214 100644
--- a/app/assets/javascripts/ide/stores/actions.js
+++ b/app/assets/javascripts/ide/stores/actions.js
@@ -193,9 +193,16 @@ export const deleteEntry = ({ commit, dispatch, state }, path) => {
export const resetOpenFiles = ({ commit }) => commit(types.RESET_OPEN_FILES);
-export const renameEntry = ({ dispatch, commit }, { path, name }) => {
- commit(types.RENAME_ENTRY, { path, name });
- dispatch('deleteEntry', path);
+export const renameEntry = ({ dispatch, commit, state }, { path, name, entryPath = null }) => {
+ commit(types.RENAME_ENTRY, { path, name, entryPath });
+
+ state.entries[entryPath || path].tree.forEach(f =>
+ dispatch('renameEntry', { path, name, entryPath: f.path }),
+ );
+
+ if (!entryPath) {
+ dispatch('deleteEntry', path);
+ }
};
export * from './actions/tree';
diff --git a/app/assets/javascripts/ide/stores/mutations.js b/app/assets/javascripts/ide/stores/mutations.js
index 8060ead5728..40baa3e7c6a 100644
--- a/app/assets/javascripts/ide/stores/mutations.js
+++ b/app/assets/javascripts/ide/stores/mutations.js
@@ -201,27 +201,35 @@ export default {
state.changedFiles = state.changedFiles.concat(entry);
parent.tree = parent.tree.filter(f => f.path !== entry.path);
},
- [types.RENAME_ENTRY](state, { path, name }) {
- const oldEntry = state.entries[path];
- const parent = oldEntry.parentPath
- ? state.entries[oldEntry.parentPath]
- : state.trees[`${state.currentProjectId}/${state.currentBranchId}`];
- const nameRegex = new RegExp(`${oldEntry.name}$`);
- const newPath = path.replace(nameRegex, name);
+ [types.RENAME_ENTRY](state, { path, name, entryPath = null }) {
+ const oldEntry = state.entries[entryPath || path];
+ const nameRegex = new RegExp(`^${path}`);
+ const newPath = oldEntry.path.replace(nameRegex, name);
+ const parentPath = oldEntry.parentPath ? oldEntry.parentPath.replace(nameRegex, name) : '';
state.entries[newPath] = {
...oldEntry,
id: newPath,
key: `${name}-${oldEntry.type}-${oldEntry.id}`,
path: newPath,
- name,
+ name: entryPath ? oldEntry.name : name,
tempFile: true,
- prevPath: path,
- url: oldEntry.url.replace(nameRegex, name),
+ prevPath: oldEntry.path,
+ url: oldEntry.url.replace(new RegExp(`${oldEntry.path}/?$`), newPath),
+ tree: [],
+ parentPath,
};
oldEntry.moved = true;
- parent.tree = parent.tree.concat(state.entries[newPath]);
- state.changedFiles = state.changedFiles.concat(state.entries[newPath]);
+
+ const parent = parentPath
+ ? state.entries[parentPath]
+ : state.trees[`${state.currentProjectId}/${state.currentBranchId}`];
+
+ parent.tree = sortTree(parent.tree.concat(state.entries[newPath]));
+
+ if (!entryPath) {
+ state.changedFiles = state.changedFiles.concat(state.entries[newPath]);
+ }
},
...projectMutations,
...mergeRequestMutation,
diff --git a/app/assets/javascripts/ide/stores/utils.js b/app/assets/javascripts/ide/stores/utils.js
index 5f0e425d2d3..7bf5e0ae2f6 100644
--- a/app/assets/javascripts/ide/stores/utils.js
+++ b/app/assets/javascripts/ide/stores/utils.js
@@ -124,7 +124,7 @@ export const getCommitFiles = (stagedFiles, deleteTree = false) =>
stagedFiles.reduce((acc, file) => {
if (file.moved) return acc;
- if ((file.deleted || deleteTree) && file.type === 'tree') {
+ if ((file.deleted || deleteTree || file.prevPath) && file.type === 'tree') {
return acc.concat(getCommitFiles(file.tree, true));
}