| 1 | using AgentForge.Abstractions; |
| 2 | using AgentForge.Contracts; |
| 3 | using AgentForge.Data.Entities; |
| 4 | using AgentForge.Plugin.View.Components; |
| 5 | using AgentForge.Services; |
| 6 | |
| 7 | namespace AgentForge.Plugin.View.Pages; |
| 8 | |
| 9 | internal static class ForgeRepoPage |
| 10 | { |
| 11 | internal static string Render( |
| 12 | ForgeRepoEntity repo, |
| 13 | RepoResponse response, |
| 14 | string repoName, |
| 15 | string activeTab, |
| 16 | GitRepoService git, |
| 17 | IForgeViewContributorCatalog catalog, |
| 18 | IForgeRepoTabBodyCatalog tabBodies, |
| 19 | IServiceProvider services) |
| 20 | { |
| 21 | var tabBody = ResolveTabBody(repoName, activeTab, git, catalog, tabBodies, services, repo.Id); |
| 22 | |
| 23 | return ForgeHtml.Fragment( |
| 24 | ForgeViewRepoHeader.Render(repo, response), |
| 25 | ForgeViewTabPanel.Render(tabBody), |
| 26 | ForgeViewStatusBar.Render()); |
| 27 | } |
| 28 | |
| 29 | private static string ResolveTabBody( |
| 30 | string repoName, |
| 31 | string activeTab, |
| 32 | GitRepoService git, |
| 33 | IForgeViewContributorCatalog catalog, |
| 34 | IForgeRepoTabBodyCatalog tabBodies, |
| 35 | IServiceProvider services, |
| 36 | string repoId) |
| 37 | { |
| 38 | if (catalog.HasTab(activeTab) |
| 39 | && tabBodies.TryRender( |
| 40 | activeTab, |
| 41 | new ForgeRepoTabBodyContext |
| 42 | { |
| 43 | RepoName = repoName, |
| 44 | RepoId = repoId, |
| 45 | Services = services, |
| 46 | }, |
| 47 | out var html)) |
| 48 | { |
| 49 | return html; |
| 50 | } |
| 51 | |
| 52 | return ForgeCodeBrowsePage.RenderRootListing(repoName, git); |
| 53 | } |
| 54 | } |
| 55 | |