Forge
csharp3407750f
1using System.Text;
2using AgentForge.Contracts;
3using AgentForge.Data;
4using AgentForge.Data.Entities;
5using AgentForge.Plugin.View.Components.Code;
6using AgentForge.Plugin.View.Components.Iop;
7using AgentForge.Services;
8
9namespace AgentForge.Plugin.View.Pages;
10
11internal static class ForgeCodeBrowsePage
12{
13 internal static string RenderRootListing(string repoName, GitRepoService git) =>
14 ForgeViewCodeRootListing.Render(repoName, git);
15
16 internal static string RenderTree(
17 string repoName,
18 string activeBranch,
19 string? path,
20 GitRepoService git,
21 IReadOnlyList<GitRepoService.GitTreeItem> entries)
22 {
23 var nav = ForgeViewCodeNav.Render(repoName, activeBranch, git.ListBranches(repoName), path, isBlob: false);
24 var tree = ForgeViewFileTree.Render(repoName, activeBranch, entries, path);
25 return ForgeHtml.Fragment(nav, tree);
26 }
27
28 internal static string RenderBlobMain(
29 string repoName,
30 string activeBranch,
31 string path,
32 IReadOnlyList<string> branches,
33 string? commitTip,
34 string fileContentHtml,
35 int? scrollToLine)
36 {
37 var nav = ForgeViewCodeNav.Render(repoName, activeBranch, branches, path, isBlob: true, commitTip);
38 var scrollScript = scrollToLine is > 0
39 ? Components.Artifact.ForgeViewScrollToLineScript.Render(scrollToLine.Value)
40 : "";
41
42 return ForgeHtml.Fragment(nav, fileContentHtml, scrollScript);
43 }
44
45 internal static void AppendBranchIopPanel(
46 StringBuilder body,
47 string repoName,
48 string branch,
49 ForgeMergeRequestEntity? mergeRequest,
50 ForgeRepoEntity repo,
51 ForgeRepository repository,
52 MergeRequestService mergeRequests,
53 string iopTab,
54 string? blobPath)
55 {
56 MergeRequestDiffResponse? diff = null;
57 ForgeIopTabLinks tabLinks;
58 if (mergeRequest is null)
59 tabLinks = new ForgeIopTabLinks("#", "#", "#");
60 else
61 {
62 diff = mergeRequests.GetDiff(repo, mergeRequest.Number);
63 tabLinks = !string.IsNullOrWhiteSpace(blobPath)
64 ? ForgeIopViewRenderer.BlobTabLinks(repoName, branch, blobPath)
65 : ForgeIopViewRenderer.MrPageTabLinks(repoName, mergeRequest.Number);
66 }
67
68 ForgeIopViewRenderer.AppendBranchContextPanel(
69 body,
70 repoName,
71 branch,
72 mergeRequest,
73 repo,
74 repository,
75 iopTab,
76 tabLinks,
77 diff);
78 }
79}
80
View only · write via MCP/CIDE