Skip to content

Commit 68402fc

Browse files
committed
Refactor naming and add comments
1 parent 59e01cd commit 68402fc

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Elastic.Markdown/Slices/IndexViewModel.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ public class VersionDrownDownItemViewModel
6363
[JsonPropertyName("children")]
6464
public required VersionDrownDownItemViewModel[]? Children { get; init; }
6565

66+
// This logic currently only handles one level of children. Although the model supports multiple levels, it is not currently used.
6667
public static VersionDrownDownItemViewModel[] FromLegacyPageMappings(LegacyPageMapping[] legacyPageMappings)
6768
{
68-
var potentialGroups = GetGroupedVersions(legacyPageMappings);
69-
return potentialGroups.Select(m =>
69+
var groupedVersions = GroupByMajorVersion(legacyPageMappings);
70+
return groupedVersions.Select(m =>
7071
{
7172
if (m.Value.Count != 1)
7273
{
@@ -93,7 +94,10 @@ public static VersionDrownDownItemViewModel[] FromLegacyPageMappings(LegacyPageM
9394
}).ToArray();
9495
}
9596

96-
private static Dictionary<string, List<string>> GetGroupedVersions(LegacyPageMapping[] legacyPageMappings) =>
97+
// The legacy page mappings provide a list of versions.
98+
// But in the actual dropdown, we want to group them by major version
99+
// E.g., 8.0 – 8.18 should be grouped under 8.x
100+
private static Dictionary<string, List<string>> GroupByMajorVersion(LegacyPageMapping[] legacyPageMappings) =>
97101
legacyPageMappings.Aggregate<LegacyPageMapping, Dictionary<string, List<string>>>([], (acc, curr) =>
98102
{
99103
var major = curr.Version.Split('.')[0];

0 commit comments

Comments
 (0)