Files
gitea/web_src/js/components/ViewFileTree.vue
T
silverwind 9f93e8d808 test: add e2e tests for comments, file tree, actions and branch protection (#40313)
Add e2e tests for flows that had no browser coverage: editing and
quote-replying an issue with an uploaded image, file tree and go-to-file
navigation, the Actions run view and workflow dispatch, and branch
protection rules with their priority.

The tests exposed bugs that are fixed here:

- Quote reply into an empty comment box left the Comment button disabled
- Removing an uploaded attachment did not update the comment buttons
- Going back from a file opened via the file tree to the initially
loaded page kept showing the other file

Assisted-by: Claude Code:claude-opus-5-5
2026-11-12 07:12:55 +00:00

45 lines
1.4 KiB
Vue

<script lang="ts" setup>
import ViewFileTreeItem from './ViewFileTreeItem.vue';
import {onMounted, useTemplateRef, type ShallowRef} from 'vue';
import {createViewFileTreeStore} from './ViewFileTreeStore.ts';
import {pathWithQuery} from '../utils/url.ts';
const elRoot = useTemplateRef('elRoot') as Readonly<ShallowRef<HTMLDivElement>>;
const props = defineProps({
repoLink: {type: String, required: true},
treePath: {type: String, required: true},
currentRefNameSubURL: {type: String, required: true},
});
const store = createViewFileTreeStore(props);
onMounted(async () => {
store.rootFiles = await store.loadChildren('', props.treePath);
elRoot.value.closest('.is-loading')?.classList?.remove('is-loading');
window.addEventListener('popstate', (e) => {
if (pathWithQuery(window.location) === store.viewContentUrl) return;
if (e.state?.url) {
store.selectedItem = e.state.treePath;
store.loadViewContent(e.state.url);
} else {
window.location.reload(); // not pushed by the tree, e.g. the initial page or an editor page
}
});
});
</script>
<template>
<div class="view-file-tree-items" ref="elRoot">
<ViewFileTreeItem v-for="item in store.rootFiles" :key="item.entryName" :item="item" :store="store"/>
</div>
</template>
<style scoped>
.view-file-tree-items {
display: flex;
flex-direction: column;
gap: 1px;
margin-right: .5rem;
}
</style>