Skip to content

Commit a0f69ec

Browse files
committed
fix
1 parent dccffe2 commit a0f69ec

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

routers/web/repo/tree.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
package repo
55

66
import (
7+
"errors"
78
"net/http"
89

910
"code.gitea.io/gitea/modules/base"
@@ -58,7 +59,7 @@ func Tree(ctx *context.Context) {
5859
recursive := ctx.FormBool("recursive")
5960

6061
if ctx.Repo.RefFullName == "" {
61-
ctx.Error(http.StatusBadRequest, "RefFullName", "ref_name is invalid")
62+
ctx.ServerError("RefFullName", errors.New("ref_name is invalid"))
6263
return
6364
}
6465

web_src/js/components/ViewFileTreeItem.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ const doLoadChildren = async () => {
2525
collapsed.value = !collapsed.value;
2626
if (!collapsed.value && props.loadChildren) {
2727
isLoading.value = true;
28-
const _children = await props.loadChildren(props.item);
28+
const _children = await props.loadChildren(props.item.path);
2929
children.value = _children;
3030
isLoading.value = false;
3131
}
3232
};
3333
3434
const doLoadDirContent = () => {
3535
doLoadChildren();
36-
props.loadContent(props.item);
36+
props.loadContent(props.item.path);
3737
};
3838
3939
const doLoadFileContent = () => {
40-
props.loadContent(props.item);
40+
props.loadContent(props.item.path);
4141
};
4242
4343
const doGotoSubModule = () => {

web_src/js/features/repo-view-file-tree-sidebar.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {initTargetPdfViewer} from '../render/pdf.ts';
1010
import {initTargetButtons} from './common-button.ts';
1111
import {initTargetCopyContent} from './copycontent.ts';
1212

13-
async function toggleSidebar(visibility, isSigned) {
13+
async function toggleSidebar(visibility: boolean, isSigned: boolean) {
1414
const sidebarEl = document.querySelector('.repo-view-file-tree-sidebar');
1515
const showBtnEl = document.querySelector('.show-tree-sidebar-button');
1616
const containerClassList = sidebarEl.parentElement.classList;
@@ -29,11 +29,11 @@ async function toggleSidebar(visibility, isSigned) {
2929
});
3030
}
3131

32-
async function loadChildren(item, recursive?: boolean) {
32+
async function loadChildren(path: string, recursive?: boolean) {
3333
const fileTree = document.querySelector('#view-file-tree');
3434
const apiBaseUrl = fileTree.getAttribute('data-api-base-url');
3535
const refTypeNameSubURL = fileTree.getAttribute('data-current-ref-type-name-sub-url');
36-
const response = await GET(`${apiBaseUrl}/tree/${refTypeNameSubURL}/${item ? item.path : ''}?recursive=${recursive ?? false}`);
36+
const response = await GET(`${apiBaseUrl}/tree/${refTypeNameSubURL}/${path ?? ''}?recursive=${recursive ?? false}`);
3737
const json = await response.json();
3838
if (json instanceof Array) {
3939
return json.map((i) => ({
@@ -90,12 +90,12 @@ export async function initViewFileTreeSidebar() {
9090

9191
const selectedItem = ref(treePath);
9292

93-
const files = await loadChildren({path: treePath}, true);
93+
const files = await loadChildren(treePath, true);
9494

9595
fileTree.classList.remove('is-loading');
96-
const fileTreeView = createApp(ViewFileTree, {files, selectedItem, loadChildren, loadContent: (item) => {
97-
window.history.pushState(null, null, `${baseUrl}/src${refString}/${item.path}`);
98-
selectedItem.value = item.path;
96+
const fileTreeView = createApp(ViewFileTree, {files, selectedItem, loadChildren, loadContent: (path: string) => {
97+
window.history.pushState(null, null, `${baseUrl}/src${refString}/${path}`);
98+
selectedItem.value = path;
9999
loadContent();
100100
}});
101101
fileTreeView.mount(fileTree);
@@ -106,7 +106,7 @@ export async function initViewFileTreeSidebar() {
106106
});
107107
}
108108

109-
function extractPath(url) {
109+
function extractPath(url: string) {
110110
// Create a URL object
111111
const urlObj = new URL(url);
112112

0 commit comments

Comments
 (0)