BigW Consortium Gitlab

Commit f658d26c by Jacob Schatz

Checks if we are on root dir.

parent 3d6c9783
......@@ -23,6 +23,7 @@ function initRepo() {
Store.checkIsCommitable();
Store.projectId = repo.dataset.projectId;
Store.tempPrivateToken = repo.dataset.tempToken;
Store.projectUrl = repo.dataset.projectUrl;
this.vm = new Vue({
el: repo,
......
......@@ -100,6 +100,21 @@ const RepoHelper = {
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) {
let file = treeOrFile;
// const loadingData = RepoHelper.setLoading(true);
......@@ -139,6 +154,7 @@ const RepoHelper = {
}
} else {
// it's a tree
if(!file) Store.isRoot = RepoHelper.isRoot(Service.url);
file = RepoHelper.setDirectoryOpen(file);
const newDirectory = RepoHelper.dataToListOfFiles(data);
Store.addFilesToDirectory(file, Store.files, newDirectory);
......
......@@ -82,6 +82,7 @@ export default RepoSidebar;
:is-mini="isMini"
:project-name="projectName"/>
<repo-previous-directory
v-if="isRoot"
:prev-url="prevURL"
@linkclicked="linkClicked(prevURL)"/>
<repo-loading-file
......
......@@ -11,9 +11,11 @@ const RepoStore = {
editButton: '',
editMode: false,
isTree: false,
isRoot: false,
prevURL: '',
projectId: '',
projectName: '',
projectUrl: '',
trees: [],
blobs: [],
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