Forge
csharp3407750f
1using AgentForge.Data.Entities;
2using AgentForge.Models;
3
4namespace AgentForge.Plugin.View.Components.Iop;
5
6internal static class ForgeViewIopCiBadge
7{
8 internal static string Render(ForgeCiRunEntity? run)
9 {
10 if (run is null)
11 return ForgeHtml.Span("ci-badge ci-unknown", ForgeHtml.Text("CI —"));
12
13 var css = run.Status switch
14 {
15 CiRunStatus.Success => "ci-badge ci-pass",
16 CiRunStatus.Failure or CiRunStatus.Cancelled => "ci-badge ci-fail",
17 CiRunStatus.Pending => "ci-badge ci-pending",
18 _ => "ci-badge ci-unknown",
19 };
20 var label = run.Status switch
21 {
22 CiRunStatus.Success => "✓ passed",
23 CiRunStatus.Failure => "✗ failed",
24 CiRunStatus.Pending => "… pending",
25 CiRunStatus.Cancelled => "cancelled",
26 _ => "—",
27 };
28
29 var parts = new List<string>
30 {
31 ForgeHtml.Span(css, ForgeHtml.Text($"CI {label}")),
32 };
33 if (!string.IsNullOrWhiteSpace(run.Url))
34 {
35 parts.Add(ForgeHtml.Text(" "));
36 parts.Add(ForgeHtml.A(run.Url, "log", "iop-meta"));
37 }
38
39 return ForgeHtml.Fragment([.. parts]);
40 }
41}
42
View only · write via MCP/CIDE