fix: Gitea sidebar now has separate Repository section below Private
Backend: - _sidebar_data() no longer clears workspace_pages for Gitea workspaces The local tree stays intact in the 'Private' section - workspace_pages is always loaded from DB (local files) Sidebar template (base.html): - Workspace section renamed to 'Private' when gitea_workspace is true - New 'Repository (Gitea)' section added below, visible only for Gitea workspaces, with its own toggle (sectionsOpen.gitea) and refresh button - Uses #sidebar-gitea-items container for the remote file tree Gitea workspace: - loadSidebarTree() now targets #sidebar-gitea-items - window._gwData exposed for sidebar refresh button - sectionsOpen now includes gitea: true by default
This commit is contained in:
@@ -76,13 +76,14 @@ def _sidebar_data(request: Request, repos: list[dict], include_workspace: bool =
|
|||||||
|
|
||||||
if include_workspace and ws_cookie and ws_cookie.startswith("gitea:"):
|
if include_workspace and ws_cookie and ws_cookie.startswith("gitea:"):
|
||||||
# Gitea workspace: set owner/repo for client-side tree loading
|
# Gitea workspace: set owner/repo for client-side tree loading
|
||||||
|
# BUT keep local workspace pages — they go in the "Private" section
|
||||||
parts = ws_cookie.split(":", 2)
|
parts = ws_cookie.split(":", 2)
|
||||||
if len(parts) >= 3:
|
if len(parts) >= 3:
|
||||||
gitea_owner = parts[1]
|
gitea_owner = parts[1]
|
||||||
gitea_repo = parts[2]
|
gitea_repo = parts[2]
|
||||||
active_ws_name = f"{gitea_owner}/{gitea_repo}"
|
active_ws_name = f"{gitea_owner}/{gitea_repo}"
|
||||||
gitea_workspace = True
|
gitea_workspace = True
|
||||||
workspace_pages = [] # loaded client-side
|
# workspace_pages stays as-is (local tree, loaded above)
|
||||||
elif include_workspace and ws_cookie and user:
|
elif include_workspace and ws_cookie and user:
|
||||||
try:
|
try:
|
||||||
wsi = int(ws_cookie)
|
wsi = int(ws_cookie)
|
||||||
|
|||||||
+23
-3
@@ -116,12 +116,12 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="sidebar-scroll">
|
<div class="sidebar-scroll">
|
||||||
<!-- Workspace -->
|
<!-- Workspace / Private -->
|
||||||
<div class="sidebar-section">
|
<div class="sidebar-section">
|
||||||
<div class="sidebar-section-header" @click="toggleSection('workspace')">
|
<div class="sidebar-section-header" @click="toggleSection('workspace')">
|
||||||
<div class="sidebar-section-title">
|
<div class="sidebar-section-title">
|
||||||
<span class="chevron" :class="{ open: sectionsOpen.workspace }" x-text="sectionsOpen.workspace ? '▼' : '▶'"></span>
|
<span class="chevron" :class="{ open: sectionsOpen.workspace }" x-text="sectionsOpen.workspace ? '▼' : '▶'"></span>
|
||||||
<span>{% if workspace_key and '/' in workspace_key %}🔗{% else %}📁{% endif %} {{ active_ws_name or 'Workspace' }}</span>
|
<span>{% if gitea_workspace %}📁 Private{% elif workspace_key and '/' in workspace_key %}🔗{% else %}📁{% endif %} {{ active_ws_name if not gitea_workspace else '' }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="sidebar-section-actions">
|
<div class="sidebar-section-actions">
|
||||||
<button class="section-action-btn" title="New Page" @click.stop="newPageInWorkspace()">📄</button>
|
<button class="section-action-btn" title="New Page" @click.stop="newPageInWorkspace()">📄</button>
|
||||||
@@ -143,6 +143,26 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Repository (Gitea) — only visible for Gitea workspaces -->
|
||||||
|
{% if gitea_workspace %}
|
||||||
|
<div class="sidebar-section">
|
||||||
|
<div class="sidebar-section-header" @click="toggleSection('gitea')">
|
||||||
|
<div class="sidebar-section-title">
|
||||||
|
<span class="chevron" :class="{ open: sectionsOpen.gitea }" x-text="sectionsOpen.gitea ? '▼' : '▶'"></span>
|
||||||
|
<span>🔗 Repository (Gitea)</span>
|
||||||
|
</div>
|
||||||
|
<div class="sidebar-section-actions">
|
||||||
|
<button class="section-action-btn" title="Refresh" @click.stop="if(window._gwData)window._gwData.refreshTree()">🔄</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="sidebar-section-items" x-show="sectionsOpen.gitea" x-transition>
|
||||||
|
<ul class="sidebar-items" data-section="gitea" id="sidebar-gitea-items">
|
||||||
|
<li class="sidebar-item empty-hint"><span class="page-icon">🔗</span><span class="page-name text-dim">Loading...</span></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<!-- Meetings -->
|
<!-- Meetings -->
|
||||||
<div class="sidebar-section">
|
<div class="sidebar-section">
|
||||||
<div class="sidebar-section-header" @click="toggleSection('meetings')">
|
<div class="sidebar-section-header" @click="toggleSection('meetings')">
|
||||||
@@ -585,7 +605,7 @@
|
|||||||
|
|
||||||
// ── Sections collapsible ──
|
// ── Sections collapsible ──
|
||||||
sectionsOpen: (function() {
|
sectionsOpen: (function() {
|
||||||
var def = { recents: true, private: true, meetings: true, favorites: true, agents: true, shared: true, published: true, apps: true, workspace: true };
|
var def = { recents: true, private: true, meetings: true, favorites: true, agents: true, shared: true, published: true, apps: true, workspace: true, gitea: true };
|
||||||
try {
|
try {
|
||||||
var saved = JSON.parse(localStorage.getItem('fd_sections') || '{}');
|
var saved = JSON.parse(localStorage.getItem('fd_sections') || '{}');
|
||||||
return Object.assign(def, saved);
|
return Object.assign(def, saved);
|
||||||
|
|||||||
@@ -229,9 +229,11 @@ function giteaWorkspace() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
// Expose globally for header to access
|
||||||
|
window._gwData = this;
|
||||||
// Set cookie for sidebar
|
// Set cookie for sidebar
|
||||||
document.cookie = 'flowdeck_workspace=gitea:' + this.owner + ':' + this.repo + ';path=/;SameSite=Lax';
|
document.cookie = 'flowdeck_workspace=gitea:' + this.owner + ':' + this.repo + ';path=/;SameSite=Lax';
|
||||||
// Load sidebar tree
|
// Load sidebar tree (into gitea section)
|
||||||
this.loadSidebarTree();
|
this.loadSidebarTree();
|
||||||
// Load main content tree
|
// Load main content tree
|
||||||
this.loadMainTree('');
|
this.loadMainTree('');
|
||||||
@@ -312,17 +314,17 @@ function giteaWorkspace() {
|
|||||||
var r = await fetch('/api/gitea/projects/' + this.owner + '/' + this.repo + '/tree');
|
var r = await fetch('/api/gitea/projects/' + this.owner + '/' + this.repo + '/tree');
|
||||||
if (!r.ok) {
|
if (!r.ok) {
|
||||||
// If API fails (e.g. no Gitea token), set a message
|
// If API fails (e.g. no Gitea token), set a message
|
||||||
var container = document.getElementById('sidebar-workspace-items');
|
var container = document.getElementById('sidebar-gitea-items');
|
||||||
if (container) container.innerHTML = '<li class="sidebar-item empty-hint"><span class="page-icon">🔗</span><span class="page-name text-dim">Connect Gitea to browse files</span></li>';
|
if (container) container.innerHTML = '<li class="sidebar-item empty-hint"><span class="page-icon">🔗</span><span class="page-name text-dim">Connect Gitea to browse files</span></li>';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var d = await r.json();
|
var d = await r.json();
|
||||||
var items = d.tree || [];
|
var items = d.tree || [];
|
||||||
var container = document.getElementById('sidebar-workspace-items');
|
var container = document.getElementById('sidebar-gitea-items');
|
||||||
if (!container) return;
|
if (!container) return;
|
||||||
// Ensure workspace section is visible
|
// Ensure gitea section is visible
|
||||||
if (window.appState && window.appState.sectionsOpen && !window.appState.sectionsOpen.workspace) {
|
if (window.appState && window.appState.sectionsOpen && !window.appState.sectionsOpen.gitea) {
|
||||||
window.appState.sectionsOpen.workspace = true;
|
window.appState.sectionsOpen.gitea = true;
|
||||||
}
|
}
|
||||||
container.innerHTML = '';
|
container.innerHTML = '';
|
||||||
// Build tree HTML as string and set once (more performant)
|
// Build tree HTML as string and set once (more performant)
|
||||||
|
|||||||
Reference in New Issue
Block a user