From 16398848009e09de155abd105a882d5b0c145322 Mon Sep 17 00:00:00 2001 From: bruno Date: Fri, 10 Jul 2026 19:59:34 -0400 Subject: [PATCH] fix: workspace name shows even empty, folders vs files, delete button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - dashboard.py _sidebar_data now reads active workspace cookie - Workspace name always displays (even with 0 pages) - Folders stored with parent_section='Workspace' (icon 📁) - Files stored with parent_section='Private' (icon 📄) - Delete button uses @click directive (not onclick app.) - workspace_pages loaded in dashboard's _sidebar_data --- app/routers/board.py | 5 +++-- app/routers/dashboard.py | 26 +++++++++++++++++++++++--- app/templates/base.html | 10 +++++----- 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/app/routers/board.py b/app/routers/board.py index 09f5155..bb2eca5 100644 --- a/app/routers/board.py +++ b/app/routers/board.py @@ -148,10 +148,11 @@ def _load_workspace_pages(ws_cookie: str) -> list: ws_id = int(ws_cookie) with get_conn() as conn: rows = conn.execute( - "SELECT id, title FROM pages WHERE workspace_id=? AND parent_id IS NULL ORDER BY created_at DESC", + "SELECT id, title, parent_section FROM pages WHERE workspace_id=? AND parent_id IS NULL ORDER BY created_at DESC", (ws_id,), ).fetchall() - return [{"db_id": r["id"], "name": r["title"] or "Untitled", "id": f"page/{r['id']}"} for r in rows] + return [{"db_id": r["id"], "name": r["title"] or "Untitled", "id": f"page/{r['id']}", + "icon": "📁" if r.get("parent_section") == "Workspace" else "📄"} for r in rows] except (ValueError, Exception): return [] diff --git a/app/routers/dashboard.py b/app/routers/dashboard.py index 0f4a98c..283f9ce 100644 --- a/app/routers/dashboard.py +++ b/app/routers/dashboard.py @@ -51,12 +51,30 @@ def _sidebar_data(request: Request, repos: list[dict]) -> dict: "children": [], }) + # Active workspace from cookie + from app.routers.board import _load_workspace_pages + ws_cookie = request.cookies.get("flowdeck_workspace", "") + active_ws_name = "Workspace" + workspace_pages = [] + if ws_cookie: + workspace_pages = _load_workspace_pages(ws_cookie) + try: + with get_conn() as conn: + ws_row = conn.execute("SELECT name FROM workspaces WHERE id=?", (int(ws_cookie),)).fetchone() + if ws_row: + active_ws_name = ws_row["name"] + except (ValueError, Exception): + pass + return { "workspace_name": ws, "workspace_initial": initial, + "active_ws_name": active_ws_name, + "workspace_pages": workspace_pages, "current_page": "Dashboard", "last_edited": "now", "recent_pages": recent_pages, "private_pages": [], "favorite_pages": [], + "shared_pages": [], "user": user, "workspace_key": "", } @@ -524,17 +542,19 @@ async def create_local_workspace_item(request: Request): import json body = await request.json() name = body.get("name", "Untitled").strip() + item_type = body.get("type", "page") ws = _get_active_workspace(request) ws_id = ws["id"] if ws else None + section = 'Workspace' if item_type == 'folder' else 'Private' with get_conn() as conn: cursor = conn.execute( "INSERT INTO pages (workspace, workspace_id, title, content, content_format, parent_section) " - "VALUES ('', ?, ?, '', 'blocks', 'Private')", - (ws_id, name), + "VALUES ('', ?, ?, '', 'blocks', ?)", + (ws_id, name, section), ) conn.commit() pid = cursor.lastrowid - return {"id": pid, "name": name, "type": "page"} + return {"id": pid, "name": name, "type": item_type} @router.put("/api/local-workspace/items/{item_id:int}") diff --git a/app/templates/base.html b/app/templates/base.html index 1d535e4..6ae46cb 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -95,11 +95,11 @@