From b2486a6e1140aa4a1e646fa704af0d43e3bd7179 Mon Sep 17 00:00:00 2001 From: bruno Date: Mon, 20 Jul 2026 08:59:00 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20sidebar=20workspace=20section=20?= =?UTF-8?q?=E2=80=94=20hide=20create=20buttons=20quand=20aucun=20workspace?= =?UTF-8?q?=20actif?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Ajout flag has_active_workspace dans _sidebar_data (dashboard.py + board.py) - Template base.html: quand has_active_workspace=False: - Titre section β†’ 'πŸ“ No workspace open' - Boutons New File/New Folder cachΓ©s - Message 'Open a workspace to see your files' - Guard JS newPageInWorkspace()/newFolderInWorkspace(): toast + redirect si pas de workspace - 143 tests passent --- app/routers/board.py | 6 +++++- app/routers/dashboard.py | 6 +++++- app/templates/base.html | 32 +++++++++++++++++++++++++++++--- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/app/routers/board.py b/app/routers/board.py index 4a08ad8..3c6597a 100644 --- a/app/routers/board.py +++ b/app/routers/board.py @@ -229,6 +229,7 @@ def _sidebar_data(request: Request, owner: str = "", repo: str = "") -> dict: gitea_workspace = False gitea_owner = "" gitea_repo = "" + has_active_workspace = False if ws_cookie and ws_cookie.startswith("gitea:"): # Gitea workspace: preserve context across pages @@ -238,6 +239,7 @@ def _sidebar_data(request: Request, owner: str = "", repo: str = "") -> dict: gitea_repo = parts[2] active_ws_name = f"{gitea_owner}/{gitea_repo}" gitea_workspace = True + has_active_workspace = True workspace_pages = [] # loaded client-side # Get local workspace ID for mirror if user: @@ -262,6 +264,7 @@ def _sidebar_data(request: Request, owner: str = "", repo: str = "") -> dict: if row: active_ws_name = row["name"] workspace_pages = _load_workspace_pages(ws_cookie) + has_active_workspace = True except (ValueError, Exception): pass local_ws_id = 0 @@ -376,7 +379,8 @@ def _sidebar_data(request: Request, owner: str = "", repo: str = "") -> dict: "user": user, "auth_method": auth_method, "gitea_linked": gitea_linked, - "github_linked": github_linked} + "github_linked": github_linked, + "has_active_workspace": has_active_workspace} def _extract_ai_keywords(owner: str, repo: str, labels: list[dict], body: str = ""): diff --git a/app/routers/dashboard.py b/app/routers/dashboard.py index 98b4df6..635e1f6 100644 --- a/app/routers/dashboard.py +++ b/app/routers/dashboard.py @@ -73,8 +73,9 @@ def _sidebar_data(request: Request, repos: list[dict], include_workspace: bool = gitea_workspace = False gitea_owner = "" gitea_repo = "" + has_active_workspace = False - if include_workspace and ws_cookie and ws_cookie.startswith("gitea:"): + if ws_cookie and ws_cookie.startswith("gitea:"): # 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) @@ -83,6 +84,7 @@ def _sidebar_data(request: Request, repos: list[dict], include_workspace: bool = gitea_repo = parts[2] active_ws_name = f"{gitea_owner}/{gitea_repo}" gitea_workspace = True + has_active_workspace = True # workspace_pages stays as-is (local tree, loaded above) elif include_workspace and ws_cookie and user: try: @@ -96,6 +98,7 @@ def _sidebar_data(request: Request, repos: list[dict], include_workspace: bool = if row: active_ws_name = row["name"] workspace_pages = _load_workspace_pages(ws_cookie) + has_active_workspace = True # else: stale cookie from another user β€” ignore except (ValueError, Exception): pass @@ -169,6 +172,7 @@ def _sidebar_data(request: Request, repos: list[dict], include_workspace: bool = "auth_method": auth_method, "gitea_linked": gitea_linked, "github_linked": github_linked, + "has_active_workspace": has_active_workspace, } diff --git a/app/templates/base.html b/app/templates/base.html index 7e7e61a..4d09eac 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -202,20 +202,30 @@ {% from '_workspace_tree_macro.html' import render_workspace_tree %}