Skip to content

Hacky dynamic applies_to badges for stack versioning system #1448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 26, 2025
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
35 changes: 34 additions & 1 deletion docs/testing/req.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
---

Check notice on line 1 in docs/testing/req.md

View workflow job for this annotation

GitHub Actions / build

The 'deprecated' lifecycle is deprecated and will be removed in a future release.

Check notice on line 1 in docs/testing/req.md

View workflow job for this annotation

GitHub Actions / build

The 'deprecated' lifecycle is deprecated and will be removed in a future release.

Check notice on line 1 in docs/testing/req.md

View workflow job for this annotation

GitHub Actions / build

The 'deprecated' lifecycle is deprecated and will be removed in a future release.

Check notice on line 1 in docs/testing/req.md

View workflow job for this annotation

GitHub Actions / build

The 'deprecated' lifecycle is deprecated and will be removed in a future release.

Check notice on line 1 in docs/testing/req.md

View workflow job for this annotation

GitHub Actions / build

The 'deprecated' lifecycle is deprecated and will be removed in a future release.
applies_to:
stack: ga 9.1
---

# Requirements

Current version: **9.0.0**

| `applies_to` | result |
|--------------------------------------------|--------------------------------------|
| `` {applies_to}`stack: preview` `` | {applies_to}`stack: preview` |
| `` {applies_to}`stack: preview 8.18` `` | {applies_to}`stack: preview 8.18` |
| `` {applies_to}`stack: preview 9.0` `` | {applies_to}`stack: preview 9.0` |
| `` {applies_to}`stack: preview 9.1` `` | {applies_to}`stack: preview 9.1` |
| `` {applies_to}`stack: ga` `` | {applies_to}`stack: ga` |
| `` {applies_to}`stack: ga 8.18` `` | {applies_to}`stack: ga 8.18` |
| `` {applies_to}`stack: ga 9.0` `` | {applies_to}`stack: ga 9.0` |
| `` {applies_to}`stack: ga 9.1` `` | {applies_to}`stack: ga 9.1` |
| `` {applies_to}`stack: beta` `` | {applies_to}`stack: beta` |
| `` {applies_to}`stack: beta 8.18` `` | {applies_to}`stack: beta 8.18` |
| `` {applies_to}`stack: beta 9.0` `` | {applies_to}`stack: beta 9.0` |
| `` {applies_to}`stack: beta 9.1` `` | {applies_to}`stack: beta 9.1` |
| `` {applies_to}`stack: deprecated` `` | {applies_to}`stack: deprecated` |
| `` {applies_to}`stack: deprecated 8.18` `` | {applies_to}`stack: deprecated 8.18` |
| `` {applies_to}`stack: deprecated 9.0` `` | {applies_to}`stack: deprecated 9.0` |
| `` {applies_to}`stack: deprecated 9.1` `` | {applies_to}`stack: deprecated 9.1` |
| `` {applies_to}`stack: removed` `` | {applies_to}`stack: removed` |
| `` {applies_to}`stack: removed 8.18` `` | {applies_to}`stack: removed 8.18` |
| `` {applies_to}`stack: removed 9.0` `` | {applies_to}`stack: removed 9.0` |
| `` {applies_to}`stack: removed 9.1` `` | {applies_to}`stack: removed 9.1` |

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


To follow this tutorial you will need to install the following components:

- An installation of Elasticsearch, based on our hosted [Elastic Cloud](https://www.elastic.co/cloud) service (which includes a free trial period), or a self-hosted service that you run on your own computer. See the Install Elasticsearch section above for installation instructions.
Expand All @@ -9,4 +42,4 @@

- Python development
- The [Flask](https://flask.palletsprojects.com/) web framework for Python.
- The command prompt or terminal application in your operating system.
- The command prompt or terminal application in your operating system.
4 changes: 4 additions & 0 deletions src/Elastic.Documentation.Site/Assets/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'htmx-ext-head-support'
import 'htmx-ext-preload'
import 'htmx.org'
import { $, $$ } from 'select-dom'
import tippy from 'tippy.js'
import { UAParser } from 'ua-parser-js'

const { getOS } = new UAParser()
Expand All @@ -24,6 +25,9 @@ document.addEventListener('htmx:load', function () {
initSmoothScroll()
openDetailsWithAnchor()
initDismissibleBanner()
tippy('[data-tippy-content]:not([data-tippy-content=""])', {
delay: [400, 100],
})
})

// Don't remove style tags because they are used by the elastic global nav.
Expand Down
5 changes: 5 additions & 0 deletions src/Elastic.Documentation.Site/Assets/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
@import './archive.css';
@import './markdown/stepper.css';
@import './api-docs.css';
@import 'tippy.js/dist/tippy.css';

:root {
--outline-size: max(2px, 0.08em);
Expand Down Expand Up @@ -162,6 +163,7 @@
}

.applicable-info {
cursor: default;
padding: calc(var(--spacing) * 0.5);
padding-left: calc(var(--spacing) * 2);
padding-right: calc(var(--spacing) * 2);
Expand All @@ -173,6 +175,9 @@
background-color: var(--color-white);
border: 1px solid var(--color-grey-20);
font-weight: normal;
&[data-tippy-content]:not([data-tippy-content='']) {
cursor: help;
}
}
.applicable-version {
font-weight: bold;
Expand Down
18 changes: 18 additions & 0 deletions src/Elastic.Documentation.Site/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/Elastic.Documentation.Site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"htmx.org": "2.0.5",
"select-dom": "9.3.1",
"tailwindcss": "4.1.10",
"tippy.js": "6.3.7",
"ua-parser-js": "2.0.3"
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@using Elastic.Documentation
@using Elastic.Markdown.Myst.FrontMatter
@inherits RazorSlice<Elastic.Markdown.Myst.Components.ApplicableToViewModel>

Expand Down Expand Up @@ -61,23 +62,98 @@

private IHtmlContent RenderProduct(string name, AppliesCollection applications)
{
var currentStackVersion = new SemVersion(9, 0, 0);
foreach (var applicability in applications)
{

var tooltip = "";
var badgeText = name;

if (name == "Elastic Stack")
{
switch (applicability.Lifecycle)
{
case ProductLifecycle.TechnicalPreview:
if (applicability.Version is not null && applicability.Version > currentStackVersion)
{
badgeText = "Planned";
tooltip = "We plan to add this functionality in a future update. Plans may change without notice.";
}
else
{
tooltip = "This functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.";
}
break;
case ProductLifecycle.Beta:
if (applicability.Version is not null && applicability.Version > currentStackVersion)
{
badgeText = "Planned";
tooltip = "We plan to add this functionality in a future update. Plans may change without notice.";
}
else
{
tooltip = "This functionality is in beta and is subject to change. The design and code is less mature than official GA features and is being provided as-is with no warranties. Beta features are not subject to the support SLA of official GA features.";
}

break;
case ProductLifecycle.GenerallyAvailable:
if (applicability.Version is not null && applicability.Version > currentStackVersion)
{
badgeText = "Planned";
tooltip = "We plan to add this functionality in a future update. Plans may change without notice.";
}

break;
case ProductLifecycle.Deprecated:
if (applicability.Version is not null && applicability.Version > currentStackVersion)
{
badgeText = "Deprecation planned";
tooltip = "We plan to deprecate this functionality in a future update. Plans may change without notice.";
}

break;
case ProductLifecycle.Removed:
if (applicability.Version is not null && applicability.Version > currentStackVersion)
{
badgeText = "Removal planned";
tooltip = "We plan to remove this functionality in a future update. Plans may change without notice.";
}
break;
}
}

var lifecycleClass = applicability.GetLifeCycleName().ToLowerInvariant().Replace(" ", "-");
<span class="applicable-info">
@name
<span class="applicable-info" data-tippy-content="@tooltip">
@if (name == "Elastic Stack")
{
@badgeText
}
else
{
@name
}
<span class="applicable-meta applicable-meta-@lifecycleClass">
@if (applicability.Lifecycle != ProductLifecycle.GenerallyAvailable)
@if (applicability.Lifecycle != ProductLifecycle.GenerallyAvailable && badgeText == name)
{
<span class="applicable-lifecycle applicable-lifecycle-@lifecycleClass">@applicability.GetLifeCycleName()</span>
}
@if (applicability.Version is not null and not AllVersions)
{
<span class="applicable-version applicable-version-@lifecycleClass">@applicability.Version</span>
if (name == "Elastic Stack")
{
if (applicability.Version <= currentStackVersion)
{
<span class="applicable-version applicable-version-@lifecycleClass">@applicability.Version</span>
}
}
else
{
<span class="applicable-version applicable-version-@lifecycleClass">@applicability.Version</span>
}
}
</span>
</span>
}
return HtmlString.Empty;
}
}
}
7 changes: 2 additions & 5 deletions tests/authoring/Inline/AppliesToRole.fs
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ This is an inline {applies_to}`stack: preview 9.1` element.
markdown |> convertsToHtml """
<p>This is an inline
<span class="applies-inline">
<span class="applicable-info">
Elastic Stack
<span class="applicable-info" data-tippy-content="We plan to add this functionality in a future update. Plans may change without notice.">
Planned
<span class="applicable-meta applicable-meta-technical-preview">
<span class="applicable-lifecycle applicable-lifecycle-technical-preview">Technical Preview</span>
<span class="applicable-version applicable-version-technical-preview">9.1.0</span>
</span>
</span>
</span>
Expand Down Expand Up @@ -72,4 +70,3 @@ This is an inline {preview}`9.1` element.
directives |> appliesToDirective (ApplicableTo(
Product=AppliesCollection.op_Explicit "preview 9.1.0"
))

Loading