diff --git a/src/Elastic.ApiExplorer/Endpoints/EndpointView.cshtml b/src/Elastic.ApiExplorer/Endpoints/EndpointView.cshtml index f9caa0901..b8487e1fb 100644 --- a/src/Elastic.ApiExplorer/Endpoints/EndpointView.cshtml +++ b/src/Elastic.ApiExplorer/Endpoints/EndpointView.cshtml @@ -13,6 +13,7 @@ NavigationHtml = Model.NavigationHtml, UrlPathPrefix = null, VersionDropdown = null, + CurrentVersion = null, AllowIndexing = false, CanonicalBaseUrl = null, GoogleTagManager = new GoogleTagManagerConfiguration(), diff --git a/src/Elastic.ApiExplorer/Landing/LandingView.cshtml b/src/Elastic.ApiExplorer/Landing/LandingView.cshtml index ccfd2d7f2..f6af0e1d7 100644 --- a/src/Elastic.ApiExplorer/Landing/LandingView.cshtml +++ b/src/Elastic.ApiExplorer/Landing/LandingView.cshtml @@ -13,6 +13,7 @@ NavigationHtml = Model.NavigationHtml, UrlPathPrefix = null, VersionDropdown = null, + CurrentVersion = "9.0+", AllowIndexing = false, CanonicalBaseUrl = null, GoogleTagManager = new GoogleTagManagerConfiguration(), diff --git a/src/Elastic.ApiExplorer/Operations/OperationView.cshtml b/src/Elastic.ApiExplorer/Operations/OperationView.cshtml index 626d57f5b..bf2593d1c 100644 --- a/src/Elastic.ApiExplorer/Operations/OperationView.cshtml +++ b/src/Elastic.ApiExplorer/Operations/OperationView.cshtml @@ -13,6 +13,7 @@ NavigationHtml = Model.NavigationHtml, UrlPathPrefix = null, VersionDropdown = null, + CurrentVersion = null, AllowIndexing = false, CanonicalBaseUrl = null, GoogleTagManager = new GoogleTagManagerConfiguration(), diff --git a/src/Elastic.Documentation.Site/Assets/web-components/VersionDropdown.tsx b/src/Elastic.Documentation.Site/Assets/web-components/VersionDropdown.tsx index 6640085f8..bc5b17576 100644 --- a/src/Elastic.Documentation.Site/Assets/web-components/VersionDropdown.tsx +++ b/src/Elastic.Documentation.Site/Assets/web-components/VersionDropdown.tsx @@ -45,14 +45,16 @@ appendIconComponentCache({ type VersionDropdownItem = { name: string href?: string + disabled: boolean children?: VersionDropdownItem[] } type VersionDropdownProps = { + currentVersion: string items: VersionDropdownItem[] } -const VersionDropdown = ({ items }: VersionDropdownProps) => { +const VersionDropdown = ({ currentVersion, items }: VersionDropdownProps) => { const [isPopoverOpen, setPopover] = useState(false) const contextMenuPopoverId = useGeneratedHtmlId({ @@ -74,6 +76,7 @@ const VersionDropdown = ({ items }: VersionDropdownProps) => { return { name: item.name, href: item.href, + disabled: item.disabled, } }) } @@ -90,6 +93,7 @@ const VersionDropdown = ({ items }: VersionDropdownProps) => { title: item.name, initialFocusedItemIndex: 0, width: WIDTH, + disabled: item.disabled, size: 's', items: item.children ? convertItems(item.children) : [], } @@ -104,6 +108,7 @@ const VersionDropdown = ({ items }: VersionDropdownProps) => { name: item.name, panel: item.children?.length ? index + 1 : undefined, href: item.href, + disabled: item.disabled, } }) @@ -117,7 +122,9 @@ const VersionDropdown = ({ items }: VersionDropdownProps) => { - Current (9.0+) + + Current ({currentVersion}) + ), width: WIDTH, @@ -149,7 +156,7 @@ const VersionDropdown = ({ items }: VersionDropdownProps) => { font-size: 0.875rem; `} > - Current (9.0+) + Current ({currentVersion}) ) @@ -174,6 +181,7 @@ customElements.define( r2wc(VersionDropdown, { props: { items: 'json', + currentVersion: 'string', }, }) ) diff --git a/src/Elastic.Documentation.Site/Layout/_SecondaryNav.cshtml b/src/Elastic.Documentation.Site/Layout/_SecondaryNav.cshtml index a7788b157..528317811 100644 --- a/src/Elastic.Documentation.Site/Layout/_SecondaryNav.cshtml +++ b/src/Elastic.Documentation.Site/Layout/_SecondaryNav.cshtml @@ -17,7 +17,7 @@ @if (Model.Features.IsVersionDropdownEnabled && Model.VersionDropdown is not null) {
- +
} diff --git a/src/Elastic.Documentation.Site/_ViewModels.cs b/src/Elastic.Documentation.Site/_ViewModels.cs index 5ea53f8b6..0a7250d90 100644 --- a/src/Elastic.Documentation.Site/_ViewModels.cs +++ b/src/Elastic.Documentation.Site/_ViewModels.cs @@ -26,6 +26,7 @@ public class GlobalLayoutViewModel public required INavigationItem? Next { get; init; } public required string? VersionDropdown { get; init; } + public required string? CurrentVersion { get; init; } public required string NavigationHtml { get; init; } public required string? UrlPathPrefix { get; init; } diff --git a/src/Elastic.Markdown/Slices/IndexViewModel.cs b/src/Elastic.Markdown/Slices/IndexViewModel.cs index 582285721..77bcf9f45 100644 --- a/src/Elastic.Markdown/Slices/IndexViewModel.cs +++ b/src/Elastic.Markdown/Slices/IndexViewModel.cs @@ -59,6 +59,9 @@ public class VersionDrownDownItemViewModel [JsonPropertyName("href")] public required string? Href { get; init; } + [JsonPropertyName("disabled")] + public required bool IsDisabled { get; init; } + [JsonPropertyName("children")] public required VersionDrownDownItemViewModel[]? Children { get; init; } @@ -66,9 +69,7 @@ public class VersionDrownDownItemViewModel public static VersionDrownDownItemViewModel[]? FromLegacyPageMappings(LegacyPageMapping[]? legacyPageMappings) { if (legacyPageMappings is null) - { return null; - } var groupedVersions = GroupByMajorVersion(legacyPageMappings); return groupedVersions.Select(m => { @@ -79,10 +80,12 @@ public class VersionDrownDownItemViewModel { Name = m.Key, Href = null, + IsDisabled = false, Children = m.Value.Select(v => new VersionDrownDownItemViewModel { Name = v, Href = legacyPageMappings.First(x => x.Version == v).ToString(), + IsDisabled = !legacyPageMappings.First(x => x.Version == v).Exists, Children = null }).ToArray() }; @@ -95,6 +98,7 @@ public class VersionDrownDownItemViewModel { Name = legacyPageMapping.Version, Href = legacyPageMapping.ToString(), + IsDisabled = !legacyPageMapping.Exists, Children = null }; }).ToArray(); diff --git a/src/Elastic.Markdown/Slices/MarkdownLayoutViewModel.cs b/src/Elastic.Markdown/Slices/MarkdownLayoutViewModel.cs index 6ca38949a..9fa71f785 100644 --- a/src/Elastic.Markdown/Slices/MarkdownLayoutViewModel.cs +++ b/src/Elastic.Markdown/Slices/MarkdownLayoutViewModel.cs @@ -16,8 +16,6 @@ public class MarkdownLayoutViewModel : GlobalLayoutViewModel public required INavigationItem[] Parents { get; init; } - public required string? CurrentVersion { get; init; } - public required LegacyPageMapping[]? LegacyPages { get; init; } public required IReadOnlyCollection PageTocItems { get; init; }