mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-19 15:00:52 +02:00
fix
This commit is contained in:
parent
a1cee9e4e2
commit
2a8f9c8531
@ -8,7 +8,7 @@
|
|||||||
{{$hasAndShowTreeSidebar := and $hasTreeSidebar $showTreeSidebar}}
|
{{$hasAndShowTreeSidebar := and $hasTreeSidebar $showTreeSidebar}}
|
||||||
<div role="main" aria-label="{{.Title}}" class="page-content repository file list {{if .IsBlame}}blame{{end}}">
|
<div role="main" aria-label="{{.Title}}" class="page-content repository file list {{if .IsBlame}}blame{{end}}">
|
||||||
{{template "repo/header" .}}
|
{{template "repo/header" .}}
|
||||||
<div class="ui container {{if .IsBlame}}fluid padded{{end}}">
|
<div class="ui container {{if or $hasTreeSidebar .IsBlame}}fluid padded{{end}}">
|
||||||
{{template "base/alert" .}}
|
{{template "base/alert" .}}
|
||||||
|
|
||||||
{{if .Repository.IsArchived}}
|
{{if .Repository.IsArchived}}
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
{{$branchDropdownCurrentRefType := "branch"}}
|
||||||
|
{{$branchDropdownCurrentRefShortName := .BranchName}}
|
||||||
|
{{if .IsViewTag}}
|
||||||
|
{{$branchDropdownCurrentRefType = "tag"}}
|
||||||
|
{{$branchDropdownCurrentRefShortName = .TagName}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
<div class="view-file-tree-sidebar-top">
|
<div class="view-file-tree-sidebar-top">
|
||||||
<div class="sidebar-header">
|
<div class="sidebar-header">
|
||||||
<button class="hide-tree-sidebar-button ui compact basic button icon" title="{{ctx.Locale.Tr "repo.diff.hide_file_tree"}}">
|
<button class="hide-tree-sidebar-button ui compact basic button icon" title="{{ctx.Locale.Tr "repo.diff.hide_file_tree"}}">
|
||||||
@ -6,12 +13,6 @@
|
|||||||
<b> Files</b>
|
<b> Files</b>
|
||||||
</div>
|
</div>
|
||||||
<div class="sidebar-ref">
|
<div class="sidebar-ref">
|
||||||
{{$branchDropdownCurrentRefType := "branch"}}
|
|
||||||
{{$branchDropdownCurrentRefShortName := .BranchName}}
|
|
||||||
{{if .IsViewTag}}
|
|
||||||
{{$branchDropdownCurrentRefType = "tag"}}
|
|
||||||
{{$branchDropdownCurrentRefShortName = .TagName}}
|
|
||||||
{{end}}
|
|
||||||
{{template "repo/branch_dropdown" dict
|
{{template "repo/branch_dropdown" dict
|
||||||
"Repository" .Repository
|
"Repository" .Repository
|
||||||
"ShowTabBranches" true
|
"ShowTabBranches" true
|
||||||
@ -59,5 +60,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="view-file-tree-sidebar-bottom">
|
<div class="view-file-tree-sidebar-bottom">
|
||||||
<div id="view-file-tree" class="is-loading" data-api-base-url="{{.RepoLink}}" data-tree-path="{{$.TreePath}}"></div>
|
<div id="view-file-tree" class="is-loading"
|
||||||
|
data-api-base-url="{{.RepoLink}}"
|
||||||
|
data-tree-path="{{$.TreePath}}"
|
||||||
|
data-current-ref-type="{{$branchDropdownCurrentRefType}}"
|
||||||
|
data-current-ref-short-name="{{$branchDropdownCurrentRefShortName}}"
|
||||||
|
></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -29,9 +29,11 @@ async function toggleSidebar(visibility) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function loadChildren(item, recursive?: boolean) {
|
async function loadChildren(item, recursive?: boolean) {
|
||||||
const el = document.querySelector('#view-file-tree');
|
const fileTree = document.querySelector('#view-file-tree');
|
||||||
const apiBaseUrl = el.getAttribute('data-api-base-url');
|
const apiBaseUrl = fileTree.getAttribute('data-api-base-url');
|
||||||
const response = await GET(`${apiBaseUrl}/tree/${item ? item.path : ''}?ref=&recursive=${recursive ?? false}`);
|
const refType = fileTree.getAttribute('data-current-ref-type');
|
||||||
|
const refName = fileTree.getAttribute('data-current-ref-short-name');
|
||||||
|
const response = await GET(`${apiBaseUrl}/tree/${item ? item.path : ''}?ref=${refType}/${refName}&recursive=${recursive ?? false}`);
|
||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
if (json instanceof Array) {
|
if (json instanceof Array) {
|
||||||
return json.map((i) => ({
|
return json.map((i) => ({
|
||||||
@ -64,15 +66,18 @@ export async function initViewFileTreeSidebar() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const fileTree = document.querySelector('#view-file-tree');
|
const fileTree = document.querySelector('#view-file-tree');
|
||||||
|
const baseUrl = fileTree.getAttribute('data-api-base-url');
|
||||||
const treePath = fileTree.getAttribute('data-tree-path');
|
const treePath = fileTree.getAttribute('data-tree-path');
|
||||||
const basePath = window.location.href.replace(treePath, '');
|
const refType = fileTree.getAttribute('data-current-ref-type');
|
||||||
|
const refName = fileTree.getAttribute('data-current-ref-short-name');
|
||||||
|
|
||||||
const selectedItem = ref(treePath);
|
const selectedItem = ref(treePath);
|
||||||
|
|
||||||
const files = await loadChildren({path: treePath}, true);
|
const files = await loadChildren({path: treePath}, true);
|
||||||
|
|
||||||
fileTree.classList.remove('is-loading');
|
fileTree.classList.remove('is-loading');
|
||||||
const fileTreeView = createApp(ViewFileTree, {files, selectedItem, loadChildren, loadContent: (item) => {
|
const fileTreeView = createApp(ViewFileTree, {files, selectedItem, loadChildren, loadContent: (item) => {
|
||||||
window.history.pushState(null, null, `${basePath}${item.path}`);
|
window.history.pushState(null, null, `${baseUrl}/src/${refType}/${refName}/${item.path}`);
|
||||||
selectedItem.value = item.path;
|
selectedItem.value = item.path;
|
||||||
loadContent(item);
|
loadContent(item);
|
||||||
}});
|
}});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user