import { useParams } from 'common' import { useInstalledIntegrations } from 'components/interfaces/Integrations/Landing/useInstalledIntegrations' import AlertError from 'components/ui/AlertError' import { ProductMenu } from 'components/ui/ProductMenu' import { ProductMenuItem } from 'components/ui/ProductMenu/ProductMenuItem' import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled' import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject' import { getPathnameWithoutQuery } from 'lib/pathname.utils' import { useRouter } from 'next/router' import { Menu, Separator } from 'ui' import { GenericSkeletonLoader } from 'ui-patterns' import { getCategoryParamFromAsPath, getIntegrationsPageFromPathname } from './Integrations.utils' import { generateIntegrationsMenu } from './IntegrationsMenu.utils' export function IntegrationsProductMenu() { const router = useRouter() const { ref: projectRef } = useParams() const { data: project } = useSelectedProjectQuery() const { integrationsWrappers: showWrappers } = useIsFeatureEnabled(['integrations:wrappers']) const resolvedProjectRef = projectRef ?? project?.ref const pathname = getPathnameWithoutQuery(router.asPath, router.pathname) const page = getIntegrationsPageFromPathname(pathname) const categoryParam = getCategoryParamFromAsPath(router.asPath) const { installedIntegrations: integrations, error, isLoading, isSuccess, isError, } = useInstalledIntegrations() const resolvedPage = page === 'integrations' ? categoryParam ? `integrations-${categoryParam}` : 'integrations' : page return ( <>
Installed
} /> {isLoading && } {isError && ( )} {isSuccess && resolvedProjectRef && integrations.map((integration) => ( {integration.icon({ className: 'p-1' })} ), items: [], }} /> ))} ) }