Files
supabase/apps/studio/components/layouts/ProjectIntegrationsLayout.tsx
dc986674d9 chore(studio): integrations Marketplace layout (#45856)
Introducing a new Integrations Marketplace layout
- behind feature flag
- behind opt-out feature preview (default to true) to easily toggle
before and after

Doesn't introduce new functionality, only layout change behind ff.

## What changed

Nothing if `marketplaceIntegrations` flag is off.

### With flag

- New Marketplace index layout
  - filter via text or by `category`, `integration type` and `source`
- Featured Partners Integrations hero (hidden when any filter is active)
  - toggle between `grid` and `list` view
- new integration detail page layout
  - with top action bar
  - more consistent fullWidth or narrow content layouts
- can access Feature Preview toggle under Account Dropdown > Feature
Previews > Marketplace

## How to review and what to test

I recommend reviewing file changes from bottom to top in
https://github.com/supabase/supabase/pull/45856/changes because it makes
more sense from a pr-logic perspective.

- [ ] Visit
https://studio-staging-git-chore-integrations-ui-refine-fs-supabase.vercel.app/dashboard/project/_/integrations
- [ ] Check if new layout doesn't have big layout issues like weird
paddings or margins mostly. (We can iterate in upcoming PRs for
additional features/fixes)
- [ ] Toggle "Marketplace" feature preview to `FALSE` and check that the
Integrations layout looks like in prod
https://supabase.com/dashboard/project/_/integrations
- [ ] Also check individual integration pages and toggle the feature
preview on and off to see before and after and check if everything looks
good

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Full Marketplace experience: explorer with featured hero,
filters/search, list & grid views, cards, sidebar, detailed integration
pages, install flows, badges, and a preview toggle.

* **Bug Fixes**
  * Prevented stale markdown from showing when switching integrations.

* **Style**
* Improved responsive layouts, loading placeholders, and header/nav
full-width behavior.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/supabase/supabase/pull/45856)

<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Saxon Fletcher <saxonafletcher@gmail.com>
Co-authored-by: Raminder Singh <romi_ssk@yahoo.co.in>
2026-05-20 11:01:32 +02:00

180 lines
5.5 KiB
TypeScript

import { useQuery } from '@tanstack/react-query'
import { IS_PLATFORM, useFeatureFlags, useParams } from 'common'
import { useRouter } from 'next/router'
import { PropsWithChildren } from 'react'
import { Menu, Separator } from 'ui'
import { GenericSkeletonLoader } from 'ui-patterns'
import { useIsMarketplaceEnabled } from '@/components/interfaces/App/FeaturePreview/FeaturePreviewContext'
import { useInstalledIntegrations } from '@/components/interfaces/Integrations/Landing/useInstalledIntegrations'
import { ProjectLayout } from '@/components/layouts/ProjectLayout'
import AlertError from '@/components/ui/AlertError'
import { ProductMenu } from '@/components/ui/ProductMenu'
import { marketplaceCategoriesQueryOptions } from '@/data/marketplace/integration-categories-query'
import { marketplaceIntegrationsQueryOptions } from '@/data/marketplace/integrations-query'
import { useIsFeatureEnabled } from '@/hooks/misc/useIsFeatureEnabled'
import { withAuth } from '@/hooks/misc/withAuth'
/**
* Layout component for the Integrations section
* Provides sidebar navigation for integrations
*/
export const ProjectIntegrationsLayout = withAuth(({ children }: PropsWithChildren) => {
const router = useRouter()
const segments = router.asPath.split('/')
// construct the page url to be used to determine the active state for the sidebar
const page = `${segments[3]}${segments[4] ? `/${segments[4]}` : ''}`
return (
<ProjectLayout
product="Integrations"
browserTitle={{ section: 'Integrations' }}
isBlocking={false}
productMenu={
<>
<IntegrationCategoriesMenu page={page} />
<Separator />
<InstalledIntegrationsMenu page={page} />
</>
}
>
{children}
</ProjectLayout>
)
})
const IntegrationCategoriesMenu = ({ page }: { page: string }) => {
const router = useRouter()
const { ref } = useParams()
const { hasLoaded: flagsLoaded } = useFeatureFlags()
const isMarketplaceEnabled = useIsMarketplaceEnabled()
const urlParams = new URLSearchParams(router.asPath.split('?')[1] || '')
const categoryParam = urlParams.get('category')
const pageKey = categoryParam || page
const { integrationsWrappers: showWrappers } = useIsFeatureEnabled(['integrations:wrappers'])
const { data: categories = [], isPending: isPendingCategories } = useQuery(
marketplaceCategoriesQueryOptions({ enabled: isMarketplaceEnabled })
)
const { data: listings = [], isPending: isPendingListings } = useQuery(
marketplaceIntegrationsQueryOptions({ enabled: isMarketplaceEnabled })
)
const populatedCategoryIds = new Set(
listings.flatMap((listing) =>
Array.isArray(listing.categories)
? (listing.categories as Array<{ id: string }>).map((c) => c.id)
: []
)
)
const nonEmptyCategories = categories.filter(
(category) => category.id && populatedCategoryIds.has(category.id)
)
const isLoading = IS_PLATFORM
? !flagsLoaded || (isMarketplaceEnabled && (isPendingCategories || isPendingListings))
: false
const allCategories = [
{
name: 'All',
key: 'integrations',
url: `/project/${ref}/integrations`,
pages: ['integrations'],
items: [],
},
...(showWrappers
? [
{
name: 'Wrappers',
key: 'wrapper',
url: `/project/${ref}/integrations?category=wrapper`,
items: [],
},
]
: []),
{
name: 'Postgres Modules',
key: 'postgres_extension',
url: `/project/${ref}/integrations?category=postgres_extension`,
items: [],
},
...nonEmptyCategories.map((category) => ({
name: category.name ?? '',
key: category.slug ?? '',
url: `/project/${ref}/integrations?category=${category.slug}`,
items: [],
})),
]
return (
<>
{isLoading ? (
<div className="px-4 py-6 md:px-6">
<Menu type="pills">
<Menu.Group title={<span className="uppercase font-mono">Explore</span>} />
</Menu>
<GenericSkeletonLoader />
</div>
) : (
<ProductMenu
page={pageKey}
menu={[{ key: 'explore', title: 'Explore', items: allCategories }]}
/>
)}
</>
)
}
const InstalledIntegrationsMenu = ({ page }: { page: string }) => {
const { ref } = useParams()
const {
installedIntegrations: integrations,
error,
isLoading,
isSuccess,
isError,
} = useInstalledIntegrations()
const installedIntegrationItems = integrations.map((integration) => ({
name: integration.name,
label: integration.status,
key: `integrations/${integration.id}`,
url: `/project/${ref}/integrations/${integration.id}/overview`,
icon: (
<div className="relative w-6 h-6 bg-white border rounded-sm flex items-center justify-center">
{integration.icon({ className: 'p-1' })}
</div>
),
items: [],
}))
return (
<>
{(isLoading || isError) && (
<div className="px-4 py-6 md:px-6">
<Menu type="pills">
<Menu.Group title={<span className="uppercase font-mono">Installed</span>} />
</Menu>
{isLoading && <GenericSkeletonLoader />}
{isError && (
<AlertError
showIcon={false}
error={error}
subject="Failed to retrieve installed integrations"
/>
)}
</div>
)}
{isSuccess && (
<ProductMenu
page={page}
menu={[{ key: 'installed', title: 'Installed', items: installedIntegrationItems }]}
/>
)}
</>
)
}