Skip to content

Commit a5b1762

Browse files
authored
Remove VersionDropdown feature flag, which enables it by default (#1402)
1 parent 74aae1a commit a5b1762

File tree

8 files changed

+16
-116
lines changed

8 files changed

+16
-116
lines changed

src/Elastic.Documentation.Configuration/Builder/FeatureFlags.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ public bool PrimaryNavEnabled
2020
set => _featureFlags["primary-nav"] = value;
2121
}
2222

23-
public bool VersionDropdownEnabled
24-
{
25-
get => IsEnabled("version-dropdown");
26-
set => _featureFlags["version-dropdown"] = value;
27-
}
28-
2923
private bool IsEnabled(string key)
3024
{
3125
var envKey = $"FEATURE_{key.ToUpperInvariant().Replace('-', '_')}";

src/Elastic.Documentation.Site/Htmx.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Elastic.Documentation.Site;
88

99
public static class Htmx
1010
{
11-
public static string GetHxSelectOob(bool hasSameTopLevelGroup) => "#version-dropdown," + (hasSameTopLevelGroup ? "#content-container,#toc-nav" : "#main-container");
11+
public static string GetHxSelectOob(bool hasSameTopLevelGroup) => hasSameTopLevelGroup ? "#content-container,#toc-nav" : "#main-container";
1212
public const string Preload = "mousedown";
1313
public const string HxSwap = "none";
1414
public const string HxPushUrl = "true";

src/Elastic.Markdown/Slices/Layout/_TableOfContents.cshtml

Lines changed: 2 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,9 @@
11
@inherits RazorSlice<MarkdownLayoutViewModel>
22
<aside class="sidebar hidden lg:block max-w-65 md:hidden">
33
<nav id="toc-nav" class="sidebar-nav h-full">
4-
@if (Model.Features.VersionDropdownEnabled)
5-
{
6-
<div class="mt-6">
7-
<version-dropdown all-versions-url="@Model.AllVersionsUrl" current-version='@(Model.CurrentVersion)' items='@(new HtmlString(Model.VersionDropdownSerializedModel))' />
8-
</div>
9-
}
10-
else
11-
{
12-
<div id="page-version-dropdown" tabindex="1"
13-
class="mt-6 block group font-sans text-sm relative z-50">
14-
<button
15-
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">
16-
<div>
17-
<span class="page-version-dropdown_active text-ink">
18-
@if (Model.CurrentVersion is not null)
19-
{
20-
<span>Current version (@Model.CurrentVersion)</span>
21-
}
22-
else
23-
{
24-
<span>Current version</span>
25-
}
26-
</span>
27-
</div>
28-
<div class="flex items-center my-auto justify-center size-5 hover:bg-grey-20 rounded-xl">
29-
<svg
30-
xmlns="http://www.w3.org/2000/svg"
31-
fill="none"
32-
viewBox="0 0 24 24"
33-
stroke-width="1.5"
34-
stroke="currentColor"
35-
class="w-4 group-open:rotate-180">
36-
<path stroke-linecap="round" stroke-linejoin="round" d="m19.5 9.25-7.5 8.5-7.5-8.5"/>
37-
</svg>
38-
</div>
39-
</button>
40-
<div class="hidden group-focus-within:block left-0 right-0 absolute top-full w-max min-w-30 max-w-60">
41-
<ul class="mt-1 py-0 mb-4 bg-white border-1 border-grey-20 rounded-sm shadow-md">
42-
<li class="block">
43-
<a
44-
45-
class="block py-1 px-4 font-semibold text-grey-60 cursor-default"
46-
@Htmx.GetNavHxAttributes(false, "mouseover")
47-
>
48-
@if (Model.CurrentVersion is not null)
49-
{
50-
<span>@Model.CurrentVersion ✓</span>
51-
}
52-
else
53-
{
54-
<span>current ✓</span>
55-
}
56-
</a>
57-
</li>
58-
@foreach (var legacyPage in Model.LegacyPages ?? [])
59-
{
60-
<li class="block">
61-
@if (legacyPage.Exists)
62-
{
63-
<a
64-
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"
65-
href="@legacyPage">
66-
@legacyPage.Version
67-
</a>
68-
}
69-
else
70-
{
71-
<a
72-
class="block py-1 px-4 font-semibold text-grey-60 cursor-default">
73-
@legacyPage.Version
74-
</a>
75-
}
76-
77-
</li>
78-
}
79-
@if (Model.LegacyPages is null) // This means there is no mapping because the page is new in v3
80-
{
81-
<li class="block border-t-1 border-grey-20">
82-
<div class="py-1 px-4 text-sm">
83-
There is no previous version of this page.
84-
</div>
85-
</li>
86-
}
87-
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.
88-
{
89-
<li class="block border-t-1 border-grey-20">
90-
<div class="py-1 px-4 text-sm">
91-
This page was fully migrated to the current version.
92-
</div>
93-
</li>
94-
}
95-
</ul>
96-
</div>
4+
<div class="mt-6">
5+
<version-dropdown all-versions-url="@Model.AllVersionsUrl" current-version='@(Model.CurrentVersion)' items='@(new HtmlString(Model.VersionDropdownSerializedModel))' />
976
</div>
98-
}
997
<ul class="mt-6">
1008

1019
@if (Model.GithubEditUrl is not null)

src/tooling/docs-assembler/assembler.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ environments:
2323
content_source: next
2424
google_tag_manager:
2525
enabled: false
26-
feature_flags:
27-
VERSION_DROPDOWN: true
2826
dev:
2927
uri: http://localhost:4000
3028
content_source: next

tests/Elastic.Markdown.Tests/Inline/AnchorLinkTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ [Sub Requirements](testing/req.md#sub-requirements)
7575
public void GeneratesHtml() =>
7676
// language=html
7777
Html.Should().Contain(
78-
"""<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>"""
78+
"""<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>"""
7979
);
8080

8181
[Fact]
@@ -93,7 +93,7 @@ [Sub Requirements](testing/req.md#new-reqs)
9393
public void GeneratesHtml() =>
9494
// language=html
9595
Html.Should().Contain(
96-
"""<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>"""
96+
"""<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>"""
9797
);
9898

9999
[Fact]
@@ -110,7 +110,7 @@ public class ExternalPageAnchorAutoTitleTests(ITestOutputHelper output) : Anchor
110110
public void GeneratesHtml() =>
111111
// language=html
112112
Html.Should().Contain(
113-
"""<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>"""
113+
"""<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>"""
114114
);
115115

116116
[Fact]
@@ -146,7 +146,7 @@ [Sub Requirements](testing/req.md#sub-requirements2)
146146
public void GeneratesHtml() =>
147147
// language=html
148148
Html.Should().Contain(
149-
"""<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>"""
149+
"""<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>"""
150150
);
151151

152152
[Fact]
@@ -165,7 +165,7 @@ [Heading inside dropdown](testing/req.md#heading-inside-dropdown)
165165
public void GeneratesHtml() =>
166166
// language=html
167167
Html.Should().Contain(
168-
"""<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>"""
168+
"""<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>"""
169169
);
170170
[Fact]
171171
public void HasError() => Collector.Diagnostics.Should().HaveCount(0);

tests/Elastic.Markdown.Tests/Inline/DirectiveBlockLinkTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ [Sub Requirements](testing/req.md#hint_ref)
6666
public void GeneratesHtml() =>
6767
// language=html
6868
Html.Should().Contain(
69-
"""<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>"""
69+
"""<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>"""
7070
);
7171

7272
[Fact]

tests/Elastic.Markdown.Tests/Inline/InlineAnchorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ [Sub Requirements](testing/req.md#custom-anchor)
200200
public void GeneratesHtml() =>
201201
// language=html
202202
Html.Should().Contain(
203-
"""<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>"""
203+
"""<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>"""
204204
);
205205

206206
[Fact]

tests/Elastic.Markdown.Tests/Inline/InlineLinkTests.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class InlineLinkTests(ITestOutputHelper output) : LinkTestBase(output,
4949
public void GeneratesHtml() =>
5050
// language=html
5151
Html.Should().Be(
52-
"""<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>"""
52+
"""<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>"""
5353
);
5454

5555
[Fact]
@@ -66,7 +66,7 @@ public class LinkToPageTests(ITestOutputHelper output) : LinkTestBase(output,
6666
public void GeneratesHtml() =>
6767
// language=html
6868
Html.Should().Contain(
69-
"""<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>"""
69+
"""<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>"""
7070
);
7171

7272
[Fact]
@@ -86,7 +86,7 @@ public class InsertPageTitleTests(ITestOutputHelper output) : LinkTestBase(outpu
8686
public void GeneratesHtml() =>
8787
// language=html
8888
Html.Should().Contain(
89-
"""<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>"""
89+
"""<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>"""
9090
);
9191

9292
[Fact]
@@ -108,7 +108,7 @@ public class RepositoryLinksTest(ITestOutputHelper output) : LinkTestBase(output
108108
public void GeneratesHtml() =>
109109
// language=html
110110
Html.Should().Contain(
111-
"""<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>"""
111+
"""<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>"""
112112
);
113113

114114
[Fact]
@@ -270,10 +270,10 @@ public void GeneratesHtml() =>
270270
Html.ReplaceLineEndings().TrimEnd().Should().Be("""
271271
<p>Links:</p>
272272
<ul>
273-
<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>
273+
<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>
274274
</ul>
275275
<ul>
276-
<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>
276+
<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>
277277
</ul>
278278
""".ReplaceLineEndings());
279279

0 commit comments

Comments
 (0)