feat: sidebar Repository identique au Workspace-local, pages forge unifiees, GC miroirs vides
This commit is contained in:
@@ -456,10 +456,10 @@ def _sidebar_data(request: Request, owner: str = "", repo: str = "") -> dict:
|
||||
has_active_workspace = False
|
||||
local_ws_id = 0
|
||||
|
||||
if ws_cookie and ws_cookie.startswith("gitea:"):
|
||||
# Gitea workspace: preserve context across pages. Also load the local
|
||||
# mirror workspace so it appears in "My Workspaces" in the top section
|
||||
# of the sidebar, in parallel with the Gitea repository tree.
|
||||
if ws_cookie and (ws_cookie.startswith("gitea:") or ws_cookie.startswith("github:")):
|
||||
# Forge workspace (Gitea/GitHub): preserve context across pages. Also
|
||||
# load the local mirror workspace so it appears in Workspace in
|
||||
# parallel with the Repository tree (same navigation as workspace-local).
|
||||
parts = ws_cookie.split(":", 2)
|
||||
if len(parts) >= 3:
|
||||
gitea_owner = parts[1]
|
||||
@@ -472,8 +472,9 @@ def _sidebar_data(request: Request, owner: str = "", repo: str = "") -> dict:
|
||||
try:
|
||||
with get_conn() as conn:
|
||||
row = conn.execute(
|
||||
"SELECT id FROM workspaces WHERE owner_id=? AND name=? AND settings_json LIKE ?",
|
||||
(user["id"], f"{gitea_owner}/{gitea_repo}", "%gitea_repo%")
|
||||
"SELECT id FROM workspaces WHERE owner_id=? AND name=? "
|
||||
"AND (settings_json LIKE '%gitea_repo%' OR settings_json LIKE '%github_repo%')",
|
||||
(user["id"], f"{gitea_owner}/{gitea_repo}"),
|
||||
).fetchone()
|
||||
if row:
|
||||
local_ws_id = row["id"]
|
||||
|
||||
@@ -34,8 +34,19 @@ router = APIRouter(tags=["board"], prefix="/board")
|
||||
|
||||
@router.get("/{owner}/{repo}", response_class=HTMLResponse)
|
||||
def board(request: Request, owner: str, repo: str, view: str = Query(default="")):
|
||||
from app.auth.session import SessionManager
|
||||
from app.routers.dashboard._common import _cleanup_empty_mirrors, _ensure_forge_mirror
|
||||
from app.templating import ENV
|
||||
env = ENV
|
||||
# Selecting a repository also opens a workspace-local of the same name:
|
||||
# ensure the mirror exists, prune other empty mirrors.
|
||||
user = SessionManager.decode_session(request.cookies.get("flowdeck_session", ""))
|
||||
if user and owner and repo:
|
||||
try:
|
||||
mid = _ensure_forge_mirror(user["id"], owner, repo, forge="gitea")
|
||||
_cleanup_empty_mirrors(user["id"], keep_name=f"{owner}/{repo}", keep_id=mid or 0)
|
||||
except Exception:
|
||||
logger.exception("board mirror ensure")
|
||||
sidebar = _sidebar_data(request, owner, repo)
|
||||
template = env.get_template("board.html")
|
||||
return template.render(request=request, owner=owner, repo=repo, groups=[],
|
||||
|
||||
Reference in New Issue
Block a user