"""HTML views for project registry pages (#427)."""
from __future__ import annotations
import html
from webui.layout import render_page
from webui.project_registry import ProjectRecord, ProjectRegistry
def _escape(text: str) -> str:
return html.escape(text, quote=True)
def render_projects_list(registry: ProjectRegistry) -> str:
rows = []
for project in registry.projects:
rows.append(
"
"
f"| {_escape(project.repo_name)} | "
f"{_escape(project.gitea_owner)} | "
f"{_escape(project.remote_host)} | "
f"{_escape(project.default_branch)} | "
f"{_escape(project.profiles['author'])} | "
"
"
)
table = (
""
""
"| Repository | Owner | Remote | "
"Branch | Author profile | "
"
"
f"{''.join(rows)}
"
)
body = (
"Projects
"
"Configured repositories managed by the MCP Control Plane.
"
f"Registry: {_escape(str(registry.source_path))} "
f"(version {registry.version})
"
f"{table}"
"JSON API
"
)
return render_page(title="Projects", body_html=body)
def render_project_detail(project: ProjectRecord) -> str:
profile_rows = "".join(
f"| {_escape(role)} | {_escape(name)} |
"
for role, name in project.profiles.items()
)
workflow_rows = "".join(
f"| {_escape(key)} | {_escape(path)} |
"
for key, path in project.workflow_paths.items()
)
schema_rows = "".join(
f"| {_escape(key)} | {_escape(path)} |
"
for key, path in project.schema_paths.items()
)
checklist_items = []
for index, step in enumerate(project.onboarding_checklist, start=1):
checklist_items.append(
""
f"{index}. {_escape(step.title)}"
f"{_escape(step.description)}
"
""
)
checklist_html = (
"" + "".join(checklist_items) + "
"
if checklist_items
else "No onboarding steps defined.
"
)
body = (
f"{_escape(project.repo_name)}
"
"← All projects
"
"Identity
"
""
f"| Registry id | {_escape(project.id)} |
"
f"| Gitea owner | {_escape(project.gitea_owner)} |
"
f"| Remote host | {_escape(project.remote_host)} |
"
f"| Default branch | {_escape(project.default_branch)} |
"
f"| Local checkout | {_escape(project.local_checkout_path)} |
"
"
"
"Profiles
"
f""
"Workflow paths
"
f""
"Schema paths
"
f""
"Onboarding checklist
"
"Read-only MVP — complete these steps outside the UI.
"
f"{checklist_html}"
)
return render_page(title=project.repo_name, body_html=body)