diff --git a/templates/repo/view_file_tree.tmpl b/templates/repo/view_file_tree.tmpl index 8aed05f346..1e737d09cd 100644 --- a/templates/repo/view_file_tree.tmpl +++ b/templates/repo/view_file_tree.tmpl @@ -10,6 +10,7 @@ {{/* TODO: Dynamically move components such as refSelector and createPR here */}}
diff --git a/web_src/js/components/ViewFileTree.vue b/web_src/js/components/ViewFileTree.vue index 1f90f92586..1bd52d7435 100644 --- a/web_src/js/components/ViewFileTree.vue +++ b/web_src/js/components/ViewFileTree.vue @@ -7,6 +7,7 @@ const elRoot = useTemplateRef('elRoot'); const props = defineProps({ repoLink: {type: String, required: true}, + repoName: {type: String, required: true}, treePath: {type: String, required: true}, currentRefNameSubURL: {type: String, required: true}, }); diff --git a/web_src/js/components/ViewFileTreeStore.ts b/web_src/js/components/ViewFileTreeStore.ts index 0e16b56650..63b585c743 100644 --- a/web_src/js/components/ViewFileTreeStore.ts +++ b/web_src/js/components/ViewFileTreeStore.ts @@ -4,7 +4,7 @@ import {pathEscapeSegments} from '../utils/url.ts'; import {createElementFromHTML} from '../utils/dom.ts'; import {html} from '../utils/html.ts'; -export function createViewFileTreeStore(props: {repoLink: string, treePath: string, currentRefNameSubURL: string}) { +export function createViewFileTreeStore(props: {repoLink: string, repoName: string, treePath: string, currentRefNameSubURL: string}) { const store = reactive({ rootFiles: [], selectedItem: props.treePath, @@ -32,14 +32,23 @@ export function createViewFileTreeStore(props: {repoLink: string, treePath: stri async navigateTreeView(treePath: string) { const url = store.buildTreePathWebUrl(treePath); + const title = store.buildTitle(store.selectedItem, treePath); window.history.pushState({treePath, url}, null, url); store.selectedItem = treePath; await store.loadViewContent(url); + document.title = title; }, buildTreePathWebUrl(treePath: string) { return `${props.repoLink}/src/${props.currentRefNameSubURL}/${pathEscapeSegments(treePath)}`; }, + + buildTitle(oldTreePath: string, treePath: string) { + // the title always starts with "