diff --git a/src/Elastic.ApiExplorer/Endpoints/EndpointView.cshtml b/src/Elastic.ApiExplorer/Endpoints/EndpointView.cshtml
index b8487e1fb..95bc519ec 100644
--- a/src/Elastic.ApiExplorer/Endpoints/EndpointView.cshtml
+++ b/src/Elastic.ApiExplorer/Endpoints/EndpointView.cshtml
@@ -12,8 +12,6 @@
Next = null,
NavigationHtml = Model.NavigationHtml,
UrlPathPrefix = null,
- VersionDropdown = null,
- CurrentVersion = null,
AllowIndexing = false,
CanonicalBaseUrl = null,
GoogleTagManager = new GoogleTagManagerConfiguration(),
diff --git a/src/Elastic.ApiExplorer/Landing/LandingView.cshtml b/src/Elastic.ApiExplorer/Landing/LandingView.cshtml
index f6af0e1d7..d24553791 100644
--- a/src/Elastic.ApiExplorer/Landing/LandingView.cshtml
+++ b/src/Elastic.ApiExplorer/Landing/LandingView.cshtml
@@ -12,8 +12,6 @@
Next = null,
NavigationHtml = Model.NavigationHtml,
UrlPathPrefix = null,
- VersionDropdown = null,
- CurrentVersion = "9.0+",
AllowIndexing = false,
CanonicalBaseUrl = null,
GoogleTagManager = new GoogleTagManagerConfiguration(),
diff --git a/src/Elastic.ApiExplorer/Operations/OperationView.cshtml b/src/Elastic.ApiExplorer/Operations/OperationView.cshtml
index bf2593d1c..12d821176 100644
--- a/src/Elastic.ApiExplorer/Operations/OperationView.cshtml
+++ b/src/Elastic.ApiExplorer/Operations/OperationView.cshtml
@@ -12,8 +12,6 @@
Next = null,
NavigationHtml = Model.NavigationHtml,
UrlPathPrefix = null,
- VersionDropdown = null,
- CurrentVersion = null,
AllowIndexing = false,
CanonicalBaseUrl = null,
GoogleTagManager = new GoogleTagManagerConfiguration(),
diff --git a/src/Elastic.Documentation.Site/Assets/web-components/VersionDropdown.tsx b/src/Elastic.Documentation.Site/Assets/web-components/VersionDropdown.tsx
index bc5b17576..c4d77844a 100644
--- a/src/Elastic.Documentation.Site/Assets/web-components/VersionDropdown.tsx
+++ b/src/Elastic.Documentation.Site/Assets/web-components/VersionDropdown.tsx
@@ -1,3 +1,5 @@
+'strict'
+
import {
EuiButton,
EuiContextMenu,
@@ -6,7 +8,12 @@ import {
EuiIcon,
EuiPopover,
EuiText,
+ EuiPanel,
+ EuiLink,
+ useEuiOverflowScroll,
useGeneratedHtmlId,
+ useEuiTheme,
+ useEuiFontSize,
} from '@elastic/eui'
import { icon as EuiIconVisualizeApp } from '@elastic/eui/es/components/icon/assets/app_visualize'
import { icon as EuiIconArrowDown } from '@elastic/eui/es/components/icon/assets/arrow_down'
@@ -50,12 +57,18 @@ type VersionDropdownItem = {
}
type VersionDropdownProps = {
- currentVersion: string
- items: VersionDropdownItem[]
+ currentVersion?: string
+ allVersionsUrl?: string
+ items?: VersionDropdownItem[]
}
-const VersionDropdown = ({ currentVersion, items }: VersionDropdownProps) => {
+const VersionDropdown = ({
+ allVersionsUrl,
+ currentVersion,
+ items,
+}: VersionDropdownProps) => {
const [isPopoverOpen, setPopover] = useState(false)
+ const { euiTheme } = useEuiTheme()
const contextMenuPopoverId = useGeneratedHtmlId({
prefix: 'contextMenuPopover',
@@ -84,60 +97,112 @@ const VersionDropdown = ({ currentVersion, items }: VersionDropdownProps) => {
const convertToPanels = (
items: VersionDropdownItem[]
): EuiContextMenuPanelDescriptor[] => {
- return items.flatMap((item, index) => {
- if (item.children == null) {
- return []
- } else {
- return {
- id: index + 1,
- title: item.name,
- initialFocusedItemIndex: 0,
- width: WIDTH,
- disabled: item.disabled,
- size: 's',
- items: item.children ? convertItems(item.children) : [],
- }
- }
- })
+ return items == null
+ ? []
+ : items.flatMap((item, index) => {
+ if (item.children == null) {
+ return []
+ } else {
+ return {
+ id: index + 1,
+ title: item.name,
+ initialFocusedItemIndex: 0,
+ width: WIDTH,
+ disabled: item.disabled,
+ size: 's',
+ items: item.children
+ ? convertItems(item.children)
+ : [],
+ }
+ }
+ })
}
const WIDTH = 175
- const topLevelItems = items.map((item, index) => {
- return {
- name: item.name,
- panel: item.children?.length ? index + 1 : undefined,
- href: item.href,
- disabled: item.disabled,
- }
- })
+ const topLevelItems = () =>
+ items.map((item, index) => {
+ return {
+ name: item.name,
+ panel: item.children?.length ? index + 1 : undefined,
+ href: item.href,
+ disabled: item.disabled,
+ }
+ })
- const subpanels = convertToPanels(items)
+ const subpanels = () => convertToPanels(items)
- const panels: EuiContextMenuPanelDescriptor[] = [
+ const panels = (): EuiContextMenuPanelDescriptor[] => [
{
id: 0,
title: (