|
| 1 | +@using System.Diagnostics.CodeAnalysis |
1 | 2 | @using Elastic.Documentation |
2 | 3 | @using Elastic.Markdown.Myst.FrontMatter |
3 | 4 | @inherits RazorSlice<Elastic.Markdown.Myst.Components.ApplicableToViewModel> |
|
94 | 95 | switch (applicability.Lifecycle) |
95 | 96 | { |
96 | 97 | case ProductLifecycle.TechnicalPreview: |
97 | | - if (applicability.Version is not null && applicability.Version > currentStackVersion) |
| 98 | + if (TryGetRealVersion(applicability, out var previewVersion) && previewVersion > currentStackVersion) |
98 | 99 | { |
99 | 100 | badgeText = "Planned"; |
100 | 101 | tooltip = "We plan to add this functionality in a future update. Plans may change without notice."; |
|
105 | 106 | } |
106 | 107 | break; |
107 | 108 | case ProductLifecycle.Beta: |
108 | | - if (applicability.Version is not null && applicability.Version > currentStackVersion) |
| 109 | + if (TryGetRealVersion(applicability, out var betaVersion) && betaVersion > currentStackVersion) |
109 | 110 | { |
110 | 111 | badgeText = "Planned"; |
111 | 112 | tooltip = "We plan to add this functionality in a future update. Plans may change without notice."; |
|
117 | 118 |
|
118 | 119 | break; |
119 | 120 | case ProductLifecycle.GenerallyAvailable: |
120 | | - if (applicability.Version is not null && applicability.Version > currentStackVersion) |
| 121 | + if (TryGetRealVersion(applicability, out var version) && version > currentStackVersion) |
121 | 122 | { |
122 | 123 | badgeText = "Planned"; |
123 | 124 | tooltip = "We plan to add this functionality in a future update. Plans may change without notice."; |
124 | 125 | } |
125 | 126 |
|
126 | 127 | break; |
127 | 128 | case ProductLifecycle.Deprecated: |
128 | | - if (applicability.Version is not null && applicability.Version > currentStackVersion) |
| 129 | + if (TryGetRealVersion(applicability, out var deprecatedVersion) && deprecatedVersion > currentStackVersion) |
129 | 130 | { |
130 | 131 | badgeText = "Deprecation planned"; |
131 | 132 | tooltip = "We plan to deprecate this functionality in a future update. Plans may change without notice."; |
132 | 133 | } |
133 | 134 |
|
134 | 135 | break; |
135 | 136 | case ProductLifecycle.Removed: |
136 | | - if (applicability.Version is not null && applicability.Version > currentStackVersion) |
| 137 | + if (TryGetRealVersion(applicability, out var removedVersion) && removedVersion > currentStackVersion) |
137 | 138 | { |
138 | 139 | badgeText = "Removal planned"; |
139 | 140 | tooltip = "We plan to remove this functionality in a future update. Plans may change without notice."; |
|
177 | 178 | return HtmlString.Empty; |
178 | 179 | } |
179 | 180 | } |
| 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