| 1 | using AgentForge.Abstractions; |
| 2 | using AgentForge.Contracts; |
| 3 | using AgentForge.Plugin.View; |
| 4 | |
| 5 | namespace AgentForge.Plugin.Org.Web.Components; |
| 6 | |
| 7 | internal static class ForgeViewOrgRepoList |
| 8 | { |
| 9 | internal static void AddRepoNodes( |
| 10 | ICollection<string> childNodes, |
| 11 | IReadOnlyList<RepoResponse> repos, |
| 12 | IForgeOrgCatalogGrouping? grouping, |
| 13 | in ForgeOrgCatalogViewContext groupingContext) |
| 14 | { |
| 15 | if (repos.Count == 0) |
| 16 | return; |
| 17 | |
| 18 | if (grouping is null) |
| 19 | { |
| 20 | foreach (var repo in repos) |
| 21 | childNodes.Add(ForgeViewOrgRepoNode.Render(repo)); |
| 22 | return; |
| 23 | } |
| 24 | |
| 25 | grouping.AppendRepoNodes(childNodes, ForgeOrgCatalogRepoMapping.ToItems(repos), groupingContext); |
| 26 | } |
| 27 | |
| 28 | internal static string RenderBody( |
| 29 | IReadOnlyList<RepoResponse> repos, |
| 30 | IForgeOrgCatalogGrouping? grouping, |
| 31 | in ForgeOrgCatalogViewContext groupingContext) |
| 32 | { |
| 33 | if (repos.Count == 0) |
| 34 | return ""; |
| 35 | |
| 36 | if (grouping is null) |
| 37 | return ForgeHtml.Ul("plain org-repo-tree-children", [.. repos.Select(ForgeViewOrgRepoNode.Render)]); |
| 38 | |
| 39 | return grouping.RenderRepoBody(ForgeOrgCatalogRepoMapping.ToItems(repos), groupingContext); |
| 40 | } |
| 41 | } |
| 42 | |