This commit is contained in:
Kerwin Bryant 2025-01-06 06:59:04 +00:00
parent 647cd304a0
commit 91f972ce82
3 changed files with 16 additions and 5 deletions

View File

@ -24,7 +24,7 @@
<div class="{{Iif $showSidebar "repo-grid-filelist-sidebar" (Iif $showTreeSidebar "repo-grid-tree-sidebar" "repo-grid-filelist-only")}}">
{{if $hasTreeSidebar}}
<div class="repo-view-file-tree-sidebar not-mobile {{if $hideTreeSidebar}}tw-hidden{{end}}">{{template "repo/view_file_tree_sidebar" .}}</div>
<div class="repo-view-file-tree-sidebar not-mobile {{if $hideTreeSidebar}}tw-hidden{{end}}" {{if .IsSigned}} data-is-signed {{end}}>{{template "repo/view_file_tree_sidebar" .}}</div>
{{end}}
<div class="repo-home-filelist">

View File

@ -70,6 +70,8 @@
display: flex;
flex-direction: column;
gap: 0.25em;
max-height: 100vh;
overflow: hidden;
}
.repo-grid-tree-sidebar .view-file-tree-sidebar-top {
@ -90,6 +92,11 @@
gap: 0.25em;
}
.repo-grid-tree-sidebar .view-file-tree-sidebar-bottom {
flex: 1;
overflow: auto;
}
@media (max-width: 767.98px) {
.repo-grid-tree-sidebar {
grid-template-columns: auto;

View File

@ -5,7 +5,7 @@ import ViewFileTree from '../components/ViewFileTree.vue';
import RepoBranchTagSelector from '../components/RepoBranchTagSelector.vue';
import {initGlobalDropdown} from './common-page.ts';
async function toggleSidebar(visibility) {
async function toggleSidebar(visibility, isSigned) {
const sidebarEl = document.querySelector('.repo-view-file-tree-sidebar');
const showBtnEl = document.querySelector('.show-tree-sidebar-button');
const containerClassList = sidebarEl.parentElement.classList;
@ -14,6 +14,8 @@ async function toggleSidebar(visibility) {
toggleElem(sidebarEl, visibility);
toggleElem(showBtnEl, !visibility);
if (!isSigned) return;
// save to session
await PUT('/repo/preferences', {
data: {
@ -49,7 +51,7 @@ async function loadContent() {
function reloadContentScript() {
document.querySelector('.repo-home-filelist .show-tree-sidebar-button').addEventListener('click', () => {
toggleSidebar(true);
toggleSidebar(true, document.querySelector('.repo-view-file-tree-sidebar').hasAttribute('data-is-signed'));
});
const refSelectorEl = document.querySelector('.repo-home-filelist .js-branch-tag-selector');
if (refSelectorEl) {
@ -62,11 +64,13 @@ export async function initViewFileTreeSidebar() {
const sidebarElement = document.querySelector('.repo-view-file-tree-sidebar');
if (!sidebarElement) return;
const isSigned = sidebarElement.hasAttribute('data-is-signed');
document.querySelector('.hide-tree-sidebar-button').addEventListener('click', () => {
toggleSidebar(false);
toggleSidebar(false, isSigned);
});
document.querySelector('.repo-home-filelist .show-tree-sidebar-button').addEventListener('click', () => {
toggleSidebar(true);
toggleSidebar(true, isSigned);
});
const fileTree = document.querySelector('#view-file-tree');