feat: Gitea file tree visible in sidebar on ALL pages
- base.html Alpine: added giteaWorkspace, giteaOwner, giteaRepo data - loadGiteaTree() fetches /api/gitea/.../tree and renders in sidebar - board._sidebar_data returns gitea_owner/gitea_repo - dashboard._sidebar_data returns gitea_owner/gitea_repo - alpine:initialized triggers loadGiteaTree on every page load
This commit is contained in:
@@ -577,6 +577,10 @@
|
||||
lastEdited: '{{ last_edited }}',
|
||||
workspaceKey: '{{ workspace_key }}',
|
||||
localWsId: {{ local_ws_id|default(0) }},
|
||||
giteaWorkspace: {{ 'true' if gitea_workspace else 'false' }},
|
||||
giteaOwner: '{{ gitea_owner|default("") }}',
|
||||
giteaRepo: '{{ gitea_repo|default("") }}',
|
||||
giteaTree: [], // loaded client-side for sidebar
|
||||
currentView: 'home',
|
||||
contextMenu: { visible: false, x: 0, y: 0, pageId: null, pageName: '' },
|
||||
contextActions: {},
|
||||
@@ -872,6 +876,30 @@
|
||||
.then(data => { window.location.href = `/pages/${data.id}`; })
|
||||
.catch(err => { this.toast('Failed to create sub-page: ' + err.message, 'error'); });
|
||||
},
|
||||
loadGiteaTree() {
|
||||
if (!this.giteaWorkspace || !this.giteaOwner || !this.giteaRepo) return;
|
||||
fetch('/api/gitea/projects/' + this.giteaOwner + '/' + this.giteaRepo + '/tree')
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
this.giteaTree = data.tree || [];
|
||||
// Render tree items into the sidebar workspace section
|
||||
var container = document.getElementById('sidebar-workspace-items');
|
||||
if (!container) return;
|
||||
container.innerHTML = '';
|
||||
if (!this.giteaTree.length) {
|
||||
container.innerHTML = '<li class="sidebar-item empty-hint"><span class="page-icon">📄</span><span class="page-name text-dim">No files yet</span></li>';
|
||||
return;
|
||||
}
|
||||
this.giteaTree.forEach(function(item) {
|
||||
var li = document.createElement('li');
|
||||
li.className = 'sidebar-item';
|
||||
var icon = item.type === 'dir' ? '📁' : '📄';
|
||||
li.innerHTML = '<span class="page-icon">' + icon + '</span><span class="page-name">' + item.name + '</span>';
|
||||
container.appendChild(li);
|
||||
});
|
||||
})
|
||||
.catch(function() { /* silently ignore */ });
|
||||
},
|
||||
newPageInWorkspace() {
|
||||
const name = prompt('File name:');
|
||||
if (!name || !name.trim()) return;
|
||||
@@ -1082,6 +1110,14 @@
|
||||
setTimeout(function() {
|
||||
var active = document.querySelector('.sidebar-item.active');
|
||||
if (active) active.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
||||
// Load Gitea tree in sidebar if workspace is remote
|
||||
var root = document.querySelector('[x-data]');
|
||||
if (root && root.__x) {
|
||||
var state = root.__x.$data;
|
||||
if (state && typeof state.loadGiteaTree === 'function') {
|
||||
state.loadGiteaTree();
|
||||
}
|
||||
}
|
||||
}, 300);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user