[API explorer] Replace raw x-state badges with applies_to popover#3026
[API explorer] Replace raw x-state badges with applies_to popover#3026szabosteve wants to merge 3 commits intomainfrom
Conversation
Parse x-state extension values into structured lifecycle and version data, then render them using the existing applies-to-popover web component instead of plain version-badge spans. This makes endpoint availability badges consistent with the rest of the documentation site. Made-with: Cursor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis change adds an AvailabilityBadgeHelper and AvailabilityBadgeData to parse Sequence Diagram(s)sequenceDiagram
participant View as Operation/Property View
participant OpenApi as OpenApiOperation/Schema
participant Versions as VersionsConfiguration
participant Helper as AvailabilityBadgeHelper
participant Popover as applies-to-popover
View->>OpenApi: pass operation/schema
View->>Versions: provide VersionsConfiguration
View->>Helper: FromOperation/FromSchema(OpenApi, Versions)
Helper->>OpenApi: read "x-state" extension
Helper->>Helper: parse lifecycle and extract semantic version
Helper->>Versions: consult version lookup (released/unreleased)
Helper-->>View: AvailabilityBadgeData (or null)
alt badge data present
View->>Popover: render with BadgeKey, LifecycleText, Version, Flags
else no badge
View-->>View: skip popover rendering
end
Suggested labels
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches✨ Simplify code
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/Elastic.ApiExplorer/Operations/AvailabilityBadgeHelper.cs`:
- Around line 83-103: GetCurrentStackVersion(versionsConfig) can return null and
current code treats that as "not released" causing all badges to show planned;
change the isReleased logic so a null currentVersion does not force "planned" —
set isReleased = currentVersion is null || version.Min <= currentVersion (or
equivalent) in the AvailabilityBadgeHelper flow so parsed lifecycle/version
(FormatVersion/versionDisplay, ProductLifecycle handling and the '+' TrimEnd)
are used when no stack config is available.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 724b49f4-1733-443d-9a38-018a4a843ba4
📒 Files selected for processing (5)
src/Elastic.ApiExplorer/Operations/AvailabilityBadgeHelper.cssrc/Elastic.ApiExplorer/Operations/OperationView.cshtmlsrc/Elastic.ApiExplorer/Schema/RenderContext.cssrc/Elastic.ApiExplorer/Shared/_PropertyItem.cshtmlsrc/Elastic.ApiExplorer/Shared/_UnionOptions.cshtml
Broaden version regex from "Added in X.Y.Z" to any semver pattern so deprecated/removed versions are also captured. Treat missing stack version config as released rather than planned, so badges fall back to the parsed lifecycle/version instead of mislabeling as "Planned". Made-with: Cursor
Summary
Relates to https://github.com/elastic/docs-eng-team/issues/452
x-statestring badges (<span class="version-badge">) with structured<applies-to-popover>web component badges on API explorer endpoint pagesx-stateinto lifecycle (GA, Preview, Beta, Deprecated, Removed) and version data using the same logic asOpenApiDocumentExporterChanges
AvailabilityBadgeHelper.cs-- parsesx-stateextensions and produces badge attributes for the<applies-to-popover>web componentOperationView.cshtml-- replacedversion-badgespan withapplies-to-popoverbelow the h1 title; removed leftover debug spans_PropertyItem.cshtml-- same badge treatment for property-levelx-stateannotations_UnionOptions.cshtml-- propagatesVersionsConfigurationto child contextsRenderContext.cs-- added optionalVersionsConfigurationproperty toPropertyRenderContextandUnionVariantsContextNotes
x-stateshow-popover="false") -- can be enabled as a follow-upElastic.ApiExplorerMade with Cursor