Commit f658d26c authored by Jacob Schatz's avatar Jacob Schatz

Checks if we are on root dir.

parent 3d6c9783
...@@ -23,6 +23,7 @@ function initRepo() { ...@@ -23,6 +23,7 @@ function initRepo() {
Store.checkIsCommitable(); Store.checkIsCommitable();
Store.projectId = repo.dataset.projectId; Store.projectId = repo.dataset.projectId;
Store.tempPrivateToken = repo.dataset.tempToken; Store.tempPrivateToken = repo.dataset.tempToken;
Store.projectUrl = repo.dataset.projectUrl;
this.vm = new Vue({ this.vm = new Vue({
el: repo, el: repo,
......
...@@ -100,6 +100,21 @@ const RepoHelper = { ...@@ -100,6 +100,21 @@ const RepoHelper = {
return 0; return 0;
}, },
isRoot(url) {
// the url we are requesting -> split by the project URL. Grab the right side.
const isRoot = !!url.split(Store.projectUrl)[1]
// remove the first "/"
.slice(1)
// split this by "/"
.split('/')
// remove the first two items of the array... usually /tree/master.
.slice(2)
// we want to know the length of the array.
// If greater than 0 not root.
.length;
return isRoot;
},
getContent(treeOrFile, cb) { getContent(treeOrFile, cb) {
let file = treeOrFile; let file = treeOrFile;
// const loadingData = RepoHelper.setLoading(true); // const loadingData = RepoHelper.setLoading(true);
...@@ -139,6 +154,7 @@ const RepoHelper = { ...@@ -139,6 +154,7 @@ const RepoHelper = {
} }
} else { } else {
// it's a tree // it's a tree
if(!file) Store.isRoot = RepoHelper.isRoot(Service.url);
file = RepoHelper.setDirectoryOpen(file); file = RepoHelper.setDirectoryOpen(file);
const newDirectory = RepoHelper.dataToListOfFiles(data); const newDirectory = RepoHelper.dataToListOfFiles(data);
Store.addFilesToDirectory(file, Store.files, newDirectory); Store.addFilesToDirectory(file, Store.files, newDirectory);
......
...@@ -82,6 +82,7 @@ export default RepoSidebar; ...@@ -82,6 +82,7 @@ export default RepoSidebar;
:is-mini="isMini" :is-mini="isMini"
:project-name="projectName"/> :project-name="projectName"/>
<repo-previous-directory <repo-previous-directory
v-if="isRoot"
:prev-url="prevURL" :prev-url="prevURL"
@linkclicked="linkClicked(prevURL)"/> @linkclicked="linkClicked(prevURL)"/>
<repo-loading-file <repo-loading-file
......
...@@ -11,9 +11,11 @@ const RepoStore = { ...@@ -11,9 +11,11 @@ const RepoStore = {
editButton: '', editButton: '',
editMode: false, editMode: false,
isTree: false, isTree: false,
isRoot: false,
prevURL: '', prevURL: '',
projectId: '', projectId: '',
projectName: '', projectName: '',
projectUrl: '',
trees: [], trees: [],
blobs: [], blobs: [],
submodules: [], submodules: [],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment