import { getCurrentPath } from '~/utils/url'
import classNames from 'classnames'
import Skeleton from 'react-loading-skeleton'
import { Link, NavLink } from 'react-router-dom'
import { getActionUrl, getName } from '~/utils/actions'
import { useOrgParams } from '~/utils/organization'
import {
ActionGroupLookupResult,
ActionMode,
NamedActionLike,
} from '~/utils/types'
function SubnavItem({
item,
orgEnvSlug,
mode,
}: {
orgEnvSlug: string
mode: ActionMode
item: NamedActionLike & { id: string }
type: 'group' | 'action'
}) {
return (
classNames('block group py-1', {
'text-primary-500 font-medium': isActive,
'text-gray-700': !isActive,
})
}
end
data-pw-run-slug={item.slug}
>
{getName(item)}
)
}
export default function PageSubnav({
title,
mode,
actionSlug,
secondaryNav,
}: {
title?: string | null
mode: ActionMode
actionSlug: string
secondaryNav: ActionGroupLookupResult
}) {
const { orgEnvSlug } = useOrgParams()
// Note: do not filter items here; the parent component needs to know
// if there are any items to render.
return (
{title ?? }
{secondaryNav?.groups?.map(group => (
<>
{(group.actions.length > 0 || group.groups.length > 0) &&
(actionSlug === group.slug ||
actionSlug.substring(0, actionSlug.lastIndexOf('/')) ===
group.slug) && (
{group.groups.map(action => (
))}
{group.actions.map(action => (
))}
)}
>
))}
{secondaryNav?.actions?.map(action => (
))}
)
}