| 1 | using AgentForge.Contracts; |
| 2 | using AgentForge.Data.Entities; |
| 3 | |
| 4 | namespace AgentForge.Plugin.View.Components; |
| 5 | |
| 6 | public static class ForgeViewRepoHeader |
| 7 | { |
| 8 | public static string Render(ForgeRepoEntity repo, RepoResponse response) |
| 9 | { |
| 10 | SplitRepoName(repo.Name, out var orgFromName, out var shortName); |
| 11 | var org = response.Org ?? orgFromName; |
| 12 | |
| 13 | var crumb = org is not null |
| 14 | ? ForgeHtml.P( |
| 15 | "repo-crumb meta", |
| 16 | ForgeHtml.A(OrgCatalogHref(org), org), |
| 17 | ForgeHtml.Text(" / "), |
| 18 | ForgeHtml.Text(shortName)) |
| 19 | : ""; |
| 20 | |
| 21 | return ForgeHtml.Header( |
| 22 | "repo-header", |
| 23 | crumb, |
| 24 | ForgeHtml.H1(shortName), |
| 25 | ForgeViewRepoMeta.Render(repo, response)); |
| 26 | } |
| 27 | |
| 28 | internal static string OrgCatalogHref(string orgSlug) => |
| 29 | orgSlug.StartsWith("u-", StringComparison.Ordinal) |
| 30 | ? "/view/me" |
| 31 | : $"/view/orgs/{Uri.EscapeDataString(orgSlug)}"; |
| 32 | |
| 33 | private static void SplitRepoName(string fullName, out string? org, out string shortName) |
| 34 | { |
| 35 | var slash = fullName.IndexOf('/', StringComparison.Ordinal); |
| 36 | if (slash < 0) |
| 37 | { |
| 38 | org = null; |
| 39 | shortName = fullName; |
| 40 | return; |
| 41 | } |
| 42 | |
| 43 | org = fullName[..slash]; |
| 44 | shortName = fullName[(slash + 1)..]; |
| 45 | } |
| 46 | } |
| 47 | |
View only · write via MCP/CIDE