fix: Gitea workspace — correct sidebar name, newPage stays remote, cookie persisted
FlowDeck CI / test (push) Failing after 3s
FlowDeck CI / docker (push) Has been skipped

Bug 1: newPageInWorkspace() allait toujours vers local-workspace API
→ Maintenant détecte workspaceKey contient '/' → Gitea API PUT file

Bug 2: workspace_name dans gitea_workspace ne persistait pas
→ Cookie flowdeck_workspace posé côté serveur au premier chargement

Bug 3: icône 📁 fixe dans sidebar — pas d'indication remote
→ 🔗 affiché quand workspace_key contient '/' (remote), 📁 sinon

newFolderInWorkspace() : avertissement si workspace distant
(car les dossiers n'existent pas dans un repo Git)
This commit is contained in:
2026-07-14 12:47:08 -04:00
parent 724ff4c880
commit 234b880c5b
2 changed files with 33 additions and 3 deletions
+11 -2
View File
@@ -380,16 +380,25 @@ async def gitea_workspace_page(request: Request):
return RedirectResponse("/auth/login?provider=local", status_code=302)
owner = request.query_params.get("owner", "")
repo = request.query_params.get("repo", "")
ws_key = f"{owner}/{repo}" if owner and repo else ""
ws_name = ws_key or "Gitea Workspace"
ctx = {
**sidebar,
"user": user,
"workspace_name": f"{owner}/{repo}" if owner and repo else "Gitea Workspace",
"active_ws_name": ws_name,
"workspace_key": ws_key,
"workspace_name": ws_name,
"workspace_initial": repo[0].upper() if repo else "G",
"owner": owner,
"repo": repo,
}
template = env.get_template("gitea_workspace.html")
return template.render(**ctx)
response = template.render(**ctx)
# Set workspace cookie so subsequent navigations remember the active Gitea project
resp = HTMLResponse(content=response)
if ws_key:
resp.set_cookie("flowdeck_workspace", f"gitea:{owner}:{repo}", path="/", samesite="lax")
return resp
@router.get("/api/workspace/projects")
+22 -1
View File
@@ -121,7 +121,7 @@
<div class="sidebar-section-header" @click="toggleSection('workspace')">
<div class="sidebar-section-title">
<span class="chevron" :class="{ open: sectionsOpen.workspace }" x-text="sectionsOpen.workspace ? '▼' : '▶'"></span>
<span>📁 {{ active_ws_name or 'Workspace' }}</span>
<span>{% if workspace_key and '/' in workspace_key %}🔗{% else %}📁{% endif %} {{ active_ws_name or 'Workspace' }}</span>
</div>
<div class="sidebar-section-actions">
<button class="section-action-btn" title="New Page" @click.stop="newPageInWorkspace()">📄</button>
@@ -874,6 +874,21 @@
newPageInWorkspace() {
const name = prompt('File name:');
if (!name || !name.trim()) return;
const wk = this.workspaceKey || '';
// Gitea/remote workspace: create file in the repo
if (wk.includes('/')) {
const parts = wk.split('/');
fetch('/api/gitea/projects/' + parts[0] + '/' + parts[1] + '/file', {
method: 'PUT',
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': this.getCsrfToken() },
body: JSON.stringify({ path: name.trim() + '.md', content: '# ' + name.trim(), message: 'Create via FlowDeck' })
})
.then(r => { if (!r.ok) throw new Error('Failed'); return r.json(); })
.then(data => { window.location.reload(); })
.catch(err => { this.toast('Failed: ' + err.message, 'error'); });
return;
}
// Local workspace
fetch('/api/local-workspace/items', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': this.getCsrfToken() },
@@ -886,6 +901,12 @@
newFolderInWorkspace() {
const name = prompt('Folder name:');
if (!name || !name.trim()) return;
const wk = this.workspaceKey || '';
// Gitea workspace: folders aren't a concept — just warn
if (wk.includes('/')) {
this.toast('Folders are not supported for remote workspaces. Use local workspace.', 'warning');
return;
}
fetch('/api/local-workspace/items', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': this.getCsrfToken() },