![JAR search and dependency download from the Maven repository](/logo.png)
plugins.SideBar.Menu.NavItems.Dropdown.Dropdown.tsx Maven / Gradle / Ivy
import React from 'react'
import isEmpty from 'lodash/isEmpty'
import map from 'lodash/map'
import classNames from 'classnames'
import { useLocation } from 'react-router-dom'
import { id as generateId } from '../../../../../utils/id'
import { NavItemContainer } from '../../../NavItemContainer'
import { Item } from '../../../../CommonMenuTypes'
import { metaPropsType } from '../../../../utils'
import { DataSourceModels } from '../../../../../core/datasource/const'
import { DropdownWrapper } from './DropdownWrapper'
interface DropdownProps {
item: Item
sidebarOpen: boolean
showContent: boolean
isMiniView: boolean
datasources: metaPropsType[]
datasource: string
models: DataSourceModels
activeId: string
level: number
isStaticView: boolean
}
function hasActiveSubItem(items: Item['items'], location: { pathname: string }): boolean {
return items.some((item) => {
if (item.href === location.pathname) { return true }
if (item.items?.length) { return hasActiveSubItem(item.items, location) }
return false
})
}
export function Dropdown({
item,
sidebarOpen,
showContent,
isMiniView,
datasources,
datasource,
models,
activeId,
level,
isStaticView,
}: DropdownProps) {
const dropdownId = generateId()
const location = useLocation()
if (isEmpty(item)) { return null }
const { items = [] } = item
if (!items.length) { return null }
const isOpen = hasActiveSubItem(items, location)
return (
{map(items, (item, i) => (
))}
)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy