diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index c9d0cca..a820682 100644 --- a/README.md +++ b/README.md @@ -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 @@ -11,34 +13,32 @@ Chrome extension to show a code tree on GitLab :) ## Installation -[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:[linsage@live.com](mailto:linsage@live.com) -- 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 diff --git a/background.js b/background.js index d5e2830..636d745 100644 --- a/background.js +++ b/background.js @@ -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); \ No newline at end of file +chrome.browserAction.onClicked.addListener(openSupport); diff --git a/main.js b/main.js index 74c1b38..a619c10 100644 --- a/main.js +++ b/main.js @@ -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; } @@ -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) { @@ -90,6 +115,7 @@ var vm = { } } vm.getZTree().addNodes(parentNode, i, treeArr); + cb && cb(treeArr) }); }, loadRecursiveNode: function () { @@ -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 = []; @@ -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({ @@ -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, @@ -270,6 +297,8 @@ var vm = { } }) } + document.title = treeNode.path + window.history.pushState(null, null, href) }, //得到树对象 getZTree: function () { @@ -462,7 +491,7 @@ var vm = { vm.initTree(); if (vm.setting.recursive) { - vm.loadRecursiveNode(); + vm.loadRecursiveTree(); } else { vm.loadNode(null); } @@ -472,4 +501,4 @@ var vm = { $(function () { vm.init(); -}); \ No newline at end of file +}); diff --git a/manifest.json b/manifest.json index d16830a..64a1367 100755 --- a/manifest.json +++ b/manifest.json @@ -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" ], @@ -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/*"], @@ -41,4 +38,4 @@ ], "run_at": "document_start" }] -} \ No newline at end of file +}