Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ public bool PrimaryNavEnabled
set => _featureFlags["primary-nav"] = value;
}

public bool VersionDropdownEnabled
{
get => IsEnabled("version-dropdown");
set => _featureFlags["version-dropdown"] = value;
}

private bool IsEnabled(string key)
{
var envKey = $"FEATURE_{key.ToUpperInvariant().Replace('-', '_')}";
Expand Down
2 changes: 1 addition & 1 deletion src/Elastic.Documentation.Site/Htmx.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Elastic.Documentation.Site;

public static class Htmx
{
public static string GetHxSelectOob(bool hasSameTopLevelGroup) => "#version-dropdown," + (hasSameTopLevelGroup ? "#content-container,#toc-nav" : "#main-container");
public static string GetHxSelectOob(bool hasSameTopLevelGroup) => hasSameTopLevelGroup ? "#content-container,#toc-nav" : "#main-container";
public const string Preload = "mousedown";
public const string HxSwap = "none";
public const string HxPushUrl = "true";
Expand Down
96 changes: 2 additions & 94 deletions src/Elastic.Markdown/Slices/Layout/_TableOfContents.cshtml
Original file line number Diff line number Diff line change
@@ -1,101 +1,9 @@
@inherits RazorSlice<MarkdownLayoutViewModel>
<aside class="sidebar hidden lg:block max-w-65 md:hidden">
<nav id="toc-nav" class="sidebar-nav h-full">
@if (Model.Features.VersionDropdownEnabled)
{
<div class="mt-6">
<version-dropdown all-versions-url="@Model.AllVersionsUrl" current-version='@(Model.CurrentVersion)' items='@(new HtmlString(Model.VersionDropdownSerializedModel))' />
</div>
}
else
{
<div id="page-version-dropdown" tabindex="1"
class="mt-6 block group font-sans text-sm relative z-50">
<button
class="text-left border-1 rounded-2xl grid grid-cols-[1fr_auto] cursor-pointer font-semibold gap-1 hover:text-black pl-4 pr-1 py-1 group-open:border-b-1 border-grey-20">
<div>
<span class="page-version-dropdown_active text-ink">
@if (Model.CurrentVersion is not null)
{
<span>Current version (@Model.CurrentVersion)</span>
}
else
{
<span>Current version</span>
}
</span>
</div>
<div class="flex items-center my-auto justify-center size-5 hover:bg-grey-20 rounded-xl">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
stroke-width="1.5"
stroke="currentColor"
class="w-4 group-open:rotate-180">
<path stroke-linecap="round" stroke-linejoin="round" d="m19.5 9.25-7.5 8.5-7.5-8.5"/>
</svg>
</div>
</button>
<div class="hidden group-focus-within:block left-0 right-0 absolute top-full w-max min-w-30 max-w-60">
<ul class="mt-1 py-0 mb-4 bg-white border-1 border-grey-20 rounded-sm shadow-md">
<li class="block">
<a

class="block py-1 px-4 font-semibold text-grey-60 cursor-default"
@Htmx.GetNavHxAttributes(false, "mouseover")
>
@if (Model.CurrentVersion is not null)
{
<span>@Model.CurrentVersion ✓</span>
}
else
{
<span>current ✓</span>
}
</a>
</li>
@foreach (var legacyPage in Model.LegacyPages ?? [])
{
<li class="block">
@if (legacyPage.Exists)
{
<a
class="block py-1 px-4 text-sm hover:underline hover:text-black hover:bg-grey-10 active:bg-blue-elastic-70 active:text-white font-semibold text-ink rounded-sm"
href="@legacyPage">
@legacyPage.Version
</a>
}
else
{
<a
class="block py-1 px-4 font-semibold text-grey-60 cursor-default">
@legacyPage.Version
</a>
}

</li>
}
@if (Model.LegacyPages is null) // This means there is no mapping because the page is new in v3
{
<li class="block border-t-1 border-grey-20">
<div class="py-1 px-4 text-sm">
There is no previous version of this page.
</div>
</li>
}
else if (Model.LegacyPages.Length == 0) // This means there is a legacy page mapping with 0 entries, which means the page was fully migrated and is also redirecting to the new system.
{
<li class="block border-t-1 border-grey-20">
<div class="py-1 px-4 text-sm">
This page was fully migrated to the current version.
</div>
</li>
}
</ul>
</div>
<div class="mt-6">
<version-dropdown all-versions-url="@Model.AllVersionsUrl" current-version='@(Model.CurrentVersion)' items='@(new HtmlString(Model.VersionDropdownSerializedModel))' />
</div>
}
<ul class="mt-6">

@if (Model.GithubEditUrl is not null)
Expand Down
2 changes: 0 additions & 2 deletions src/tooling/docs-assembler/assembler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ environments:
content_source: next
google_tag_manager:
enabled: false
feature_flags:
VERSION_DROPDOWN: true
dev:
uri: http://localhost:4000
content_source: next
Expand Down
10 changes: 5 additions & 5 deletions tests/Elastic.Markdown.Tests/Inline/AnchorLinkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ [Sub Requirements](testing/req.md#sub-requirements)
public void GeneratesHtml() =>
// language=html
Html.Should().Contain(
"""<p><a href="/docs/testing/req#sub-requirements" hx-get="/docs/testing/req#sub-requirements" hx-select-oob="#version-dropdown,#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Sub Requirements</a></p>"""
"""<p><a href="/docs/testing/req#sub-requirements" hx-get="/docs/testing/req#sub-requirements" hx-select-oob="#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Sub Requirements</a></p>"""
);

[Fact]
Expand All @@ -93,7 +93,7 @@ [Sub Requirements](testing/req.md#new-reqs)
public void GeneratesHtml() =>
// language=html
Html.Should().Contain(
"""<p><a href="/docs/testing/req#new-reqs" hx-get="/docs/testing/req#new-reqs" hx-select-oob="#version-dropdown,#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Sub Requirements</a></p>"""
"""<p><a href="/docs/testing/req#new-reqs" hx-get="/docs/testing/req#new-reqs" hx-select-oob="#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Sub Requirements</a></p>"""
);

[Fact]
Expand All @@ -110,7 +110,7 @@ public class ExternalPageAnchorAutoTitleTests(ITestOutputHelper output) : Anchor
public void GeneratesHtml() =>
// language=html
Html.Should().Contain(
"""<p><a href="/docs/testing/req#sub-requirements" hx-get="/docs/testing/req#sub-requirements" hx-select-oob="#version-dropdown,#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Special Requirements &gt; Sub Requirements</a></p>"""
"""<p><a href="/docs/testing/req#sub-requirements" hx-get="/docs/testing/req#sub-requirements" hx-select-oob="#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Special Requirements &gt; Sub Requirements</a></p>"""
);

[Fact]
Expand Down Expand Up @@ -146,7 +146,7 @@ [Sub Requirements](testing/req.md#sub-requirements2)
public void GeneratesHtml() =>
// language=html
Html.Should().Contain(
"""<p><a href="/docs/testing/req#sub-requirements2" hx-get="/docs/testing/req#sub-requirements2" hx-select-oob="#version-dropdown,#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Sub Requirements</a></p>"""
"""<p><a href="/docs/testing/req#sub-requirements2" hx-get="/docs/testing/req#sub-requirements2" hx-select-oob="#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Sub Requirements</a></p>"""
);

[Fact]
Expand All @@ -165,7 +165,7 @@ [Heading inside dropdown](testing/req.md#heading-inside-dropdown)
public void GeneratesHtml() =>
// language=html
Html.Should().Contain(
"""<a href="/docs/testing/req#heading-inside-dropdown" hx-get="/docs/testing/req#heading-inside-dropdown" hx-select-oob="#version-dropdown,#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Heading inside dropdown</a>"""
"""<a href="/docs/testing/req#heading-inside-dropdown" hx-get="/docs/testing/req#heading-inside-dropdown" hx-select-oob="#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Heading inside dropdown</a>"""
);
[Fact]
public void HasError() => Collector.Diagnostics.Should().HaveCount(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ [Sub Requirements](testing/req.md#hint_ref)
public void GeneratesHtml() =>
// language=html
Html.Should().Contain(
"""<p><a href="/docs/testing/req#hint_ref" hx-get="/docs/testing/req#hint_ref" hx-select-oob="#version-dropdown,#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Sub Requirements</a></p>"""
"""<p><a href="/docs/testing/req#hint_ref" hx-get="/docs/testing/req#hint_ref" hx-select-oob="#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Sub Requirements</a></p>"""
);

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion tests/Elastic.Markdown.Tests/Inline/InlineAnchorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ [Sub Requirements](testing/req.md#custom-anchor)
public void GeneratesHtml() =>
// language=html
Html.Should().Contain(
"""<p><a href="/docs/testing/req#custom-anchor" hx-get="/docs/testing/req#custom-anchor" hx-select-oob="#version-dropdown,#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Sub Requirements</a></p>"""
"""<p><a href="/docs/testing/req#custom-anchor" hx-get="/docs/testing/req#custom-anchor" hx-select-oob="#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Sub Requirements</a></p>"""
);

[Fact]
Expand Down
12 changes: 6 additions & 6 deletions tests/Elastic.Markdown.Tests/Inline/InlineLinkTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class InlineLinkTests(ITestOutputHelper output) : LinkTestBase(output,
public void GeneratesHtml() =>
// language=html
Html.Should().Be(
"""<p><a href="/docs/_static/img/observability.png" hx-get="/docs/_static/img/observability.png" hx-select-oob="#version-dropdown,#main-container" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Elasticsearch</a></p>"""
"""<p><a href="/docs/_static/img/observability.png" hx-get="/docs/_static/img/observability.png" hx-select-oob="#main-container" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Elasticsearch</a></p>"""
);

[Fact]
Expand All @@ -66,7 +66,7 @@ public class LinkToPageTests(ITestOutputHelper output) : LinkTestBase(output,
public void GeneratesHtml() =>
// language=html
Html.Should().Contain(
"""<p><a href="/docs/testing/req" hx-get="/docs/testing/req" hx-select-oob="#version-dropdown,#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Requirements</a></p>"""
"""<p><a href="/docs/testing/req" hx-get="/docs/testing/req" hx-select-oob="#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Requirements</a></p>"""
);

[Fact]
Expand All @@ -86,7 +86,7 @@ public class InsertPageTitleTests(ITestOutputHelper output) : LinkTestBase(outpu
public void GeneratesHtml() =>
// language=html
Html.Should().Contain(
"""<p><a href="/docs/testing/req" hx-get="/docs/testing/req" hx-select-oob="#version-dropdown,#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Special Requirements</a></p>"""
"""<p><a href="/docs/testing/req" hx-get="/docs/testing/req" hx-select-oob="#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Special Requirements</a></p>"""
);

[Fact]
Expand All @@ -108,7 +108,7 @@ public class RepositoryLinksTest(ITestOutputHelper output) : LinkTestBase(output
public void GeneratesHtml() =>
// language=html
Html.Should().Contain(
"""<p><a href="/docs/testing/req" hx-get="/docs/testing/req" hx-select-oob="#version-dropdown,#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">test</a></p>"""
"""<p><a href="/docs/testing/req" hx-get="/docs/testing/req" hx-select-oob="#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">test</a></p>"""
);

[Fact]
Expand Down Expand Up @@ -270,10 +270,10 @@ public void GeneratesHtml() =>
Html.ReplaceLineEndings().TrimEnd().Should().Be("""
<p>Links:</p>
<ul>
<li><a href="/docs/testing/req" hx-get="/docs/testing/req" hx-select-oob="#version-dropdown,#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Special Requirements</a></li>
<li><a href="/docs/testing/req" hx-get="/docs/testing/req" hx-select-oob="#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Special Requirements</a></li>
</ul>
<ul>
<li><a href="/docs/testing/req" hx-get="/docs/testing/req" hx-select-oob="#version-dropdown,#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Special Requirements</a></li>
<li><a href="/docs/testing/req" hx-get="/docs/testing/req" hx-select-oob="#content-container,#toc-nav" hx-swap="none" hx-push-url="true" hx-indicator="#htmx-indicator" preload="mousedown">Special Requirements</a></li>
</ul>
""".ReplaceLineEndings());

Expand Down
Loading