Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

52 changes: 26 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# GitLab-TreeView

Chrome extension to show a code tree on GitLab :)
> fork from [gitlab-treeview](https://github.com/linsage/gitlab-treeview) and fix some bug

Chrome extension to show a code tree on GitLab :)

## Features

Expand All @@ -11,34 +13,32 @@ Chrome extension to show a code tree on GitLab :)

## Installation

[Chrome](https://chrome.google.com/webstore/detail/gitlab-treeview/kfjchffabpogdehadpflljaikjicdpng)
<!-- [Chrome](https://chrome.google.com/webstore/detail/gitlab-treeview/kfjchffabpogdehadpflljaikjicdpng) -->
[release](https://github.com/zWingz/gitlab-treeview/releases)

## Screenshot

![](https://ws2.sinaimg.cn/large/006tNc79gy1fi3ighoji0g30zk0m8du9.gif)


## Change Log
- v1.6
- api V3 to api V4
- v1.5
- add expand the current file path
- v1.4
- fix bug On gitlab 10.x, don't cover header and sidebar
- container width resizable
- v1.3
- fix bug On gitlab 10.x, rss_token instead of private_token.
- v1.2
- add css loading
- add options setting
- search file
- load entire tree at once
- v1.1
- basic function
- v1.0
- initial version

## More

- Email:[[email protected]](mailto:[email protected])
- Blog:[https://linsage.com](https://linsage.com)

- v1.6.3
- fix bug on gitlab api
- v1.6
- api V3 to api V4
- v1.5
- add expand the current file path
- v1.4
- fix bug On gitlab 10.x, don't cover header and sidebar
- container width resizable
- v1.3
- fix bug On gitlab 10.x, rss_token instead of private_token.
- v1.2
- add css loading
- add options setting
- search file
- load entire tree at once
- v1.1
- basic function
- v1.0
- initial version
5 changes: 3 additions & 2 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// current tab.
function openSupport(tab) {
window.open("https://chrome.google.com/webstore/detail/gitlab-treeview/" + chrome.runtime.id + "/support");
// window.open("https://chrome.google.com/webstore/detail/gitlab-treeview-fork/" + chrome.runtime.id + "/support");
window.open("https://github.com/zWingz/gitlab-treeview")
}

// When the browser action is clicked, call the
chrome.browserAction.onClicked.addListener(openSupport);
chrome.browserAction.onClicked.addListener(openSupport);
61 changes: 45 additions & 16 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,31 @@ var vm = {
vm.repository_ref = $('#repository_ref').val();
//console.info(vm)
},
loadNode: function (parentNode) {
loadRecursiveTree: function() {
const path = $('#path').val().split('/')
const ztree = vm.getZTree()
const self = this
function exec(treeArr) {
const p = path.shift()
const node = treeArr.filter(function(each) {
return each.name === p
})[0]
if(!node) {
return
}
const ztreeNode = ztree.getNodeByParam("id", node.id)
if(path.length) {
self.loadNode(ztreeNode, function(treeArr) {
ztree.expandNode(ztreeNode, true)
exec(treeArr)
})
} else {
ztree.selectNode(ztreeNode);
}
}
this.loadNode(null, exec)
},
loadNode: function (parentNode, cb) {
if (parentNode && (parentNode.zAsync || parentNode.isAjaxing)) {
return;
}
Expand All @@ -62,14 +86,15 @@ var vm = {
var param = {
id: vm.project_id,
path: parentNode ? parentNode.path : null,
ref: vm.repository_ref
ref: vm.repository_ref,
per_page: 9999
};

if (vm.rss_mode) {
param.rss_token = vm.rss_token;
} else {
param.private_token = vm.private_token;
}
// if (vm.rss_mode) {
// param.rss_token = vm.rss_token;
// } else {
// param.private_token = vm.private_token;
// }

$.get(vm.apiRepoTree, param, function (result) {
if (parentNode) {
Expand All @@ -90,6 +115,7 @@ var vm = {
}
}
vm.getZTree().addNodes(parentNode, i, treeArr);
cb && cb(treeArr)
});
},
loadRecursiveNode: function () {
Expand All @@ -99,11 +125,11 @@ var vm = {
ref_name: vm.repository_ref
};

if (vm.rss_mode) {
param.rss_token = vm.rss_token;
} else {
param.private_token = vm.private_token;
}
// if (vm.rss_mode) {
// param.rss_token = vm.rss_token;
// } else {
// param.private_token = vm.private_token;
// }

$.get(vm.apiRepoTree, param, function (result) {
var treeArr = [];
Expand Down Expand Up @@ -224,8 +250,9 @@ var vm = {
$.fn.zTree.init($("#gitlabTreeView"), setting);
},
selectNode: function (treeNode) {
var href
if (treeNode.type === 'blob') {
var href = window.location.origin + '/' + vm.shortcuts_project + '/blob/' + vm.repository_ref + '/' + treeNode.path;
href = window.location.origin + '/' + vm.shortcuts_project + '/blob/' + vm.repository_ref + '/' + treeNode.path;

//加载文件信息
$.ajax({
Expand Down Expand Up @@ -254,7 +281,7 @@ var vm = {
}
})
} else if (treeNode.type === 'tree') {
var href = window.location.origin + '/' + vm.shortcuts_project + '/tree/' + vm.repository_ref + '/' + treeNode.path;
href = window.location.origin + '/' + vm.shortcuts_project + '/tree/' + vm.repository_ref + '/' + treeNode.path;
$.ajax({
type: "GET",
url: href,
Expand All @@ -270,6 +297,8 @@ var vm = {
}
})
}
document.title = treeNode.path
window.history.pushState(null, null, href)
},
//得到树对象
getZTree: function () {
Expand Down Expand Up @@ -462,7 +491,7 @@ var vm = {
vm.initTree();

if (vm.setting.recursive) {
vm.loadRecursiveNode();
vm.loadRecursiveTree();
} else {
vm.loadNode(null);
}
Expand All @@ -472,4 +501,4 @@ var vm = {

$(function () {
vm.init();
});
});
15 changes: 6 additions & 9 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "Gitlab TreeView",
"version": "1.6",
"name": "Gitlab TreeView Fork",
"version": "1.0.0",
"manifest_version": 2,
"author": "linsage",
"author": "zWing",
"description": "Code tree for Gitlab",
"homepage_url": "https://github.com/linsage/gitlab-treeview",
"homepage_url": "https://github.com/zWingz/gitlab-treeview",
"permissions": [
"storage"
],
Expand All @@ -18,10 +18,7 @@
"persistent": false
},
"browser_action": {
"default_icon": {
"19": "images/gitlab.png",
"38": "images/gitlab.png"
},
"default_icon": "images/gitlab.png",
"default_title": "Gitlab TreeView"
},
"web_accessible_resources": ["css/*", "fonts/*"],
Expand All @@ -41,4 +38,4 @@
],
"run_at": "document_start"
}]
}
}