fix: sidebar Repository et pages forge — erreurs console, cache assets (v7.70.1)
FlowDeck CI / lint (push) Successful in 1m37s
FlowDeck CI / docker (push) Canceled after 0s
FlowDeck CI / test (push) Canceled after 1h9m58s

This commit is contained in:
2026-10-09 23:33:48 -04:00
parent d95178156f
commit 1fedafa808
5 changed files with 109 additions and 12 deletions
+33 -7
View File
@@ -45,6 +45,8 @@ var _regGiteaWs = () => {
sortedTreeItems: [],
filteredTreeItems: [],
treeLoading: false,
treeError: false,
treeErrorText: '',
folderStack: [],
currentPath: '',
// Context menu
@@ -132,16 +134,30 @@ var _regGiteaWs = () => {
async loadMainTree(path) {
this.treeLoading = true;
this.treeError = false;
this.treeErrorText = '';
this.currentPath = path;
var forgeLabel = this.forge === 'github' ? 'GitHub' : 'Gitea';
try {
var url = this.apiBase() + '/tree';
if (path) url += '?path=' + encodeURIComponent(path);
var r = await fetch(url);
if (!r.ok) { this.treeItems = []; this.sortedTreeItems = []; this.filteredTreeItems = []; return; }
if (!r.ok) {
this.treeItems = []; this.sortedTreeItems = []; this.filteredTreeItems = [];
this.treeError = true;
this.treeErrorText = r.status === 401
? 'Connect your ' + forgeLabel + ' account (Settings → Integrations) to browse this repository.'
: 'Repository API answered HTTP ' + r.status + '.';
return;
}
var d = await r.json();
this.treeItems = d.tree || [];
this._sortTree();
} catch { this.treeItems = []; this.sortedTreeItems = []; this.filteredTreeItems = []; }
} catch {
this.treeItems = []; this.sortedTreeItems = []; this.filteredTreeItems = [];
this.treeError = true;
this.treeErrorText = 'Could not reach the repository — the server may be restarting. Retry in a moment.';
}
finally { this.treeLoading = false; }
},
@@ -199,13 +215,18 @@ var _regGiteaWs = () => {
}).catch(function(){ window.showToast('Delete failed', 'error'); });
},
_sidebarHint(msg) {
var container = document.getElementById('sidebar-gitea-items');
if (container) container.innerHTML = '<li class="sidebar-item empty-hint"><span class="page-icon">'+getSvgIcon('link',14)+'</span><span class="page-name text-dim">' + msg + '</span></li>';
},
async loadSidebarTree() {
var forgeLabel = this.forge === 'github' ? 'GitHub' : 'Gitea';
try {
var r = await fetch(this.apiBase() + '/tree');
if (!r.ok) {
// If API fails (e.g. no Gitea token), set a message
var container = document.getElementById('sidebar-gitea-items');
if (container) container.innerHTML = '<li class="sidebar-item empty-hint"><span class="page-icon">'+getSvgIcon('link',14)+'</span><span class="page-name text-dim">Connect Gitea to browse files</span></li>';
// API error (e.g. forge account not linked) — hint instead of
// leaving "Loading..." stuck in the Repository section.
this._sidebarHint(r.status === 401 ? 'Connect ' + forgeLabel + ' to browse files' : 'Could not load repository tree (HTTP ' + r.status + ')');
return;
}
var d = await r.json();
@@ -248,14 +269,19 @@ var _regGiteaWs = () => {
html += '<li class="sidebar-item" id="gitea-private-link" style="padding-left:12px;cursor:pointer;display:flex;align-items:center;gap:4px;">';
html += '<span class="page-icon">'+getSvgIcon('lock',14)+'</span><span class="page-name">Private Pages</span></li>';
container.innerHTML = html;
// Re-attach event listeners
// Attach sidebar clicks once (loadSidebarTree runs on every refresh —
// re-attaching would stack duplicate global listeners).
this.setupSidebarClicks();
} catch(e) {
console.error('Gitea sidebar tree load failed:', e);
// Network failure (server restarting, offline…) — hint in place of
// "Loading..." so the Repository section never looks broken.
this._sidebarHint('Could not reach the repository — retry in a moment');
}
},
setupSidebarClicks() {
if (this._sidebarClicksBound) return;
this._sidebarClicksBound = true;
var self = this;
document.addEventListener('click', function(e) {
var el = e.target.closest('.sidebar-item[data-gitea-path]');