Forge
csharp3407750f
1using AgentForge.Abstractions;
2using AgentForge.Data.Entities;
3
4namespace AgentForge.Plugin.Org.Web.Components;
5
6internal readonly struct ForgeViewOrgCatalogContext
7{
8 internal ForgeViewOrgCatalogContext(
9 string orgSlug,
10 string catalogBasePath,
11 ForgeViewOrgCatalogIndex.Model index,
12 IReadOnlyDictionary<string, string> groupPaths,
13 string? activeGroupPath,
14 ForgeOrgCatalogViewContext groupingContext,
15 IForgeOrgCatalogGrouping? grouping = null)
16 {
17 OrgSlug = orgSlug;
18 CatalogBasePath = catalogBasePath;
19 Index = index;
20 GroupPaths = groupPaths;
21 ActiveGroupPath = activeGroupPath;
22 GroupingContext = groupingContext;
23 Grouping = grouping;
24 }
25
26 internal string OrgSlug { get; }
27
28 internal string CatalogBasePath { get; }
29
30 internal ForgeViewOrgCatalogIndex.Model Index { get; }
31
32 internal IReadOnlyDictionary<string, string> GroupPaths { get; }
33
34 internal string? ActiveGroupPath { get; }
35
36 internal ForgeOrgCatalogViewContext GroupingContext { get; }
37
38 internal IForgeOrgCatalogGrouping? Grouping { get; }
39
40 internal string ResolvePath(ForgeRepoGroupEntity group) =>
41 GroupPaths.TryGetValue(group.Id, out var path) ? path : group.Slug;
42
43 internal bool IsActive(string path) =>
44 !string.IsNullOrWhiteSpace(ActiveGroupPath)
45 && string.Equals(path, ActiveGroupPath, StringComparison.OrdinalIgnoreCase);
46
47 internal bool ShouldExpand(string path)
48 {
49 if (string.IsNullOrWhiteSpace(ActiveGroupPath))
50 return false;
51
52 if (string.Equals(path, ActiveGroupPath, StringComparison.OrdinalIgnoreCase))
53 return true;
54
55 var prefix = path + "/";
56 return ActiveGroupPath.StartsWith(prefix, StringComparison.OrdinalIgnoreCase);
57 }
58}
59
View only · write via MCP/CIDE