Skip to content

Commit ca7a658

Browse files
authored
Handle empty stack: applies_to output in HTML (#1456)
1 parent 036bf5d commit ca7a658

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

docs/testing/req.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Current version: **9.0.0**
2929
| `` {applies_to}`stack: removed 8.18` `` | {applies_to}`stack: removed 8.18` |
3030
| `` {applies_to}`stack: removed 9.0` `` | {applies_to}`stack: removed 9.0` |
3131
| `` {applies_to}`stack: removed 9.1` `` | {applies_to}`stack: removed 9.1` |
32+
| `` {applies_to}`stack: ` `` | {applies_to}`stack: ` |
3233

3334
{applies_to}`stack: deprecated 9.1, removed 9.4`
3435

src/Elastic.Markdown/Myst/Components/ApplicableToComponent.cshtml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@using System.Diagnostics.CodeAnalysis
12
@using Elastic.Documentation
23
@using Elastic.Markdown.Myst.FrontMatter
34
@inherits RazorSlice<Elastic.Markdown.Myst.Components.ApplicableToViewModel>
@@ -94,7 +95,7 @@
9495
switch (applicability.Lifecycle)
9596
{
9697
case ProductLifecycle.TechnicalPreview:
97-
if (applicability.Version is not null && applicability.Version > currentStackVersion)
98+
if (TryGetRealVersion(applicability, out var previewVersion) && previewVersion > currentStackVersion)
9899
{
99100
badgeText = "Planned";
100101
tooltip = "We plan to add this functionality in a future update. Plans may change without notice.";
@@ -105,7 +106,7 @@
105106
}
106107
break;
107108
case ProductLifecycle.Beta:
108-
if (applicability.Version is not null && applicability.Version > currentStackVersion)
109+
if (TryGetRealVersion(applicability, out var betaVersion) && betaVersion > currentStackVersion)
109110
{
110111
badgeText = "Planned";
111112
tooltip = "We plan to add this functionality in a future update. Plans may change without notice.";
@@ -117,23 +118,23 @@
117118

118119
break;
119120
case ProductLifecycle.GenerallyAvailable:
120-
if (applicability.Version is not null && applicability.Version > currentStackVersion)
121+
if (TryGetRealVersion(applicability, out var version) && version > currentStackVersion)
121122
{
122123
badgeText = "Planned";
123124
tooltip = "We plan to add this functionality in a future update. Plans may change without notice.";
124125
}
125126

126127
break;
127128
case ProductLifecycle.Deprecated:
128-
if (applicability.Version is not null && applicability.Version > currentStackVersion)
129+
if (TryGetRealVersion(applicability, out var deprecatedVersion) && deprecatedVersion > currentStackVersion)
129130
{
130131
badgeText = "Deprecation planned";
131132
tooltip = "We plan to deprecate this functionality in a future update. Plans may change without notice.";
132133
}
133134

134135
break;
135136
case ProductLifecycle.Removed:
136-
if (applicability.Version is not null && applicability.Version > currentStackVersion)
137+
if (TryGetRealVersion(applicability, out var removedVersion) && removedVersion > currentStackVersion)
137138
{
138139
badgeText = "Removal planned";
139140
tooltip = "We plan to remove this functionality in a future update. Plans may change without notice.";
@@ -177,3 +178,16 @@
177178
return HtmlString.Empty;
178179
}
179180
}
181+
@functions {
182+
private static bool TryGetRealVersion(Applicability applicability, [NotNullWhen(true)] out SemVersion? version)
183+
{
184+
version = null;
185+
if (applicability.Version is not null && applicability.Version != AllVersions.Instance)
186+
{
187+
version = applicability.Version;
188+
return true;
189+
}
190+
191+
return false;
192+
}
193+
}

0 commit comments

Comments
 (0)