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:
authorPhil Hughes <me@iamphill.com>2018-08-01 19:16:21 +0300
committerPhil Hughes <me@iamphill.com>2018-08-01 19:16:21 +0300
commit3f4aaea26c65391098e9e424c4550493a1c525cb (patch)
tree104086d742b61c069aa3f0e9bd65fbecdd6375cc /app/assets/javascripts/ide/stores/actions
parent100c68eecd7ba6f950d1f23d339a2f1ec55675d8 (diff)
correctly show renaming and deleting entries
for folders, it shows all the files in commit mode for files, nothing changes, the behaviour is the same
Diffstat (limited to 'app/assets/javascripts/ide/stores/actions')
-rw-r--r--app/assets/javascripts/ide/stores/actions/file.js23
-rw-r--r--app/assets/javascripts/ide/stores/actions/tree.js10
2 files changed, 28 insertions, 5 deletions
diff --git a/app/assets/javascripts/ide/stores/actions/file.js b/app/assets/javascripts/ide/stores/actions/file.js
index b343750f789..9e3f5da4676 100644
--- a/app/assets/javascripts/ide/stores/actions/file.js
+++ b/app/assets/javascripts/ide/stores/actions/file.js
@@ -62,14 +62,14 @@ export const setFileActive = ({ commit, state, getters, dispatch }, path) => {
export const getFileData = ({ state, commit, dispatch }, { path, makeFileActive = true }) => {
const file = state.entries[path];
- if (file.raw || file.tempFile) return Promise.resolve();
+ if (file.raw || (file.tempFile && !file.prevPath)) return Promise.resolve();
commit(types.TOGGLE_LOADING, { entry: file });
+ const url = file.prevPath ? file.url.replace(file.path, file.prevPath) : file.url;
+
return service
- .getFileData(
- `${gon.relative_url_root ? gon.relative_url_root : ''}${file.url.replace('/-/', '/')}`,
- )
+ .getFileData(`${gon.relative_url_root ? gon.relative_url_root : ''}${url.replace('/-/', '/')}`)
.then(({ data, headers }) => {
const normalizedHeaders = normalizeHeaders(headers);
setPageTitle(decodeURI(normalizedHeaders['PAGE-TITLE']));
@@ -101,7 +101,7 @@ export const getRawFileData = ({ state, commit, dispatch }, { path, baseSha }) =
service
.getRawFileData(file)
.then(raw => {
- if (!file.tempFile) commit(types.SET_FILE_RAW_DATA, { file, raw });
+ if (!(file.tempFile && !file.prevPath)) commit(types.SET_FILE_RAW_DATA, { file, raw });
if (file.mrChange && file.mrChange.new_file === false) {
service
.getBaseRawFileData(file, baseSha)
@@ -176,9 +176,22 @@ export const setFileViewMode = ({ commit }, { file, viewMode }) => {
export const discardFileChanges = ({ dispatch, state, commit, getters }, path) => {
const file = state.entries[path];
+ if (file.deleted && file.parentPath) {
+ dispatch('restoreTree', file.parentPath);
+ }
+
+ if (file.movedPath) {
+ commit(types.DISCARD_FILE_CHANGES, file.movedPath);
+ commit(types.REMOVE_FILE_FROM_CHANGED, file.movedPath);
+ }
+
commit(types.DISCARD_FILE_CHANGES, path);
commit(types.REMOVE_FILE_FROM_CHANGED, path);
+ if (file.prevPath) {
+ dispatch('discardFileChanges', file.prevPath);
+ }
+
if (file.tempFile && file.opened) {
commit(types.TOGGLE_FILE_OPEN, path);
} else if (getters.activeFile && file.path === getters.activeFile.path) {
diff --git a/app/assets/javascripts/ide/stores/actions/tree.js b/app/assets/javascripts/ide/stores/actions/tree.js
index acb6ef5e6d4..9288bbe32f5 100644
--- a/app/assets/javascripts/ide/stores/actions/tree.js
+++ b/app/assets/javascripts/ide/stores/actions/tree.js
@@ -89,3 +89,13 @@ export const getFiles = ({ state, commit, dispatch }, { projectId, branchId } =
resolve();
}
});
+
+export const restoreTree = ({ dispatch, commit, state }, path) => {
+ const entry = state.entries[path];
+
+ commit(types.RESTORE_TREE, path);
+
+ if (entry.parentPath) {
+ dispatch('restoreTree', entry.parentPath);
+ }
+};