diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2017-11-30 09:17:23 +0100 |
---|---|---|
committer | Tim Zallmann <tzallmann@gitlab.com> | 2017-11-30 17:56:51 +0100 |
commit | fd63fb32ac173fa4fa1fdf1ebfabb2201d4d8415 (patch) | |
tree | 9399b34067180cf2a22299e76cebec2c4cb1a60c /app | |
parent | f3bfd86657ecc26be65a23d5a595aada84acf95d (diff) | |
download | gitlab-ce-fd63fb32ac173fa4fa1fdf1ebfabb2201d4d8415.tar.gz |
Removed single Tree from State
Cleaned up
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/ide/components/ide.vue | 2 | ||||
-rw-r--r-- | app/assets/javascripts/ide/components/ide_repo_tree.vue | 2 | ||||
-rw-r--r-- | app/assets/javascripts/ide/components/ide_side_bar.vue | 2 | ||||
-rw-r--r-- | app/assets/javascripts/ide/components/ide_status_bar.vue | 6 | ||||
-rw-r--r-- | app/assets/javascripts/ide/components/repo_file.vue | 5 | ||||
-rw-r--r-- | app/assets/javascripts/ide/ide_router.js | 19 | ||||
-rw-r--r-- | app/assets/javascripts/ide/index.js | 4 | ||||
-rw-r--r-- | app/assets/javascripts/ide/stores/actions/branch.js | 4 | ||||
-rw-r--r-- | app/assets/javascripts/ide/stores/actions/file.js | 3 | ||||
-rw-r--r-- | app/assets/javascripts/ide/stores/actions/project.js | 1 | ||||
-rw-r--r-- | app/assets/javascripts/ide/stores/actions/tree.js | 25 | ||||
-rw-r--r-- | app/assets/javascripts/ide/stores/getters.js | 12 | ||||
-rw-r--r-- | app/assets/javascripts/ide/stores/index.js | 2 | ||||
-rw-r--r-- | app/assets/javascripts/ide/stores/utils.js | 5 | ||||
-rw-r--r-- | app/assets/stylesheets/pages/ide.scss | 3 |
15 files changed, 34 insertions, 61 deletions
diff --git a/app/assets/javascripts/ide/components/ide.vue b/app/assets/javascripts/ide/components/ide.vue index d000589be16..08079d7c687 100644 --- a/app/assets/javascripts/ide/components/ide.vue +++ b/app/assets/javascripts/ide/components/ide.vue @@ -1,3 +1,5 @@ +/* global Sidebar */ + <script> import { mapState, mapGetters } from 'vuex'; import IdeSidebar from './ide_side_bar.vue'; diff --git a/app/assets/javascripts/ide/components/ide_repo_tree.vue b/app/assets/javascripts/ide/components/ide_repo_tree.vue index ccec79ea0d2..73dd6b640f9 100644 --- a/app/assets/javascripts/ide/components/ide_repo_tree.vue +++ b/app/assets/javascripts/ide/components/ide_repo_tree.vue @@ -1,5 +1,5 @@ <script> -import { mapState, mapGetters, mapActions } from 'vuex'; +import { mapState, mapGetters } from 'vuex'; import RepoPreviousDirectory from './repo_prev_directory.vue'; import RepoFile from './repo_file.vue'; import RepoLoadingFile from './repo_loading_file.vue'; diff --git a/app/assets/javascripts/ide/components/ide_side_bar.vue b/app/assets/javascripts/ide/components/ide_side_bar.vue index 628f58d3d7a..0600aee28cc 100644 --- a/app/assets/javascripts/ide/components/ide_side_bar.vue +++ b/app/assets/javascripts/ide/components/ide_side_bar.vue @@ -1,5 +1,5 @@ <script> -import { mapState, mapGetters, mapActions } from 'vuex'; +import { mapState } from 'vuex'; import ProjectTree from './ide_project_tree.vue'; export default { diff --git a/app/assets/javascripts/ide/components/ide_status_bar.vue b/app/assets/javascripts/ide/components/ide_status_bar.vue index e663459c15b..84ddf14c4cc 100644 --- a/app/assets/javascripts/ide/components/ide_status_bar.vue +++ b/app/assets/javascripts/ide/components/ide_status_bar.vue @@ -1,6 +1,6 @@ <script> -import { mapGetters, mapState } from 'vuex'; -import Icon from '../../vue_shared/components/icon.vue' +import { mapState } from 'vuex'; +import Icon from '../../vue_shared/components/icon.vue'; export default { components: { @@ -10,7 +10,7 @@ export default { ...mapState([ 'selectedFile', ]), - } + }, }; </script> diff --git a/app/assets/javascripts/ide/components/repo_file.vue b/app/assets/javascripts/ide/components/repo_file.vue index e2f33bd895f..6515852fbee 100644 --- a/app/assets/javascripts/ide/components/repo_file.vue +++ b/app/assets/javascripts/ide/components/repo_file.vue @@ -1,5 +1,4 @@ <script> - import { mapActions, mapGetters } from 'vuex'; import timeAgoMixin from '../../vue_shared/mixins/timeago'; import skeletonLoadingContainer from '../../vue_shared/components/skeleton_loading_container.vue'; @@ -18,7 +17,7 @@ collapsed: { type: Boolean, default: true, - } + }, }, computed: { isSubmodule() { @@ -49,7 +48,7 @@ methods: { clickFile(row) { this.$router.push(`/project${row.url}`); - } + }, }, }; </script> diff --git a/app/assets/javascripts/ide/ide_router.js b/app/assets/javascripts/ide/ide_router.js index da6e53a3da9..f67e106ffa8 100644 --- a/app/assets/javascripts/ide/ide_router.js +++ b/app/assets/javascripts/ide/ide_router.js @@ -18,9 +18,9 @@ Vue.use(VueRouter); /workspace/project/h5bp/html5-boilerplate/mr/123 / = /workspace -/settings - */ +/settings +*/ // Unfortunately Vue Router doesn't work without at least a fake component // If you do only data handling @@ -50,8 +50,6 @@ const router = new VueRouter({ }); router.beforeEach((to, from, next) => { - console.log('BEFORE EACH : ',to); - store.dispatch('getProjectData', { namespace: to.params.namespace, projectId: to.params.project, @@ -74,7 +72,6 @@ router.beforeEach((to, from, next) => { if (to.params[0]) { const treeEntry = store.getters.getTreeEntry(`${to.params.namespace}/${to.params.project}/${to.params.branch}`, to.params[0]); if (treeEntry) { - console.log('To Selected File : ', to.params, '/', treeEntry.url); store.dispatch('handleTreeEntryAction', treeEntry); } } else { @@ -82,20 +79,12 @@ router.beforeEach((to, from, next) => { } }) .catch((e) => { - debugger; + throw e; }); - - if (!to.params[0]) { - // We are in the root of the tree - console.log('Load Branch Tree'); - } else { - - } } }) .catch((e) => { - debugger; - //next(false); + throw e; }); next(); }); diff --git a/app/assets/javascripts/ide/index.js b/app/assets/javascripts/ide/index.js index 16359b6e7fa..9edecf15e58 100644 --- a/app/assets/javascripts/ide/index.js +++ b/app/assets/javascripts/ide/index.js @@ -111,4 +111,6 @@ initNewDropdown(newDropdownHolder); const contextualSidebar = new ContextualSidebar(); contextualSidebar.bindEvents(); -new Sidebar() +/* global Sidebar */ +// eslint-disable-next-line no-new +new Sidebar(); diff --git a/app/assets/javascripts/ide/stores/actions/branch.js b/app/assets/javascripts/ide/stores/actions/branch.js index 6a4763b66da..d5640d1cce6 100644 --- a/app/assets/javascripts/ide/stores/actions/branch.js +++ b/app/assets/javascripts/ide/stores/actions/branch.js @@ -1,7 +1,6 @@ import service from '../../services'; import flash from '../../../flash'; import * as types from '../mutation_types'; -import { pushState } from '../utils'; // eslint-disable-next-line import/prefer-default-export export const getBranchData = ( @@ -11,7 +10,6 @@ export const getBranchData = ( if ((typeof state.projects[`${namespace}/${projectId}`] === 'undefined' || !state.projects[`${namespace}/${projectId}`].branches[branch]) || enforce) { - console.log('Loading Branch ' + branch); service.getBranchData(`${namespace}/${projectId}`, branch) .then((data) => { commit(types.SET_BRANCH, { projectPath: `${namespace}/${projectId}`, branchName: branch, branch: data }); @@ -39,7 +37,7 @@ export const createNewBranch = ({ state, commit }, branch) => service.createBran const branchName = data.name; const url = location.href.replace(state.currentBranch, branchName); - pushState(url); + this.$router.push(url); commit(types.SET_CURRENT_BRANCH, branchName); }); diff --git a/app/assets/javascripts/ide/stores/actions/file.js b/app/assets/javascripts/ide/stores/actions/file.js index 88058a18552..01f0af6e91b 100644 --- a/app/assets/javascripts/ide/stores/actions/file.js +++ b/app/assets/javascripts/ide/stores/actions/file.js @@ -4,7 +4,6 @@ import service from '../../services'; import * as types from '../mutation_types'; import { findEntry, - pushState, setPageTitle, createTemp, findIndexOfFile, @@ -25,7 +24,7 @@ export const closeFile = ({ commit, state, dispatch }, { file, force = false }) dispatch('setFileActive', nextFileToOpen); } else if (!state.openFiles.length) { - pushState(file.parentTreeUrl); + this.$router.push(file.parentTreeUrl); } dispatch('getLastCommitData'); diff --git a/app/assets/javascripts/ide/stores/actions/project.js b/app/assets/javascripts/ide/stores/actions/project.js index 2a74c600ab2..a0f092b4f97 100644 --- a/app/assets/javascripts/ide/stores/actions/project.js +++ b/app/assets/javascripts/ide/stores/actions/project.js @@ -8,7 +8,6 @@ export const getProjectData = ( { namespace, projectId, enforce = false } = {}, ) => new Promise((resolve, reject) => { if (!state.projects[`${namespace}/${projectId}`] || enforce) { - console.log('Loading project exists ' + projectId); service.getProjectData(namespace, projectId) .then(res => res.data) .then((data) => { diff --git a/app/assets/javascripts/ide/stores/actions/tree.js b/app/assets/javascripts/ide/stores/actions/tree.js index b6b983088e5..c756efabac8 100644 --- a/app/assets/javascripts/ide/stores/actions/tree.js +++ b/app/assets/javascripts/ide/stores/actions/tree.js @@ -3,7 +3,6 @@ import flash from '../../../flash'; import service from '../../services'; import * as types from '../mutation_types'; import { - pushState, setPageTitle, findEntry, createTemp, @@ -33,20 +32,16 @@ export const getTreeData = ( } dispatch('updateDirectoryData', { data, tree, namespace, projectId, branch }); - if (!tree) { - // If there was no tree given one was just created - tree = state.trees[`${namespace}/${projectId}/${branch}`]; - } + const selectedTree = tree || state.trees[`${namespace}/${projectId}/${branch}`]; commit(types.SET_PARENT_TREE_URL, data.parent_tree_url); - commit(types.SET_LAST_COMMIT_URL, { tree, url: data.last_commit_path }); - if (tree) commit(types.TOGGLE_LOADING, tree); + commit(types.SET_LAST_COMMIT_URL, { tree: selectedTree, url: data.last_commit_path }); + if (tree) commit(types.TOGGLE_LOADING, selectedTree); - const prevLastCommitPath = tree.lastCommitPath; + const prevLastCommitPath = selectedTree.lastCommitPath; if (prevLastCommitPath !== null) { - dispatch('getLastCommitData', tree); + dispatch('getLastCommitData', selectedTree); } - console.log('Loaded Tree'); resolve(data); }) .catch((e) => { @@ -62,8 +57,6 @@ export const toggleTreeOpen = ({ commit, dispatch }, { endpoint, tree }) => { // send empty data to clear the tree const data = { trees: [], blobs: [], submodules: [] }; - pushState(tree.parentTreeUrl); - dispatch('updateDirectoryData', { data, tree }); } else { dispatch('getTreeData', { endpoint, tree }); @@ -156,14 +149,14 @@ export const updateDirectoryData = ( const existingTree = state.trees[`${namespace}/${projectId}/${branch}`]; if (!existingTree) { commit(types.CREATE_TREE, { treePath: `${namespace}/${projectId}/${branch}` }); - tree = state.trees[`${namespace}/${projectId}/${branch}`]; } } - const level = tree.level !== undefined ? tree.level + 1 : 0; + const selectedTree = tree || state.trees[`${namespace}/${projectId}/${branch}`]; + const level = selectedTree.level !== undefined ? selectedTree.level + 1 : 0; const parentTreeUrl = data.parent_tree_url ? `${data.parent_tree_url}${data.path}` : state.endpoints.rootUrl; const createEntry = (entry, type) => createOrMergeEntry({ - tree, + tree: selectedTree, entry, level, type, @@ -176,5 +169,5 @@ export const updateDirectoryData = ( ...data.blobs.map(b => createEntry(b, 'blob')), ]; - commit(types.SET_DIRECTORY_DATA, { tree, data: formattedData }); + commit(types.SET_DIRECTORY_DATA, { tree: selectedTree, data: formattedData }); }; diff --git a/app/assets/javascripts/ide/stores/getters.js b/app/assets/javascripts/ide/stores/getters.js index 97b20d9c4ea..309e411a0c9 100644 --- a/app/assets/javascripts/ide/stores/getters.js +++ b/app/assets/javascripts/ide/stores/getters.js @@ -7,7 +7,8 @@ import _ from 'underscore'; */ export const treeList = state => (treeId) => { if (state.trees[treeId]) { - const mapTree = arr => (!arr.tree || !arr.tree.length ? [] : _.map(arr.tree, a => [a, mapTree(a)])); + const mapTree = arr => (!arr.tree || !arr.tree.length ? + [] : _.map(arr.tree, a => [a, mapTree(a)])); return _.chain(state.trees[treeId].tree) .map(arr => [arr, mapTree(arr)]) @@ -33,18 +34,13 @@ export const activeFileExtension = (state) => { return file ? `.${file.path.split('.').pop()}` : ''; }; -export const isCollapsed = state => true; // !!state.openFiles.length; +export const isCollapsed = () => true; // ToDo: Need to remove !!state.openFiles.length; export const canEditFile = (state) => { const currentActiveFile = activeFile(state); - const openedFiles = state.openFiles; - - return true; return state.canCommit && - state.onTopOfBranch && - openedFiles.length && - (currentActiveFile && !currentActiveFile.renderError && !currentActiveFile.binary); + (currentActiveFile && !currentActiveFile.renderError && !currentActiveFile.binary); }; export const addedFiles = state => changedFiles(state).filter(f => f.tempFile); diff --git a/app/assets/javascripts/ide/stores/index.js b/app/assets/javascripts/ide/stores/index.js index 48b7266d2ae..3ad2e828bdc 100644 --- a/app/assets/javascripts/ide/stores/index.js +++ b/app/assets/javascripts/ide/stores/index.js @@ -4,7 +4,7 @@ import state from './state'; import * as actions from './actions'; import * as getters from './getters'; import mutations from './mutations'; -import ideStorage from './ide_storage'; +// import ideStorage from './ide_storage'; Vue.use(Vuex); diff --git a/app/assets/javascripts/ide/stores/utils.js b/app/assets/javascripts/ide/stores/utils.js index ef4a29313c6..b6ccb229904 100644 --- a/app/assets/javascripts/ide/stores/utils.js +++ b/app/assets/javascripts/ide/stores/utils.js @@ -78,16 +78,13 @@ export const decorateData = (entity) => { export const findEntry = (state, type, name) => state.tree.find( f => f.type === type && f.name === name, ); + export const findIndexOfFile = (state, file) => state.findIndex(f => f.path === file.path); export const setPageTitle = (title) => { document.title = title; }; -export const pushState = (url) => { - // history.pushState({ url }, '', url); -}; - export const createTemp = ({ name, path, type, level, changed, content, base64 }) => { const treePath = path ? `${path}/${name}` : name; diff --git a/app/assets/stylesheets/pages/ide.scss b/app/assets/stylesheets/pages/ide.scss index b0f53108c73..d0437961f2d 100644 --- a/app/assets/stylesheets/pages/ide.scss +++ b/app/assets/stylesheets/pages/ide.scss @@ -35,7 +35,7 @@ } } -.ide-view { +.ide-view { display: flex; height: calc(100vh - #{$header-height}); margin-top: $header-height; @@ -338,5 +338,4 @@ padding-top: 200px; text-align: center; font-size: 140%; - } |