diff options
author | Paul Slaughter <pslaughter@gitlab.com> | 2019-03-19 10:04:48 -0500 |
---|---|---|
committer | Paul Slaughter <pslaughter@gitlab.com> | 2019-03-19 10:04:48 -0500 |
commit | 210a0a90049aafab7751055493738d0e781a30bc (patch) | |
tree | 6d72218a05f656947f988753b9016cb2c13c2787 | |
parent | 31042747d92f24fb5cfa558a21f2e99b3e33aecb (diff) | |
download | gitlab-ce-web-ide-new-file.tar.gz |
-rw-r--r-- | app/assets/javascripts/ide/lib/files.js | 6 | ||||
-rw-r--r-- | app/assets/javascripts/ide/stores/actions/project.js | 4 | ||||
-rw-r--r-- | app/assets/javascripts/ide/stores/actions/tree.js | 12 |
3 files changed, 11 insertions, 11 deletions
diff --git a/app/assets/javascripts/ide/lib/files.js b/app/assets/javascripts/ide/lib/files.js index 5dfba8fe531..05c3ce92ec3 100644 --- a/app/assets/javascripts/ide/lib/files.js +++ b/app/assets/javascripts/ide/lib/files.js @@ -21,7 +21,6 @@ export const decorateFiles = ({ content = '', base64 = false, }) => { - const treeList = []; const entries = {}; // These mutable variable references end up being exported and used by `createTempEntry` @@ -60,8 +59,6 @@ export const decorateFiles = ({ if (parentFolder) { parentFolder.tree.push(tree); - } else { - treeList.push(tree); } return tree; @@ -98,15 +95,12 @@ export const decorateFiles = ({ if (fileFolder) { fileFolder.tree.push(file); - } else { - treeList.push(file); } } }); return { entries, - treeList: sortTree(treeList), file, parentPath, }; diff --git a/app/assets/javascripts/ide/stores/actions/project.js b/app/assets/javascripts/ide/stores/actions/project.js index a9de3ce975f..db74f6de9e5 100644 --- a/app/assets/javascripts/ide/stores/actions/project.js +++ b/app/assets/javascripts/ide/stores/actions/project.js @@ -148,7 +148,7 @@ export const openBranch = ({ dispatch, state }, { projectId, branchId, basePath if (treeEntry) { dispatch('handleTreeEntryAction', treeEntry); } else { - dispatch('createTempEntry', { name: path, type: 'blob' }); + setTimeout(() => dispatch('createTempEntry', { name: path, type: 'blob' }), 3000); } } }) @@ -157,5 +157,5 @@ export const openBranch = ({ dispatch, state }, { projectId, branchId, basePath projectId, branchId, }); - }) + }); }; diff --git a/app/assets/javascripts/ide/stores/actions/tree.js b/app/assets/javascripts/ide/stores/actions/tree.js index 3d83e4a9ba5..6c0effc0e27 100644 --- a/app/assets/javascripts/ide/stores/actions/tree.js +++ b/app/assets/javascripts/ide/stores/actions/tree.js @@ -3,6 +3,7 @@ import { __ } from '../../../locale'; import service from '../../services'; import * as types from '../mutation_types'; import { decorateFiles } from '../../lib/files'; +import { sortTree } from '../utils'; export const toggleTreeOpen = ({ commit }, path) => { commit(types.TOGGLE_TREE_OPEN, path); @@ -33,8 +34,13 @@ export const handleTreeEntryAction = ({ commit, dispatch }, row) => { dispatch('showTreeEntry', row.path); }; -export const setDirectoryData = ({ state, commit }, { projectId, branchId, treeList }) => { +export const setDirectoryData = ({ state, commit }, { projectId, branchId }) => { const selectedTree = state.trees[`${projectId}/${branchId}`]; + const { entries } = state; + + // build treeList from entries + const treeList = sortTree(Object.values(entries).filter(x => !x.parentPath)); + console.log(treeList); commit(types.SET_DIRECTORY_DATA, { treePath: `${projectId}/${branchId}`, @@ -59,7 +65,7 @@ export const getFiles = ({ state, commit, dispatch }, { projectId, branchId } = service .getFiles(selectedProject.web_url, branchId) .then(({ data }) => { - const { entries, treeList } = decorateFiles({ + const { entries } = decorateFiles({ data, projectId, branchId, @@ -69,7 +75,7 @@ export const getFiles = ({ state, commit, dispatch }, { projectId, branchId } = // Defer setting the directory data because this triggers some intense rendering. // The entries is all we need to load the file editor. - _.defer(() => dispatch('setDirectoryData', { projectId, branchId, treeList })); + _.defer(() => dispatch('setDirectoryData', { projectId, branchId })); resolve(); }) |