Forge
csharp3407750f
1namespace AgentForge.Plugin.View.Components.Layout;
2
3internal static class ForgeViewHeaderTabs
4{
5 public static string Render(ForgeViewPageContext ctx)
6 {
7 var tabs = new List<string>
8 {
9 RenderTab(ctx.RepoName, "code", "Code", ctx.ActiveTab),
10 };
11
12 foreach (var contributor in ctx.Contributors ?? [])
13 {
14 var count = contributor.TabId switch
15 {
16 "issues" => ctx.IssueCount,
17 "merge-requests" => ctx.MrCount,
18 _ => 0,
19 };
20 tabs.Add(RenderTab(ctx.RepoName, contributor.TabId, contributor.Label, ctx.ActiveTab, count));
21 }
22
23 return ForgeHtml.Nav("header-tabs", "Repository", [.. tabs]);
24 }
25
26 private static string RenderTab(
27 string repoName,
28 string tabId,
29 string label,
30 string activeTab,
31 int count = 0)
32 {
33 var active = string.Equals(tabId, activeTab, StringComparison.OrdinalIgnoreCase);
34 var cssClass = active ? "header-tab active" : "header-tab";
35 var inner = count > 0
36 ? ForgeHtml.Fragment(
37 ForgeHtml.Text(label),
38 ForgeHtml.Span("tab-count", ForgeHtml.Text(count.ToString())))
39 : ForgeHtml.Text(label);
40
41 return ForgeHtml.ARaw(
42 ForgeViewLinks.RepoViewHref(repoName, tabId),
43 cssClass,
44 null,
45 null,
46 inner);
47 }
48}
49
View only · write via MCP/CIDE